From c899e4a84ee45b65950980ccb87e52129871d58e Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Dec 2009 17:02:48 -0500 Subject: show forwards in the inbox --- actions/all.php | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) (limited to 'actions/all.php') diff --git a/actions/all.php b/actions/all.php index 5a9d97dd7..2c96298fa 100644 --- a/actions/all.php +++ b/actions/all.php @@ -144,7 +144,7 @@ class AllAction extends ProfileAction function showContent() { - $nl = new NoticeList($this->notice, $this); + $nl = new InboxNoticeList($this->notice, $this->user, $this); $cnt = $nl->show(); @@ -167,5 +167,88 @@ class AllAction extends ProfileAction $this->element('h1', null, sprintf(_('%s and friends'), $this->user->nickname)); } } +} + +class InboxNoticeList extends NoticeList +{ + var $owner = null; + + function __construct($notice, $owner, $out=null) + { + parent::__construct($notice, $out); + $this->owner = $owner; + } + + function newListItem($notice) + { + return new InboxNoticeListItem($notice, $this->owner, $this->out); + } +} +class InboxNoticeListItem extends NoticeListItem +{ + var $owner = null; + var $ib = null; + + function __construct($notice, $owner, $out=null) + { + parent::__construct($notice, $out); + $this->owner = $owner; + + $this->ib = Notice_inbox::pkeyGet(array('user_id' => $owner->id, + 'notice_id' => $notice->id)); + } + + function showAuthor() + { + parent::showAuthor(); + if ($this->ib->source == NOTICE_INBOX_SOURCE_FORWARD) { + $this->out->element('span', 'forward', _('Fwd')); + } + } + + function showEnd() + { + if ($this->ib->source == NOTICE_INBOX_SOURCE_FORWARD) { + + $forward = new Forward(); + + // FIXME: scary join! + + $forward->query('SELECT profile_id '. + 'FROM forward JOIN subscription ON forward.profile_id = subscription.subscribed '. + 'WHERE subscription.subscriber = ' . $this->owner->id . ' '. + 'AND forward.notice_id = ' . $this->notice->id . ' '. + 'ORDER BY forward.created '); + + $n = 0; + + $firstForwarder = null; + + while ($forward->fetch()) { + if (empty($firstForwarder)) { + $firstForwarder = Profile::staticGet('id', $forward->profile_id); + } + $n++; + } + + $forward->free(); + unset($forward); + + $this->out->elementStart('span', 'forwards'); + + $link = XMLStringer::estring('a', array('href' => $firstForwarder->profileurl), + $firstForwarder->nickname); + + if ($n == 1) { + $this->out->raw(sprintf(_('Forwarded by %s'), $link)); + } else { + // XXX: use that cool ngettext thing + $this->out->raw(sprintf(_('Forwarded by %s and %d other(s)'), $link, $n - 1)); + } + + $this->out->elementEnd('span'); + } + parent::showEnd(); + } } -- cgit v1.2.3-54-g00ecf From 198e413a58f8aa3d07ce5da365f6c47ce98ab2c0 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 10 Dec 2009 13:34:11 -0500 Subject: move inbox notice list to repeat plugin --- actions/all.php | 86 +------------------------------------- plugins/Repeat/inboxnoticelist.php | 85 +++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 85 deletions(-) create mode 100644 plugins/Repeat/inboxnoticelist.php (limited to 'actions/all.php') diff --git a/actions/all.php b/actions/all.php index 2c96298fa..08fbacaef 100644 --- a/actions/all.php +++ b/actions/all.php @@ -144,7 +144,7 @@ class AllAction extends ProfileAction function showContent() { - $nl = new InboxNoticeList($this->notice, $this->user, $this); + $nl = new NoticeList($this->notice, $this->user, $this); $cnt = $nl->show(); @@ -168,87 +168,3 @@ class AllAction extends ProfileAction } } } - -class InboxNoticeList extends NoticeList -{ - var $owner = null; - - function __construct($notice, $owner, $out=null) - { - parent::__construct($notice, $out); - $this->owner = $owner; - } - - function newListItem($notice) - { - return new InboxNoticeListItem($notice, $this->owner, $this->out); - } -} - -class InboxNoticeListItem extends NoticeListItem -{ - var $owner = null; - var $ib = null; - - function __construct($notice, $owner, $out=null) - { - parent::__construct($notice, $out); - $this->owner = $owner; - - $this->ib = Notice_inbox::pkeyGet(array('user_id' => $owner->id, - 'notice_id' => $notice->id)); - } - - function showAuthor() - { - parent::showAuthor(); - if ($this->ib->source == NOTICE_INBOX_SOURCE_FORWARD) { - $this->out->element('span', 'forward', _('Fwd')); - } - } - - function showEnd() - { - if ($this->ib->source == NOTICE_INBOX_SOURCE_FORWARD) { - - $forward = new Forward(); - - // FIXME: scary join! - - $forward->query('SELECT profile_id '. - 'FROM forward JOIN subscription ON forward.profile_id = subscription.subscribed '. - 'WHERE subscription.subscriber = ' . $this->owner->id . ' '. - 'AND forward.notice_id = ' . $this->notice->id . ' '. - 'ORDER BY forward.created '); - - $n = 0; - - $firstForwarder = null; - - while ($forward->fetch()) { - if (empty($firstForwarder)) { - $firstForwarder = Profile::staticGet('id', $forward->profile_id); - } - $n++; - } - - $forward->free(); - unset($forward); - - $this->out->elementStart('span', 'forwards'); - - $link = XMLStringer::estring('a', array('href' => $firstForwarder->profileurl), - $firstForwarder->nickname); - - if ($n == 1) { - $this->out->raw(sprintf(_('Forwarded by %s'), $link)); - } else { - // XXX: use that cool ngettext thing - $this->out->raw(sprintf(_('Forwarded by %s and %d other(s)'), $link, $n - 1)); - } - - $this->out->elementEnd('span'); - } - parent::showEnd(); - } -} diff --git a/plugins/Repeat/inboxnoticelist.php b/plugins/Repeat/inboxnoticelist.php new file mode 100644 index 000000000..809fbe8af --- /dev/null +++ b/plugins/Repeat/inboxnoticelist.php @@ -0,0 +1,85 @@ +owner = $owner; + } + + function newListItem($notice) + { + return new InboxNoticeListItem($notice, $this->owner, $this->out); + } +} + +class InboxNoticeListItem extends NoticeListItem +{ + var $owner = null; + var $ib = null; + + function __construct($notice, $owner, $out=null) + { + parent::__construct($notice, $out); + $this->owner = $owner; + + $this->ib = Notice_inbox::pkeyGet(array('user_id' => $owner->id, + 'notice_id' => $notice->id)); + } + + function showAuthor() + { + parent::showAuthor(); + if ($this->ib->source == NOTICE_INBOX_SOURCE_FORWARD) { + $this->out->element('span', 'forward', _('Fwd')); + } + } + + function showEnd() + { + if ($this->ib->source == NOTICE_INBOX_SOURCE_FORWARD) { + + $forward = new Forward(); + + // FIXME: scary join! + + $forward->query('SELECT profile_id '. + 'FROM forward JOIN subscription ON forward.profile_id = subscription.subscribed '. + 'WHERE subscription.subscriber = ' . $this->owner->id . ' '. + 'AND forward.notice_id = ' . $this->notice->id . ' '. + 'ORDER BY forward.created '); + + $n = 0; + + $firstForwarder = null; + + while ($forward->fetch()) { + if (empty($firstForwarder)) { + $firstForwarder = Profile::staticGet('id', $forward->profile_id); + } + $n++; + } + + $forward->free(); + unset($forward); + + $this->out->elementStart('span', 'forwards'); + + $link = XMLStringer::estring('a', array('href' => $firstForwarder->profileurl), + $firstForwarder->nickname); + + if ($n == 1) { + $this->out->raw(sprintf(_('Forwarded by %s'), $link)); + } else { + // XXX: use that cool ngettext thing + $this->out->raw(sprintf(_('Forwarded by %s and %d other(s)'), $link, $n - 1)); + } + + $this->out->elementEnd('span'); + } + parent::showEnd(); + } +} -- cgit v1.2.3-54-g00ecf From 79443d1ee2a50234e79c89f2bc41bb49935c66ca Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 10 Dec 2009 14:36:14 -0500 Subject: had wrong number of arguments to NoticeList in notice inbox --- actions/all.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actions/all.php') diff --git a/actions/all.php b/actions/all.php index 08fbacaef..452803d8a 100644 --- a/actions/all.php +++ b/actions/all.php @@ -144,7 +144,7 @@ class AllAction extends ProfileAction function showContent() { - $nl = new NoticeList($this->notice, $this->user, $this); + $nl = new NoticeList($this->notice, $this); $cnt = $nl->show(); -- cgit v1.2.3-54-g00ecf