diff options
author | Evan Prodromou <evan@prodromou.name> | 2008-11-13 16:57:34 -0500 |
---|---|---|
committer | Evan Prodromou <evan@prodromou.name> | 2008-11-13 16:57:34 -0500 |
commit | 5409bd6a5d5768f912aacce764fe301caf46c5c6 (patch) | |
tree | 0a9f4452a76e71ce130b0fe9bd39bbfa8628a945 | |
parent | 169b3e00e1e7dfdcb800afd6169024c3da2be99e (diff) |
different query based on config var and user inbox status
darcs-hash:20081113215734-84dde-badae0579fb70a6760dc6fdf0289b76356e479f6.gz
-rw-r--r-- | classes/User.php | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/classes/User.php b/classes/User.php index e4a8663c3..fa1ecdfa0 100644 --- a/classes/User.php +++ b/classes/User.php @@ -327,17 +327,32 @@ class User extends Memcached_DataObject } function noticesWithFriends($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) { - $qry = - 'SELECT notice.* ' . - 'FROM notice JOIN notice_inbox ON notice.id = notice_inbox.notice_id ' . - 'WHERE notice_inbox.user_id = %d '; + $enabled = common_config('inboxes', 'enabled'); - # NOTE: we override ORDER + # 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 '; + $order = NULL; + } else if ($enabled === true || + ($enabled == 'transitional' && $this->inboxed == 1)) { + $qry = + 'SELECT notice.* ' . + 'FROM notice JOIN notice_inbox ON notice.id = notice_inbox.notice_id ' . + 'WHERE notice_inbox.user_id = %d '; + # NOTE: we override ORDER + $order = 'ORDER BY notice_inbox.created DESC, notice_inbox.notice_id DESC '; + } return Notice::getStream(sprintf($qry, $this->id), 'user:notices_with_friends:' . $this->id, $offset, $limit, $since_id, $before_id, - 'ORDER BY notice_inbox.created DESC, notice_inbox.notice_id DESC '); + $order); } function blowFavesCache() { |