From 70faf760012d16d565644766c27db3d0208fa268 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 10 Apr 2011 20:16:51 -0400 Subject: [PATCH] threadednoticelist takes a profile param --- actions/all.php | 11 ++++++++++- actions/conversation.php | 17 +++++++++-------- actions/conversationreplies.php | 4 ++-- actions/public.php | 14 ++++++++++++-- actions/showgroup.php | 16 ++++++++++++---- lib/threadednoticelist.php | 21 +++++++++++++++++++-- 6 files changed, 64 insertions(+), 19 deletions(-) diff --git a/actions/all.php b/actions/all.php index 74a0059346..5fd2475e49 100644 --- a/actions/all.php +++ b/actions/all.php @@ -157,7 +157,16 @@ class AllAction extends ProfileAction function showContent() { if (Event::handle('StartShowAllContent', array($this))) { - $nl = new ThreadedNoticeList($this->notice, $this); + + $profile = null; + + $current_user = common_current_user(); + + if (!empty($current_user)) { + $profile = $current_user->getProfile(); + } + + $nl = new ThreadedNoticeList($this->notice, $this, $profile); $cnt = $nl->show(); diff --git a/actions/conversation.php b/actions/conversation.php index cfe4e47fe6..123965afa2 100644 --- a/actions/conversation.php +++ b/actions/conversation.php @@ -47,9 +47,10 @@ require_once INSTALLDIR.'/lib/noticelist.php'; */ class ConversationAction extends Action { - var $id = null; - var $page = null; - var $notices = null; + var $id = null; + var $page = null; + var $notices = null; + var $userProfile = null; const MAX_NOTICES = 500; @@ -76,14 +77,14 @@ class ConversationAction extends Action $cur = common_current_user(); if (empty($cur)) { - $profile = null; + $this->userProfile = null; } else { - $profile = $cur->getProfile(); + $this->userProfile = $cur->getProfile(); } - $stream = new ConversationNoticeStream($this->id, $profile); + $stream = new ConversationNoticeStream($this->id, $this->userProfile); - $this->notices = $stream->getNotices(0, self::MAX_NOTICES, null, null); + $this->notices = $stream->getNotices(0, self::MAX_NOTICES); return true; } @@ -122,7 +123,7 @@ class ConversationAction extends Action */ function showContent() { - $tnl = new ThreadedNoticeList($this->notices, $this); + $tnl = new ThreadedNoticeList($this->notices, $this, $this->userProfile); $cnt = $tnl->show(); } diff --git a/actions/conversationreplies.php b/actions/conversationreplies.php index 51bc97f1fc..450a3d6828 100644 --- a/actions/conversationreplies.php +++ b/actions/conversationreplies.php @@ -66,7 +66,7 @@ class ConversationRepliesAction extends ConversationAction */ function showContent() { - $ct = new FullThreadedNoticeList($this->notices, $this); + $ct = new FullThreadedNoticeList($this->notices, $this, $this->userProfile); $cnt = $ct->show(); } @@ -91,7 +91,7 @@ class FullThreadedNoticeList extends ThreadedNoticeList { function newListItem($notice) { - return new FullThreadedNoticeListItem($notice, $this->out); + return new FullThreadedNoticeListItem($notice, $this->out, $this->userProfile); } } diff --git a/actions/public.php b/actions/public.php index d2b0373dc6..84306e1fcc 100644 --- a/actions/public.php +++ b/actions/public.php @@ -85,8 +85,18 @@ class PublicAction extends Action common_set_returnto($this->selfUrl()); - $this->notice = Notice::publicStream(($this->page-1)*NOTICES_PER_PAGE, - NOTICES_PER_PAGE + 1); + $profile = null; + + $user = common_current_user(); + + if (!empty($user)) { + $profile = $user->getProfile(); + } + + $stream = new PublicNoticeStream($profile); + + $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE, + NOTICES_PER_PAGE + 1); if (!$this->notice) { // TRANS: Server error displayed when a public timeline cannot be retrieved. diff --git a/actions/showgroup.php b/actions/showgroup.php index 512ca6a0ee..49c8e04dcd 100644 --- a/actions/showgroup.php +++ b/actions/showgroup.php @@ -50,6 +50,8 @@ class ShowgroupAction extends GroupDesignAction { /** page we're viewing. */ var $page = null; + var $userProfile = null; + var $notice = null; /** * Is this page read-only? @@ -144,6 +146,15 @@ class ShowgroupAction extends GroupDesignAction return false; } + $cur = common_current_user(); + + $this->userProfile = (empty($cur)) ? null : $cur->getProfile(); + + $stream = new GroupNoticeStream($this->group, $this->userProfile); + + $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE, + NOTICES_PER_PAGE + 1); + common_set_returnto($this->selfUrl()); return true; @@ -190,10 +201,7 @@ class ShowgroupAction extends GroupDesignAction */ function showGroupNotices() { - $notice = $this->group->getNotices(($this->page-1)*NOTICES_PER_PAGE, - NOTICES_PER_PAGE + 1); - - $nl = new ThreadedNoticeList($notice, $this); + $nl = new ThreadedNoticeList($notice, $this, $this->userProfile); $cnt = $nl->show(); $this->pagination($this->page > 1, diff --git a/lib/threadednoticelist.php b/lib/threadednoticelist.php index c5cd2d3081..372791c3e5 100644 --- a/lib/threadednoticelist.php +++ b/lib/threadednoticelist.php @@ -50,6 +50,14 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { */ class ThreadedNoticeList extends NoticeList { + protected $userProfile; + + function __construct($notice, $out=null, $profile=null) + { + parent::__construct($notice, $out); + $this->userProfile = $profile; + } + /** * show the list of notices * @@ -123,7 +131,7 @@ class ThreadedNoticeList extends NoticeList */ function newListItem($notice) { - return new ThreadedNoticeListItem($notice, $this->out); + return new ThreadedNoticeListItem($notice, $this->out, $this->userProfile); } } @@ -146,6 +154,14 @@ class ThreadedNoticeList extends NoticeList */ class ThreadedNoticeListItem extends NoticeListItem { + protected $userProfile = null; + + function __construct($notice, $out=null, $profile=null) + { + parent::__construct($notice, $out); + $this->userProfile = $profile; + } + function initialItems() { return 3; @@ -167,7 +183,8 @@ class ThreadedNoticeListItem extends NoticeListItem { $max = $this->initialItems(); if (!$this->repeat) { - $notice = Notice::conversationStream($this->notice->conversation, 0, $max + 2); + $stream = new ConversationNoticeStream($this->notice->conversation, $this->userProfile); + $notice = $stream->getNotices(0, $max + 2); $notices = array(); $cnt = 0; $moreCutoff = null;