X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FUser.php;h=c3ceb2646b166ca57a912c1d44aec2c31073a35a;hb=38bea345620738f0095b9d7f8fc6e2fe1774116a;hp=24a03b62fd0d0d82941e72a481cc3fa2f8906119;hpb=2dfa0bfcee92f5e9ddf6534ee07a7186065a275f;p=quix0rs-gnu-social.git diff --git a/classes/User.php b/classes/User.php index 24a03b62fd..c3ceb2646b 100644 --- a/classes/User.php +++ b/classes/User.php @@ -55,7 +55,6 @@ class User extends Managed_DataObject public $autosubscribe; // tinyint(1) public $subscribe_policy; // tinyint(1) public $urlshorteningservice; // varchar(50) default_ur1.ca - public $inboxed; // tinyint(1) public $private_stream; // tinyint(1) default_0 public $created; // datetime() not_null public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP @@ -91,7 +90,6 @@ class User extends Managed_DataObject 'autosubscribe' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'automatically subscribe to users who subscribe to us'), 'subscribe_policy' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => '0 = anybody can subscribe; 1 = require approval'), 'urlshorteningservice' => array('type' => 'varchar', 'length' => 50, 'default' => 'internal', 'description' => 'service to use for auto-shortening URLs'), - 'inboxed' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'has an inbox been created for this user?'), 'private_stream' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'whether to limit all notices to followers only'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'), @@ -115,7 +113,7 @@ class User extends Managed_DataObject ); } - protected $_profile = null; + protected $_profile = array(); /** * @return Profile @@ -124,22 +122,32 @@ class User extends Managed_DataObject */ public function getProfile() { - if (!($this->_profile instanceof Profile)) { - $this->_profile = Profile::getKV('id', $this->id); - if (!($this->_profile instanceof Profile)) { + if (!isset($this->_profile[$this->id])) { + $profile = Profile::getKV('id', $this->id); + if (!$profile instanceof Profile) { throw new UserNoProfileException($this); } + $this->_profile[$this->id] = $profile; } + return $this->_profile[$this->id]; + } + + public function getUri() + { + return $this->uri; + } - return $this->_profile; + public function getNickname() + { + return $this->getProfile()->getNickname(); } - function isSubscribed($other) + function isSubscribed(Profile $other) { return $this->getProfile()->isSubscribed($other); } - function hasPendingSubscription($other) + function hasPendingSubscription(Profile $other) { return $this->getProfile()->hasPendingSubscription($other); } @@ -277,10 +285,6 @@ class User extends Managed_DataObject $user->email = $email; } - // This flag is ignored but still set to 1 - - $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. @@ -325,20 +329,6 @@ class User extends Managed_DataObject return false; } - // Everyone gets an inbox - - $inbox = new Inbox(); - - $inbox->user_id = $user->id; - $inbox->notice_ids = ''; - - $result = $inbox->insert(); - - if (!$result) { - common_log_db_error($inbox, 'INSERT', __FILE__); - return false; - } - // Everyone is subscribed to themself $subscription = new Subscription(); @@ -450,12 +440,7 @@ class User extends Managed_DataObject } } - function hasFave($notice) - { - return $this->getProfile()->hasFave($notice); - } - - function mutuallySubscribed($other) + function mutuallySubscribed(Profile $other) { return $this->getProfile()->mutuallySubscribed($other); } @@ -489,57 +474,6 @@ class User extends Managed_DataObject return $this->getProfile()->getNotices($offset, $limit, $since_id, $before_id); } - function favoriteNotices($own=false, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0) - { - return $this->getProfile()->favoriteNotices($own, $offset, $limit, $since_id, $max_id); - } - - function noticeInbox($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) - { - $stream = new InboxNoticeStream($this); - return $stream->getNotices($offset, $limit, $since_id, $before_id); - } - - // DEPRECATED, use noticeInbox() - - function noticesWithFriends($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) - { - return $this->noticeInbox($offset, $limit, $since_id, $before_id); - } - - // DEPRECATED, use noticeInbox() - - function noticesWithFriendsThreaded($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) - { - return $this->noticeInbox($offset, $limit, $since_id, $before_id); - } - - // DEPRECATED, use noticeInbox() - - function noticeInboxThreaded($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) - { - return $this->noticeInbox($offset, $limit, $since_id, $before_id); - } - - // DEPRECATED, use noticeInbox() - - function friendsTimeline($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) - { - return $this->noticeInbox($offset, $limit, $since_id, $before_id); - } - - // DEPRECATED, use noticeInbox() - - function ownFriendsTimeline($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) - { - $this->noticeInbox($offset, $limit, $since_id, $before_id); - } - - function blowFavesCache() - { - $this->getProfile()->blowFavesCache(); - } - function getSelfTags() { return Profile_tag::getTagsArray($this->id, $this->id, $this->id); @@ -616,12 +550,12 @@ class User extends Managed_DataObject return true; } - function isMember($group) + function isMember(User_group $group) { return $this->getProfile()->isMember($group); } - function isAdmin($group) + function isAdmin(User_group $group) { return $this->getProfile()->isAdmin($group); } @@ -692,7 +626,7 @@ class User extends Managed_DataObject common_log(LOG_INFO, "User {$this->nickname} has no profile; continuing deletion."); } - $related = array('Fave', + $related = array( 'Confirm_address', 'Remember_me', 'Foreign_link', @@ -1032,18 +966,6 @@ class User extends Managed_DataObject return false; } - function conversationTree() - { - if (common_config('oldschool', 'enabled')) { - $osp = Old_school_prefs::getKV('user_id', $this->id); - if (!empty($osp)) { - return $osp->conversation_tree; - } - } - - return false; - } - function streamNicknames() { if (common_config('oldschool', 'enabled')) {