From 5409bd6a5d5768f912aacce764fe301caf46c5c6 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 13 Nov 2008 16:57:34 -0500 Subject: different query based on config var and user inbox status darcs-hash:20081113215734-84dde-badae0579fb70a6760dc6fdf0289b76356e479f6.gz --- classes/User.php | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'classes/User.php') 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() { -- cgit v1.2.3-54-g00ecf