different query based on config var and user inbox status

darcs-hash:20081113215734-84dde-badae0579fb70a6760dc6fdf0289b76356e479f6.gz
This commit is contained in:
Evan Prodromou 2008-11-13 16:57:34 -05:00
parent 169b3e00e1
commit 5409bd6a5d

View File

@ -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() {