summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
Diffstat (limited to 'classes')
-rw-r--r--classes/Avatar.php5
-rw-r--r--classes/Consumer.php1
-rwxr-xr-xclasses/Conversation.php2
-rw-r--r--classes/Fave.php28
-rw-r--r--classes/File.php1
-rw-r--r--classes/File_oembed.php1
-rw-r--r--classes/File_redirection.php1
-rw-r--r--classes/File_thumbnail.php1
-rw-r--r--classes/File_to_post.php1
-rw-r--r--classes/Foreign_link.php2
-rw-r--r--classes/Foreign_service.php4
-rw-r--r--classes/Foreign_subscription.php2
-rw-r--r--classes/Foreign_user.php1
-rw-r--r--classes/Group_block.php1
-rw-r--r--classes/Group_inbox.php2
-rw-r--r--classes/Group_member.php55
-rw-r--r--classes/Inbox.php9
-rw-r--r--classes/Invitation.php2
-rw-r--r--classes/Memcached_DataObject.php9
-rw-r--r--classes/Message.php1
-rw-r--r--classes/Nonce.php1
-rw-r--r--classes/Notice.php99
-rw-r--r--classes/Notice_source.php2
-rw-r--r--classes/Oauth_application.php2
-rw-r--r--classes/Oauth_application_user.php1
-rw-r--r--classes/Profile.php53
-rw-r--r--classes/Profile_tag.php2
-rw-r--r--classes/Remember_me.php10
-rw-r--r--classes/Remote_profile.php8
-rw-r--r--classes/Safe_DataObject.php1
-rw-r--r--classes/Sms_carrier.php4
-rw-r--r--classes/Status_network.php15
-rw-r--r--classes/Status_network_tag.php4
-rw-r--r--classes/Subscription.php29
-rw-r--r--classes/User.php68
-rw-r--r--classes/User_group.php1
-rw-r--r--classes/User_username.php6
37 files changed, 312 insertions, 123 deletions
diff --git a/classes/Avatar.php b/classes/Avatar.php
index dbe2cd813..6edc81768 100644
--- a/classes/Avatar.php
+++ b/classes/Avatar.php
@@ -42,8 +42,9 @@ class Avatar extends Memcached_DataObject
return Memcached_DataObject::pkeyGet('Avatar', $kv);
}
- // where should the avatar go for this user?
-
+ /**
+ * Where should the avatar go for this user?
+ */
static function filename($id, $extension, $size=null, $extra=null)
{
if ($size) {
diff --git a/classes/Consumer.php b/classes/Consumer.php
index ce399f278..c1090b85a 100644
--- a/classes/Consumer.php
+++ b/classes/Consumer.php
@@ -65,5 +65,4 @@ class Consumer extends Memcached_DataObject
$nonce->consumer_key = $this->consumer_key;
$nonce->delete();
}
-
}
diff --git a/classes/Conversation.php b/classes/Conversation.php
index f540004ef..aab55723f 100755
--- a/classes/Conversation.php
+++ b/classes/Conversation.php
@@ -74,6 +74,4 @@ class Conversation extends Memcached_DataObject
return $conv;
}
-
}
-
diff --git a/classes/Fave.php b/classes/Fave.php
index ed4f56aee..059b339cd 100644
--- a/classes/Fave.php
+++ b/classes/Fave.php
@@ -129,4 +129,32 @@ class Fave extends Memcached_DataObject
return $ids;
}
+
+ function asActivity()
+ {
+ $notice = Notice::staticGet('id', $this->notice_id);
+ $profile = Profile::staticGet('id', $this->user_id);
+
+ $act = new Activity();
+
+ $act->verb = ActivityVerb::FAVORITE;
+ $act->id = TagURI::mint('favor:%d:%d:%s',
+ $profile->id,
+ $notice->id,
+ common_date_iso8601($this->modified));
+
+ $act->time = strtotime($this->modified);
+ // TRANS: Activity title when marking a notice as favorite.
+ $act->title = _("Favor");
+ // TRANS: Ntofication given when a user marks a notice as favorite.
+ // TRANS: %1$s is a user nickname or full name, %2$s is a notice URI.
+ $act->content = sprintf(_("%1$s marked notice %2$s as a favorite."),
+ $profile->getBestName(),
+ $notice->uri);
+
+ $act->actor = ActivityObject::fromProfile($profile);
+ $act->objects[] = ActivityObject::fromNotice($notice);
+
+ return $act;
+ }
}
diff --git a/classes/File.php b/classes/File.php
index 407fd3211..d457968b5 100644
--- a/classes/File.php
+++ b/classes/File.php
@@ -29,7 +29,6 @@ require_once INSTALLDIR.'/classes/File_to_post.php';
/**
* Table Definition for file
*/
-
class File extends Memcached_DataObject
{
###START_AUTOCODE
diff --git a/classes/File_oembed.php b/classes/File_oembed.php
index 041b44740..4813d5dda 100644
--- a/classes/File_oembed.php
+++ b/classes/File_oembed.php
@@ -131,4 +131,3 @@ class File_oembed extends Memcached_DataObject
}
}
}
-
diff --git a/classes/File_redirection.php b/classes/File_redirection.php
index 6a86197d9..92f0125a4 100644
--- a/classes/File_redirection.php
+++ b/classes/File_redirection.php
@@ -311,4 +311,3 @@ class File_redirection extends Memcached_DataObject
$file_redir->insert();
}
}
-
diff --git a/classes/File_thumbnail.php b/classes/File_thumbnail.php
index f8b70356c..edae8ac21 100644
--- a/classes/File_thumbnail.php
+++ b/classes/File_thumbnail.php
@@ -57,4 +57,3 @@ class File_thumbnail extends Memcached_DataObject
$tn->insert();
}
}
-
diff --git a/classes/File_to_post.php b/classes/File_to_post.php
index 72a42b088..530921adc 100644
--- a/classes/File_to_post.php
+++ b/classes/File_to_post.php
@@ -67,4 +67,3 @@ class File_to_post extends Memcached_DataObject
return Memcached_DataObject::pkeyGet('File_to_post', $kv);
}
}
-
diff --git a/classes/Foreign_link.php b/classes/Foreign_link.php
index e47b2e309..60db51595 100644
--- a/classes/Foreign_link.php
+++ b/classes/Foreign_link.php
@@ -44,7 +44,6 @@ class Foreign_link extends Memcached_DataObject
$result = $flink->find(true);
return empty($result) ? null : $flink;
-
}
static function getByForeignID($foreign_id, $service)
@@ -129,5 +128,4 @@ class Foreign_link extends Memcached_DataObject
return false;
}
}
-
}
diff --git a/classes/Foreign_service.php b/classes/Foreign_service.php
index ef614dbd6..dd74fd2ca 100644
--- a/classes/Foreign_service.php
+++ b/classes/Foreign_service.php
@@ -4,7 +4,7 @@
*/
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
-class Foreign_service extends Memcached_DataObject
+class Foreign_service extends Memcached_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */
@@ -12,7 +12,7 @@ class Foreign_service extends Memcached_DataObject
public $__table = 'foreign_service'; // table name
public $id; // int(4) primary_key not_null
public $name; // varchar(32) unique_key not_null
- public $description; // varchar(255)
+ public $description; // varchar(255)
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
diff --git a/classes/Foreign_subscription.php b/classes/Foreign_subscription.php
index d50860621..ec2631238 100644
--- a/classes/Foreign_subscription.php
+++ b/classes/Foreign_subscription.php
@@ -4,7 +4,7 @@
*/
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
-class Foreign_subscription extends Memcached_DataObject
+class Foreign_subscription extends Memcached_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */
diff --git a/classes/Foreign_user.php b/classes/Foreign_user.php
index e98a16064..8e6e0b33e 100644
--- a/classes/Foreign_user.php
+++ b/classes/Foreign_user.php
@@ -83,5 +83,4 @@ class Foreign_user extends Memcached_DataObject
}
return $result;
}
-
}
diff --git a/classes/Group_block.php b/classes/Group_block.php
index 9f4d59295..ffc57a496 100644
--- a/classes/Group_block.php
+++ b/classes/Group_block.php
@@ -111,5 +111,4 @@ class Group_block extends Memcached_DataObject
return true;
}
-
}
diff --git a/classes/Group_inbox.php b/classes/Group_inbox.php
index 2a0787e38..8f5c65e59 100644
--- a/classes/Group_inbox.php
+++ b/classes/Group_inbox.php
@@ -1,8 +1,8 @@
<?php
+
/**
* Table Definition for group_inbox
*/
-
class Group_inbox extends Memcached_DataObject
{
###START_AUTOCODE
diff --git a/classes/Group_member.php b/classes/Group_member.php
index 2239461be..c40d06a1d 100644
--- a/classes/Group_member.php
+++ b/classes/Group_member.php
@@ -65,4 +65,59 @@ class Group_member extends Memcached_DataObject
return true;
}
+
+ function getMember()
+ {
+ $member = Profile::staticGet('id', $this->profile_id);
+
+ if (empty($member)) {
+ // TRANS: Exception thrown providing an invalid profile ID.
+ // TRANS: %s is the invalid profile ID.
+ throw new Exception(sprintf(_("Profile ID %s is invalid."),$this->profile_id));
+ }
+
+ return $member;
+ }
+
+ function getGroup()
+ {
+ $group = User_group::staticGet('id', $this->group_id);
+
+ if (empty($group)) {
+ // TRANS: Exception thrown providing an invalid group ID.
+ // TRANS: %s is the invalid group ID.
+ throw new Exception(sprintf(_("Group ID %s is invalid."),$this->group_id));
+ }
+
+ return $group;
+ }
+
+ function asActivity()
+ {
+ $member = $this->getMember();
+ $group = $this->getGroup();
+
+ $act = new Activity();
+
+ $act->id = TagURI::mint('join:%d:%d:%s',
+ $member->id,
+ $group->id,
+ common_date_iso8601($this->created));
+
+ $act->actor = ActivityObject::fromProfile($member);
+ $act->verb = ActivityVerb::JOIN;
+ $act->objects[] = ActivityObject::fromGroup($group);
+
+ $act->time = strtotime($this->created);
+ // TRANS: Activity title.
+ $act->title = _("Join");
+
+ // TRANS: Success message for subscribe to group attempt through OStatus.
+ // TRANS: %1$s is the member name, %2$s is the subscribed group's name.
+ $act->content = sprintf(_('%1$s has joined group %2$s.'),
+ $member->getBestName(),
+ $group->getBestName());
+
+ return $act;
+ }
}
diff --git a/classes/Inbox.php b/classes/Inbox.php
index 430419ba5..a1ab6215f 100644
--- a/classes/Inbox.php
+++ b/classes/Inbox.php
@@ -55,7 +55,6 @@ class Inbox extends Memcached_DataObject
/**
* Create a new inbox from existing Notice_inbox stuff
*/
-
static function initialize($user_id)
{
$inbox = Inbox::fromNoticeInbox($user_id);
@@ -115,10 +114,10 @@ class Inbox extends Memcached_DataObject
*/
static function insertNotice($user_id, $notice_id)
{
- // Going straight to the DB rather than trusting our caching
- // during an update. Note: not using DB_DataObject::staticGet,
- // which is unsafe to use directly (in-process caching causes
- // memory leaks, which accumulate in queue processes).
+ // Going straight to the DB rather than trusting our caching
+ // during an update. Note: not using DB_DataObject::staticGet,
+ // which is unsafe to use directly (in-process caching causes
+ // memory leaks, which accumulate in queue processes).
$inbox = new Inbox();
if (!$inbox->get('user_id', $user_id)) {
$inbox = Inbox::initialize($user_id);
diff --git a/classes/Invitation.php b/classes/Invitation.php
index 8a36fd8df..0e87c1629 100644
--- a/classes/Invitation.php
+++ b/classes/Invitation.php
@@ -4,7 +4,7 @@
*/
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
-class Invitation extends Memcached_DataObject
+class Invitation extends Memcached_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */
diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php
index 6feb59c34..8ffb46cc5 100644
--- a/classes/Memcached_DataObject.php
+++ b/classes/Memcached_DataObject.php
@@ -189,11 +189,11 @@ class Memcached_DataObject extends Safe_DataObject
str_replace("\n", " ", $e->getTraceAsString()));
return false;
} else {
- $keys = $this->_allCacheKeys();
+ $keys = $this->_allCacheKeys();
- foreach ($keys as $key) {
- $c->set($key, $this);
- }
+ foreach ($keys as $key) {
+ $c->set($key, $this);
+ }
}
}
@@ -637,4 +637,3 @@ class Memcached_DataObject extends Safe_DataObject
return $vstr;
}
}
-
diff --git a/classes/Message.php b/classes/Message.php
index fa0c5b318..353dc01f9 100644
--- a/classes/Message.php
+++ b/classes/Message.php
@@ -38,7 +38,6 @@ class Message extends Memcached_DataObject
}
static function saveNew($from, $to, $content, $source) {
-
$sender = Profile::staticGet('id', $from);
if (!$sender->hasRight(Right::NEWMESSAGE)) {
diff --git a/classes/Nonce.php b/classes/Nonce.php
index 2f8ab00b5..93191bd40 100644
--- a/classes/Nonce.php
+++ b/classes/Nonce.php
@@ -36,5 +36,4 @@ class Nonce extends Memcached_DataObject
{
return array('consumer_key,token' => 'token:consumer_key,token');
}
-
}
diff --git a/classes/Notice.php b/classes/Notice.php
index 4c6efd3eb..a8ec0529f 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -745,6 +745,7 @@ class Notice extends Memcached_DataObject
1,
1
);
+
if ($conversation->N > 0) {
return true;
}
@@ -753,8 +754,15 @@ class Notice extends Memcached_DataObject
}
/**
- * @param $groups array of Group *objects*
- * @param $recipients array of profile *ids*
+ * Pull up a full list of local recipients who will be getting
+ * this notice in their inbox. Results will be cached, so don't
+ * change the input data wily-nilly!
+ *
+ * @param array $groups optional list of Group objects;
+ * if left empty, will be loaded from group_inbox records
+ * @param array $recipient optional list of reply profile ids
+ * if left empty, will be loaded from reply records
+ * @return array associating recipient user IDs with an inbox source constant
*/
function whoGets($groups=null, $recipients=null)
{
@@ -787,27 +795,27 @@ class Notice extends Memcached_DataObject
$ni[$id] = NOTICE_INBOX_SOURCE_SUB;
}
- $profile = $this->getProfile();
-
foreach ($groups as $group) {
$users = $group->getUserMembers();
foreach ($users as $id) {
if (!array_key_exists($id, $ni)) {
- $user = User::staticGet('id', $id);
- if (!$user->hasBlocked($profile)) {
- $ni[$id] = NOTICE_INBOX_SOURCE_GROUP;
- }
+ $ni[$id] = NOTICE_INBOX_SOURCE_GROUP;
}
}
}
foreach ($recipients as $recipient) {
-
if (!array_key_exists($recipient, $ni)) {
- $recipientUser = User::staticGet('id', $recipient);
- if (!empty($recipientUser)) {
- $ni[$recipient] = NOTICE_INBOX_SOURCE_REPLY;
- }
+ $ni[$recipient] = NOTICE_INBOX_SOURCE_REPLY;
+ }
+ }
+
+ // Exclude any deleted, non-local, or blocking recipients.
+ $profile = $this->getProfile();
+ foreach ($ni as $id => $source) {
+ $user = User::staticGet('id', $id);
+ if (empty($user) || $user->hasBlocked($profile)) {
+ unset($ni[$id]);
}
}
@@ -1212,6 +1220,64 @@ class Notice extends Memcached_DataObject
return $groups;
}
+ function asActivity()
+ {
+ $profile = $this->getProfile();
+
+ $act = new Activity();
+
+ $act->actor = ActivityObject::fromProfile($profile);
+ $act->verb = ActivityVerb::POST;
+ $act->objects[] = ActivityObject::fromNotice($this);
+
+ $act->time = strtotime($this->created);
+ $act->link = $this->bestUrl();
+
+ $act->content = common_xml_safe_str($this->rendered);
+ $act->id = $this->uri;
+ $act->title = common_xml_safe_str($this->content);
+
+ $ctx = new ActivityContext();
+
+ if (!empty($this->reply_to)) {
+ $reply = Notice::staticGet('id', $this->reply_to);
+ if (!empty($reply)) {
+ $ctx->replyToID = $reply->uri;
+ $ctx->replyToUrl = $reply->bestUrl();
+ }
+ }
+
+ $ctx->location = $this->getLocation();
+
+ $conv = null;
+
+ if (!empty($this->conversation)) {
+ $conv = Conversation::staticGet('id', $this->conversation);
+ if (!empty($conv)) {
+ $ctx->conversation = $conv->uri;
+ }
+ }
+
+ $reply_ids = $this->getReplies();
+
+ foreach ($reply_ids as $id) {
+ $profile = Profile::staticGet('id', $id);
+ if (!empty($profile)) {
+ $ctx->attention[] = $profile->getUri();
+ }
+ }
+
+ $groups = $this->getGroups();
+
+ foreach ($groups as $group) {
+ $ctx->attention[] = $group->uri;
+ }
+
+ $act->context = $ctx;
+
+ return $act;
+ }
+
// This has gotten way too long. Needs to be sliced up into functional bits
// or ideally exported to a utility class.
@@ -1240,13 +1306,10 @@ class Notice extends Memcached_DataObject
}
if (Event::handle('StartActivitySource', array(&$this, &$xs))) {
-
if ($source) {
-
$atom_feed = $profile->getAtomFeed();
if (!empty($atom_feed)) {
-
$xs->elementStart('source');
// XXX: we should store the actual feed ID
@@ -1834,7 +1897,6 @@ class Notice extends Memcached_DataObject
$options = array();
if (!empty($location_id) && !empty($location_ns)) {
-
$options['location_id'] = $location_id;
$options['location_ns'] = $location_ns;
@@ -1846,7 +1908,6 @@ class Notice extends Memcached_DataObject
}
} else if (!empty($lat) && !empty($lon)) {
-
$options['lat'] = $lat;
$options['lon'] = $lon;
@@ -1857,7 +1918,6 @@ class Notice extends Memcached_DataObject
$options['location_ns'] = $location->location_ns;
}
} else if (!empty($profile)) {
-
if (isset($profile->lat) && isset($profile->lon)) {
$options['lat'] = $profile->lat;
$options['lon'] = $profile->lon;
@@ -1974,6 +2034,7 @@ class Notice extends Memcached_DataObject
{
// We always insert for the author so they don't
// have to wait
+ Event::handle('StartNoticeDistribute', array($this));
$user = User::staticGet('id', $this->profile_id);
if (!empty($user)) {
diff --git a/classes/Notice_source.php b/classes/Notice_source.php
index e7568bbca..43893ebe1 100644
--- a/classes/Notice_source.php
+++ b/classes/Notice_source.php
@@ -4,7 +4,7 @@
*/
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
-class Notice_source extends Memcached_DataObject
+class Notice_source extends Memcached_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */
diff --git a/classes/Oauth_application.php b/classes/Oauth_application.php
index 748b64220..e81706104 100644
--- a/classes/Oauth_application.php
+++ b/classes/Oauth_application.php
@@ -110,7 +110,6 @@ class Oauth_application extends Memcached_DataObject
*
* @return void
*/
-
function uploadLogo()
{
if ($_FILES['app_icon']['error'] ==
@@ -153,5 +152,4 @@ class Oauth_application extends Memcached_DataObject
$oauser->application_id = $this->id;
$oauser->delete();
}
-
}
diff --git a/classes/Oauth_application_user.php b/classes/Oauth_application_user.php
index 57986281f..3d4238d64 100644
--- a/classes/Oauth_application_user.php
+++ b/classes/Oauth_application_user.php
@@ -40,5 +40,4 @@ class Oauth_application_user extends Memcached_DataObject
return empty($result) ? null : $oau;
}
-
}
diff --git a/classes/Profile.php b/classes/Profile.php
index 230b3aa3a..1d130c44a 100644
--- a/classes/Profile.php
+++ b/classes/Profile.php
@@ -103,7 +103,6 @@ class Profile extends Memcached_DataObject
foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) {
# We don't do a scaled one if original is our scaled size
if (!($avatar->width == $size && $avatar->height == $size)) {
-
$scaled_filename = $imagefile->resize($size);
//$scaled = DB_DataObject::factory('avatar');
@@ -474,6 +473,41 @@ class Profile extends Memcached_DataObject
return $cnt;
}
+ function hasFave($notice)
+ {
+ $cache = Cache::instance();
+
+ // XXX: Kind of a hack.
+
+ if (!empty($cache)) {
+ // This is the stream of favorite notices, in rev chron
+ // order. This forces it into cache.
+
+ $ids = Fave::stream($this->id, 0, NOTICE_CACHE_WINDOW);
+
+ // If it's in the list, then it's a fave
+
+ if (in_array($notice->id, $ids)) {
+ return true;
+ }
+
+ // If we're not past the end of the cache window,
+ // then the cache has all available faves, so this one
+ // is not a fave.
+
+ if (count($ids) < NOTICE_CACHE_WINDOW) {
+ return false;
+ }
+
+ // Otherwise, cache doesn't have all faves;
+ // fall through to the default
+ }
+
+ $fave = Fave::pkeyGet(array('user_id' => $this->id,
+ 'notice_id' => $notice->id));
+ return ((is_null($fave)) ? false : true);
+ }
+
function faveCount()
{
$c = Cache::instance();
@@ -517,6 +551,20 @@ class Profile extends Memcached_DataObject
return $cnt;
}
+ function blowFavesCache()
+ {
+ $cache = common_memcache();
+ if ($cache) {
+ // Faves don't happen chronologically, so we need to blow
+ // ;last cache, too
+ $cache->delete(common_cache_key('fave:ids_by_user:'.$this->id));
+ $cache->delete(common_cache_key('fave:ids_by_user:'.$this->id.';last'));
+ $cache->delete(common_cache_key('fave:ids_by_user_own:'.$this->id));
+ $cache->delete(common_cache_key('fave:ids_by_user_own:'.$this->id.';last'));
+ }
+ $this->blowFaveCount();
+ }
+
function blowSubscriberCount()
{
$c = Cache::instance();
@@ -790,13 +838,14 @@ class Profile extends Memcached_DataObject
* @param $right string Name of the right, usually a constant in class Right
* @return boolean whether the user has the right in question
*/
-
function hasRight($right)
{
$result = false;
+
if ($this->hasRole(Profile_role::DELETED)) {
return false;
}
+
if (Event::handle('UserRightsCheck', array($this, $right, &$result))) {
switch ($right)
{
diff --git a/classes/Profile_tag.php b/classes/Profile_tag.php
index 0a1ad9cd6..ab6bab096 100644
--- a/classes/Profile_tag.php
+++ b/classes/Profile_tag.php
@@ -23,7 +23,6 @@ class Profile_tag extends Memcached_DataObject
###END_AUTOCODE
static function getTags($tagger, $tagged) {
-
$tags = array();
# XXX: store this in memcached
@@ -44,7 +43,6 @@ class Profile_tag extends Memcached_DataObject
}
static function setTags($tagger, $tagged, $newtags) {
-
$newtags = array_unique($newtags);
$oldtags = Profile_tag::getTags($tagger, $tagged);
diff --git a/classes/Remember_me.php b/classes/Remember_me.php
index 8dc29bfa3..3df7a9983 100644
--- a/classes/Remember_me.php
+++ b/classes/Remember_me.php
@@ -4,7 +4,7 @@
*/
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
-class Remember_me extends Memcached_DataObject
+class Remember_me extends Memcached_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */
@@ -16,11 +16,15 @@ class Remember_me extends Memcached_DataObject
/* Static get */
function staticGet($k,$v=null)
- { return Memcached_DataObject::staticGet('Remember_me',$k,$v); }
+ {
+ return Memcached_DataObject::staticGet('Remember_me',$k,$v);
+ }
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
function sequenceKey()
- { return array(false, false); }
+ {
+ return array(false, false);
+ }
}
diff --git a/classes/Remote_profile.php b/classes/Remote_profile.php
index 77bfbcd99..1672e9f95 100644
--- a/classes/Remote_profile.php
+++ b/classes/Remote_profile.php
@@ -24,7 +24,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
*/
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
-class Remote_profile extends Memcached_DataObject
+class Remote_profile extends Memcached_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */
@@ -32,8 +32,8 @@ class Remote_profile extends Memcached_DataObject
public $__table = 'remote_profile'; // table name
public $id; // int(4) primary_key not_null
public $uri; // varchar(255) unique_key
- public $postnoticeurl; // varchar(255)
- public $updateprofileurl; // varchar(255)
+ public $postnoticeurl; // varchar(255)
+ public $updateprofileurl; // varchar(255)
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
@@ -43,7 +43,7 @@ class Remote_profile extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
-
+
function hasRight($right)
{
$profile = Profile::staticGet($this->id);
diff --git a/classes/Safe_DataObject.php b/classes/Safe_DataObject.php
index f0ea6b136..891e33a66 100644
--- a/classes/Safe_DataObject.php
+++ b/classes/Safe_DataObject.php
@@ -287,4 +287,3 @@ class Safe_DataObject extends DB_DataObject
return Safe_DataObject::$iniCache[$key];
}
}
-
diff --git a/classes/Sms_carrier.php b/classes/Sms_carrier.php
index ffa12de29..500cb4f04 100644
--- a/classes/Sms_carrier.php
+++ b/classes/Sms_carrier.php
@@ -4,7 +4,7 @@
*/
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
-class Sms_carrier extends Memcached_DataObject
+class Sms_carrier extends Memcached_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */
@@ -22,7 +22,7 @@ class Sms_carrier extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
-
+
function toEmailAddress($sms)
{
return sprintf($this->email_pattern, $sms);
diff --git a/classes/Status_network.php b/classes/Status_network.php
index c4f37ce1c..5d01e72cc 100644
--- a/classes/Status_network.php
+++ b/classes/Status_network.php
@@ -167,18 +167,17 @@ class Status_network extends Safe_DataObject
' WHERE nickname = ' . $this->_quote($this->nickname);
$orig->decache();
$result = $this->query($qry);
- if ($result) {
- $this->encache();
- }
+ $this->decache();
+
return $result;
}
-
+
function delete()
{
$this->decache(); # while we still have the values!
return parent::delete();
}
-
+
/**
* @param string $servername hostname
* @param string $wildcard hostname suffix to match wildcard config
@@ -314,7 +313,7 @@ class Status_network extends Safe_DataObject
if (empty($result)) {
return explode('|', $this->tags);
}
-
+
return $result;
}
@@ -332,7 +331,7 @@ class Status_network extends Safe_DataObject
$snt->site_id = $this->site_id;
$snt->tag = $tag;
$snt->created = common_sql_now();
-
+
$id = $snt->insert();
if (!$id) {
// TRANS: Exception thrown when a tag cannot be saved.
@@ -357,7 +356,7 @@ class Status_network extends Safe_DataObject
$tag->free();
}
-
+
/**
* Check if this site record has a particular meta-info tag attached.
* @param string $tag
diff --git a/classes/Status_network_tag.php b/classes/Status_network_tag.php
index 7dab23289..a5893c114 100644
--- a/classes/Status_network_tag.php
+++ b/classes/Status_network_tag.php
@@ -26,7 +26,7 @@ class Status_network_tag extends Safe_DataObject
public $__table = 'status_network_tag'; // table name
public $site_id; // int(4) primary_key not_null
- public $tag; // varchar(64) primary_key not_null
+ public $tag; // varchar(64) primary_key not_null
public $created; // datetime() not_null
@@ -34,7 +34,7 @@ class Status_network_tag extends Safe_DataObject
{
global $config;
global $_DB_DATAOBJECT;
-
+
$sn = new Status_network();
$sn->_connect();
diff --git a/classes/Subscription.php b/classes/Subscription.php
index 0225ed4df..b4dbd84c9 100644
--- a/classes/Subscription.php
+++ b/classes/Subscription.php
@@ -235,4 +235,33 @@ class Subscription extends Memcached_DataObject
'subscribed' => $other->id));
return (empty($sub)) ? false : true;
}
+
+ function asActivity()
+ {
+ $subscriber = Profile::staticGet('id', $this->subscriber);
+ $subscribed = Profile::staticGet('id', $this->subscribed);
+
+ $act = new Activity();
+
+ $act->verb = ActivityVerb::FOLLOW;
+
+ $act->id = TagURI::mint('follow:%d:%d:%s',
+ $subscriber->id,
+ $subscribed->id,
+ common_date_iso8601($this->created));
+
+ $act->time = strtotime($this->created);
+ // TRANS: Activity tile when subscribing to another person.
+ $act->title = _("Follow");
+ // TRANS: Notification given when one person starts following another.
+ // TRANS: %1$s is the subscriber, %2$s is the subscribed.
+ $act->content = sprintf(_("%1$s is now following %2$s."),
+ $subscriber->getBestName(),
+ $subscribed->getBestName());
+
+ $act->actor = ActivityObject::fromProfile($subscriber);
+ $act->objects[] = ActivityObject::fromProfile($subscribed);
+
+ return $act;
+ }
}
diff --git a/classes/User.php b/classes/User.php
index c15ddc9dc..259df7e2c 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -250,6 +250,19 @@ class User extends Memcached_DataObject
$user->inboxed = 1;
+ // Set default-on options here, otherwise they'll be disabled
+ // initially for sites using caching, since the initial encache
+ // doesn't know about the defaults in the database.
+ $user->emailnotifysub = 1;
+ $user->emailnotifyfav = 1;
+ $user->emailnotifynudge = 1;
+ $user->emailnotifymsg = 1;
+ $user->emailnotifyattn = 1;
+ $user->emailmicroid = 1;
+ $user->emailpost = 1;
+ $user->jabbermicroid = 1;
+ $user->viewdesigns = 1;
+
$user->created = common_sql_now();
if (Event::handle('StartUserRegister', array(&$user, &$profile))) {
@@ -264,7 +277,13 @@ class User extends Memcached_DataObject
}
$user->id = $id;
- $user->uri = common_user_uri($user);
+
+ if (!empty($uri)) {
+ $user->uri = $uri;
+ } else {
+ $user->uri = common_user_uri($user);
+ }
+
if (!empty($password)) { // may not have a password for OpenID users
$user->password = common_munge_password($password, $id);
}
@@ -388,37 +407,8 @@ class User extends Memcached_DataObject
function hasFave($notice)
{
- $cache = Cache::instance();
-
- // XXX: Kind of a hack.
-
- if ($cache) {
- // This is the stream of favorite notices, in rev chron
- // order. This forces it into cache.
-
- $ids = Fave::stream($this->id, 0, NOTICE_CACHE_WINDOW);
-
- // If it's in the list, then it's a fave
-
- if (in_array($notice->id, $ids)) {
- return true;
- }
-
- // If we're not past the end of the cache window,
- // then the cache has all available faves, so this one
- // is not a fave.
-
- if (count($ids) < NOTICE_CACHE_WINDOW) {
- return false;
- }
-
- // Otherwise, cache doesn't have all faves;
- // fall through to the default
- }
-
- $fave = Fave::pkeyGet(array('user_id' => $this->id,
- 'notice_id' => $notice->id));
- return ((is_null($fave)) ? false : true);
+ $profile = $this->getProfile();
+ return $profile->hasFave($notice);
}
function mutuallySubscribed($other)
@@ -487,17 +477,8 @@ class User extends Memcached_DataObject
function blowFavesCache()
{
- $cache = Cache::instance();
- if ($cache) {
- // Faves don't happen chronologically, so we need to blow
- // ;last cache, too
- $cache->delete(Cache::key('fave:ids_by_user:'.$this->id));
- $cache->delete(Cache::key('fave:ids_by_user:'.$this->id.';last'));
- $cache->delete(Cache::key('fave:ids_by_user_own:'.$this->id));
- $cache->delete(Cache::key('fave:ids_by_user_own:'.$this->id.';last'));
- }
$profile = $this->getProfile();
- $profile->blowFaveCount();
+ $profile->blowFavesCache();
}
function getSelfTags()
@@ -547,6 +528,9 @@ class User extends Memcached_DataObject
if (Subscription::exists($other, $self)) {
Subscription::cancel($other, $self);
}
+ if (Subscription::exists($self, $other)) {
+ Subscription::cancel($self, $other);
+ }
$block->query('COMMIT');
diff --git a/classes/User_group.php b/classes/User_group.php
index 0b83cfd47..cfdcef290 100644
--- a/classes/User_group.php
+++ b/classes/User_group.php
@@ -465,7 +465,6 @@ class User_group extends Memcached_DataObject
}
static function register($fields) {
-
// MAGICALLY put fields into current scope
extract($fields);
diff --git a/classes/User_username.php b/classes/User_username.php
index 8d99cddd3..ae7785cc9 100644
--- a/classes/User_username.php
+++ b/classes/User_username.php
@@ -18,7 +18,9 @@ class User_username extends Memcached_DataObject
/* Static get */
function staticGet($k,$v=null)
- { return Memcached_DataObject::staticGet('User_username',$k,$v); }
+ {
+ return Memcached_DataObject::staticGet('User_username',$k,$v);
+ }
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
@@ -37,6 +39,7 @@ class User_username extends Memcached_DataObject
$user_username->provider_name = $provider_name;
$user_username->username = $username;
$user_username->created = DB_DataObject_Cast::dateTime();
+
if($user_username->insert()){
return $user_username;
}else{
@@ -57,5 +60,4 @@ class User_username extends Memcached_DataObject
function keys() {
return array('provider_name' => 'K', 'username' => 'K');
}
-
}