threadednoticelist takes a profile param

This commit is contained in:
Evan Prodromou 2011-04-10 20:16:51 -04:00
parent dfdde5d2bc
commit 70faf76001
6 changed files with 64 additions and 19 deletions

View File

@ -157,7 +157,16 @@ class AllAction extends ProfileAction
function showContent() function showContent()
{ {
if (Event::handle('StartShowAllContent', array($this))) { 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(); $cnt = $nl->show();

View File

@ -50,6 +50,7 @@ class ConversationAction extends Action
var $id = null; var $id = null;
var $page = null; var $page = null;
var $notices = null; var $notices = null;
var $userProfile = null;
const MAX_NOTICES = 500; const MAX_NOTICES = 500;
@ -76,14 +77,14 @@ class ConversationAction extends Action
$cur = common_current_user(); $cur = common_current_user();
if (empty($cur)) { if (empty($cur)) {
$profile = null; $this->userProfile = null;
} else { } 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; return true;
} }
@ -122,7 +123,7 @@ class ConversationAction extends Action
*/ */
function showContent() function showContent()
{ {
$tnl = new ThreadedNoticeList($this->notices, $this); $tnl = new ThreadedNoticeList($this->notices, $this, $this->userProfile);
$cnt = $tnl->show(); $cnt = $tnl->show();
} }

View File

@ -66,7 +66,7 @@ class ConversationRepliesAction extends ConversationAction
*/ */
function showContent() function showContent()
{ {
$ct = new FullThreadedNoticeList($this->notices, $this); $ct = new FullThreadedNoticeList($this->notices, $this, $this->userProfile);
$cnt = $ct->show(); $cnt = $ct->show();
} }
@ -91,7 +91,7 @@ class FullThreadedNoticeList extends ThreadedNoticeList
{ {
function newListItem($notice) function newListItem($notice)
{ {
return new FullThreadedNoticeListItem($notice, $this->out); return new FullThreadedNoticeListItem($notice, $this->out, $this->userProfile);
} }
} }

View File

@ -85,7 +85,17 @@ class PublicAction extends Action
common_set_returnto($this->selfUrl()); common_set_returnto($this->selfUrl());
$this->notice = Notice::publicStream(($this->page-1)*NOTICES_PER_PAGE, $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); NOTICES_PER_PAGE + 1);
if (!$this->notice) { if (!$this->notice) {

View File

@ -50,6 +50,8 @@ class ShowgroupAction extends GroupDesignAction
{ {
/** page we're viewing. */ /** page we're viewing. */
var $page = null; var $page = null;
var $userProfile = null;
var $notice = null;
/** /**
* Is this page read-only? * Is this page read-only?
@ -144,6 +146,15 @@ class ShowgroupAction extends GroupDesignAction
return false; 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()); common_set_returnto($this->selfUrl());
return true; return true;
@ -190,10 +201,7 @@ class ShowgroupAction extends GroupDesignAction
*/ */
function showGroupNotices() function showGroupNotices()
{ {
$notice = $this->group->getNotices(($this->page-1)*NOTICES_PER_PAGE, $nl = new ThreadedNoticeList($notice, $this, $this->userProfile);
NOTICES_PER_PAGE + 1);
$nl = new ThreadedNoticeList($notice, $this);
$cnt = $nl->show(); $cnt = $nl->show();
$this->pagination($this->page > 1, $this->pagination($this->page > 1,

View File

@ -50,6 +50,14 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
*/ */
class ThreadedNoticeList extends NoticeList 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 * show the list of notices
* *
@ -123,7 +131,7 @@ class ThreadedNoticeList extends NoticeList
*/ */
function newListItem($notice) 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 class ThreadedNoticeListItem extends NoticeListItem
{ {
protected $userProfile = null;
function __construct($notice, $out=null, $profile=null)
{
parent::__construct($notice, $out);
$this->userProfile = $profile;
}
function initialItems() function initialItems()
{ {
return 3; return 3;
@ -167,7 +183,8 @@ class ThreadedNoticeListItem extends NoticeListItem
{ {
$max = $this->initialItems(); $max = $this->initialItems();
if (!$this->repeat) { 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(); $notices = array();
$cnt = 0; $cnt = 0;
$moreCutoff = null; $moreCutoff = null;