// XXX: make this a little more convenient
if (!common_config('performance', 'high')) {
- $pop = new PopularNoticeSection($this, Profile::current());
+ $pop = new PopularNoticeSection($this, $this->scoped);
$pop->show();
$pop = new InboxTagCloudSection($this, $this->target);
$pop->show();
class ThreadingInboxNoticeStream extends ThreadingNoticeStream
{
- function __construct($user, $profile)
+ function __construct(Profile $target, Profile $scoped=null)
{
- parent::__construct(new InboxNoticeStream($user, $profile));
+ parent::__construct(new InboxNoticeStream($target, $scoped));
}
}
*/
function getNotices($limit=0)
{
- $stream = new InboxNoticeStream($this->user);
+ $stream = new InboxNoticeStream($this->user->getProfile());
$notice = $stream->getNotices(0, $limit, null, null);
$notices = array();
{
$notices = array();
- $stream = new InboxNoticeStream($this->target->getUser(), $this->scoped);
+ $stream = new InboxNoticeStream($this->target, $this->scoped);
$notice = $stream->getNotices(($this->page-1) * $this->count,
$this->count,
{
$notice = new Notice();
$notice->selectAdd();
- $notice->selectAdd('notice_id');
- // Reply is a class for mentions
- $notice->joinAdd(array('id', 'reply:notice_id'));
-
- $notice->profile_id = $this->target->id;
+ $notice->selectAdd('id');
+ $notice->whereAdd(sprintf('notice.created > "%s"', $notice->escape($this->target->created)));
+ // Reply:: is a table of mentions
+ // Subscription:: is a table of subscriptions (every user is subscribed to themselves)
+ $notice->whereAdd(
+ sprintf('notice.id IN (SELECT notice_id FROM reply WHERE profile_id=%1$d) ' .
+ 'OR notice.profile_id IN (SELECT subscribed FROM subscription WHERE subscriber=%d)', $this->target->id)
+ );
$notice->limit($offset, $limit);
- $notice->orderBy('created DESC');
+ $notice->orderBy('notice.created DESC');
if (!$notice->find()) {
return array();
}
- $ids = $notice->fetchAll('notice_id');
+ $ids = $notice->fetchAll('id');
return $ids;
}
*/
class InboxTagCloudSection extends TagCloudSection
{
- var $user = null;
+ protected $target = null;
- function __construct($out=null, $user=null)
+ function __construct($out=null, Profile $target)
{
parent::__construct($out);
- $this->user = $user;
+ $this->target = $target;
}
function title()
{
$profile = Profile::current();
- $keypart = sprintf('Inbox:notice_tag:%d:%d', $this->user->id,
+ $keypart = sprintf('Inbox:notice_tag:%d:%d', $this->target,
$profile instanceof Profile ? $profile->id : 0);
$tag = Memcached_DataObject::cacheGet($keypart);
if ($tag === false) {
- $stream = new InboxNoticeStream($this->user, $profile);
+ $stream = new InboxNoticeStream($this->target, $profile);
$ids = $stream->getNoticeIds(0, Inbox::MAX_NOTICES, null, null);
return true;
}
- $stream = new InboxNoticeStream($user, $user->getProfile());
+ // An InboxNoticeStream for a certain user, scoped to its own view
+ $stream = new InboxNoticeStream($profile, $profile);
$notice = $stream->getNotices(0, self::MAX_NOTICES, $since_id);
function prepare($args)
{
if (parent::prepare($args)) {
- $cur = common_current_user();
- $stream = new InboxNoticeStream($this->user, $cur->getProfile());
+ $stream = new InboxNoticeStream($this->user->getProfile(), $this->scoped);
$this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
NOTICES_PER_PAGE + 1,
null,
$content = testNoticeContent();
if ($is_reply == 0) {
- $stream = new InboxNoticeStream($user, $user->getProfile());
+ $stream = new InboxNoticeStream($user->getProfile(), $user->getProfile());
$notices = $stream->getNotices(0, 20);
if ($notices->N > 0) {
$nval = rand(0, $notices->N - 1);