X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FUser.php;h=7df93b7c5a395679b975a23d2afff5017762b756;hb=4737563b957e84ee06d07f373af533b2f037497a;hp=08a166d5ae4a4478be5943cd69eee776834e54ec;hpb=c2ba727d6154394fe234e9297b430ac69fd24c88;p=quix0rs-gnu-social.git diff --git a/classes/User.php b/classes/User.php index 08a166d5ae..7df93b7c5a 100644 --- a/classes/User.php +++ b/classes/User.php @@ -1,7 +1,7 @@ id, $offset, $limit); + $ids = Fave::stream($this->id, $offset, $limit, $own); return Notice::getStreamByIds($ids); } @@ -438,6 +437,33 @@ class User extends Memcached_DataObject // Complicated code, depending on whether we support inboxes yet // XXX: make this go away when inboxes become mandatory + if ($enabled === false || + ($enabled == 'transitional' && $this->inboxed == 0)) { + $qry = + 'SELECT notice.* ' . + 'FROM notice JOIN subscription ON notice.profile_id = subscription.subscribed ' . + 'WHERE subscription.subscriber = %d ' . + 'AND notice.is_local != ' . Notice::GATEWAY; + return Notice::getStream(sprintf($qry, $this->id), + 'user:notices_with_friends:' . $this->id, + $offset, $limit, $since_id, $before_id, + $order, $since); + } else if ($enabled === true || + ($enabled == 'transitional' && $this->inboxed == 1)) { + + $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, false); + + return Notice::getStreamByIds($ids); + } + } + + function noticeInbox($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null) + { + $enabled = common_config('inboxes', 'enabled'); + + // Complicated code, depending on whether we support inboxes yet + // XXX: make this go away when inboxes become mandatory + if ($enabled === false || ($enabled == 'transitional' && $this->inboxed == 0)) { $qry = @@ -451,7 +477,7 @@ class User extends Memcached_DataObject } else if ($enabled === true || ($enabled == 'transitional' && $this->inboxed == 1)) { - $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since); + $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, true); return Notice::getStreamByIds($ids); } @@ -465,7 +491,11 @@ class User extends Memcached_DataObject // ;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')); } + $profile = $this->getProfile(); + $profile->blowFaveCount(); } function getSelfTags() @@ -574,50 +604,16 @@ class User extends Memcached_DataObject function getSubscriptions($offset=0, $limit=null) { - $qry = - 'SELECT profile.* ' . - 'FROM profile JOIN subscription ' . - 'ON profile.id = subscription.subscribed ' . - 'WHERE subscription.subscriber = %d ' . - 'AND subscription.subscribed != subscription.subscriber ' . - 'ORDER BY subscription.created DESC '; - - if (common_config('db','type') == 'pgsql') { - $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; - } else { - $qry .= ' LIMIT ' . $offset . ', ' . $limit; - } - - $profile = new Profile(); - - $profile->query(sprintf($qry, $this->id)); - - return $profile; + $profile = $this->getProfile(); + assert(!empty($profile)); + return $profile->getSubscriptions($offset, $limit); } function getSubscribers($offset=0, $limit=null) { - $qry = - 'SELECT profile.* ' . - 'FROM profile JOIN subscription ' . - 'ON profile.id = subscription.subscriber ' . - 'WHERE subscription.subscribed = %d ' . - 'AND subscription.subscribed != subscription.subscriber ' . - 'ORDER BY subscription.created DESC '; - - if ($offset) { - if (common_config('db','type') == 'pgsql') { - $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; - } else { - $qry .= ' LIMIT ' . $offset . ', ' . $limit; - } - } - - $profile = new Profile(); - - $cnt = $profile->query(sprintf($qry, $this->id)); - - return $profile; + $profile = $this->getProfile(); + assert(!empty($profile)); + return $profile->getSubscribers($offset, $limit); } function getTaggedSubscribers($tag, $offset=0, $limit=null) @@ -684,4 +680,9 @@ class User extends Memcached_DataObject return ($cnt > 0); } + + function getDesign() + { + return Design::staticGet('id', $this->design_id); + } }