diff --git a/actions/newnotice.php b/actions/newnotice.php index 0c12c7d74a..060f1ecd7d 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -170,6 +170,9 @@ class NewnoticeAction extends FormAction Event::handle('EndNoticeSaveWeb', array($this, $notice)); } + + assert($notice instanceof Notice); + Event::handle('EndSaveNewNoticeWeb', array($this, $user, &$content_shortened, &$options)); if (StatusNet::isAjax()) { @@ -345,7 +348,7 @@ class NewnoticeAction extends FormAction * * @return void */ - function showNotice($notice) + function showNotice(Notice $notice) { $nli = new NoticeListItem($notice, $this); $nli->show(); diff --git a/actions/shownotice.php b/actions/shownotice.php index 28cb68c121..5e2be9f9d2 100644 --- a/actions/shownotice.php +++ b/actions/shownotice.php @@ -114,20 +114,19 @@ class ShownoticeAction extends Action $id = $this->arg('notice'); $notice = Notice::getKV('id', $id); - - if (!$notice instanceof Notice) { - // Did we used to have it, and it got deleted? - $deleted = Deleted_notice::getKV($id); - if ($deleted instanceof Deleted_notice) { - // TRANS: Client error displayed trying to show a deleted notice. - $this->clientError(_('Notice deleted.'), 410); - } else { - // TRANS: Client error displayed trying to show a non-existing notice. - $this->clientError(_('No such notice.'), 404); - } - return false; + if ($notice instanceof Notice) { + // Alright, got it! + return $notice; } - return $notice; + + // Did we use to have it, and it got deleted? + $deleted = Deleted_notice::getKV('id', $id); + if ($deleted instanceof Deleted_notice) { + // TRANS: Client error displayed trying to show a deleted notice. + $this->clientError(_('Notice deleted.'), 410); + } + // TRANS: Client error displayed trying to show a non-existing notice. + $this->clientError(_('No such notice.'), 404); } /** diff --git a/lib/noticelist.php b/lib/noticelist.php index b00e476d92..c21d73cff5 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -58,7 +58,7 @@ class NoticeList extends Widget * * @param Notice $notice stream of notices from DB_DataObject */ - function __construct($notice, $out=null) + function __construct(Notice $notice, $out=null) { parent::__construct($out); $this->notice = $notice; @@ -111,7 +111,7 @@ class NoticeList extends Widget * * @return NoticeListItem a list item for displaying the notice */ - function newListItem($notice) + function newListItem(Notice $notice) { return new NoticeListItem($notice, $this->out); } diff --git a/lib/noticelistitem.php b/lib/noticelistitem.php index b8ebe3bede..f46827d1f7 100644 --- a/lib/noticelistitem.php +++ b/lib/noticelistitem.php @@ -65,7 +65,7 @@ class NoticeListItem extends Widget * * @param Notice $notice The notice we'll display */ - function __construct($notice, $out=null) + function __construct(Notice $notice, HTMLOutputter $out=null) { parent::__construct($out); if (!empty($notice->repeat_of)) { diff --git a/lib/noticesection.php b/lib/noticesection.php index 4a4eac344a..c1fcbbf8cd 100644 --- a/lib/noticesection.php +++ b/lib/noticesection.php @@ -70,7 +70,7 @@ class NoticeSection extends Section return null; } - function showNotice($notice) + function showNotice(Notice $notice) { $profile = $notice->getProfile(); if (empty($profile)) { diff --git a/lib/threadednoticelist.php b/lib/threadednoticelist.php index e8abeb74fc..ed3193420f 100644 --- a/lib/threadednoticelist.php +++ b/lib/threadednoticelist.php @@ -50,7 +50,7 @@ class ThreadedNoticeList extends NoticeList { protected $userProfile; - function __construct($notice, $out=null, $profile=-1) + function __construct(Notice $notice, HTMLOutputter $out=null, $profile=-1) { parent::__construct($notice, $out); if (is_int($profile) && $profile == -1) { @@ -147,7 +147,7 @@ class ThreadedNoticeList extends NoticeList * * @return NoticeListItem a list item for displaying the notice */ - function newListItem($notice) + function newListItem(Notice $notice) { return new ThreadedNoticeListItem($notice, $this->out, $this->userProfile); } @@ -174,7 +174,7 @@ class ThreadedNoticeListItem extends NoticeListItem { protected $userProfile = null; - function __construct($notice, $out=null, $profile=null) + function __construct(Notice $notice, HTMLOutputter $out=null, $profile=null) { parent::__construct($notice, $out); $this->userProfile = $profile; @@ -269,7 +269,7 @@ class ThreadedNoticeListSubItem extends NoticeListItem { protected $root = null; - function __construct($notice, $root, $out) + function __construct(Notice $notice, $root, $out) { $this->root = $root; parent::__construct($notice, $out); @@ -327,7 +327,7 @@ class ThreadedNoticeListMoreItem extends NoticeListItem { protected $cnt; - function __construct($notice, $out, $cnt) + function __construct(Notice $notice, HTMLOutputter $out, $cnt) { parent::__construct($notice, $out); $this->cnt = $cnt; diff --git a/plugins/Bookmark/actions/newbookmark.php b/plugins/Bookmark/actions/newbookmark.php index 168a6e07b6..bc043f41ed 100644 --- a/plugins/Bookmark/actions/newbookmark.php +++ b/plugins/Bookmark/actions/newbookmark.php @@ -191,7 +191,7 @@ class NewbookmarkAction extends Action * * @return void */ - function showNotice($notice) + function showNotice(Notice $notice) { class_exists('NoticeList'); // @fixme hack for autoloader $nli = new NoticeListItem($notice, $this); diff --git a/plugins/Event/actions/newevent.php b/plugins/Event/actions/newevent.php index d05b5af8d3..9483db7b4e 100644 --- a/plugins/Event/actions/newevent.php +++ b/plugins/Event/actions/newevent.php @@ -320,7 +320,7 @@ class NeweventAction extends Action * * @return void */ - function showNotice($notice) + function showNotice(Notice $notice) { $nli = new NoticeListItem($notice, $this); $nli->show(); diff --git a/plugins/Poll/PollPlugin.php b/plugins/Poll/PollPlugin.php index c6b4099756..e87e81c2e3 100644 --- a/plugins/Poll/PollPlugin.php +++ b/plugins/Poll/PollPlugin.php @@ -379,7 +379,7 @@ class PollPlugin extends MicroAppPlugin * open here, but we probably shouldn't open it here. Check parent class * and Bookmark plugin for if that's right. */ - function showNotice($notice, $out) + function showNotice(Notice $notice, $out) { switch ($notice->object_type) { case self::POLL_OBJECT: @@ -393,7 +393,7 @@ class PollPlugin extends MicroAppPlugin } } - function showNoticePoll($notice, $out) + function showNoticePoll(Notice $notice, $out) { $user = common_current_user(); @@ -425,7 +425,7 @@ class PollPlugin extends MicroAppPlugin $out->elementStart('div', array('class' => 'entry-content')); } - function showNoticePollResponse($notice, $out) + function showNoticePollResponse(Notice $notice, $out) { $user = common_current_user(); diff --git a/plugins/Poll/actions/newpoll.php b/plugins/Poll/actions/newpoll.php index 8a1155ba85..071778aaa2 100644 --- a/plugins/Poll/actions/newpoll.php +++ b/plugins/Poll/actions/newpoll.php @@ -181,7 +181,7 @@ class NewPollAction extends Action * * @return void */ - function showNotice($notice) + function showNotice(Notice $notice) { class_exists('NoticeList'); // @fixme hack for autoloader $nli = new NoticeListItem($notice, $this); diff --git a/plugins/QnA/QnAPlugin.php b/plugins/QnA/QnAPlugin.php index d874441d85..8aa3247f9a 100644 --- a/plugins/QnA/QnAPlugin.php +++ b/plugins/QnA/QnAPlugin.php @@ -319,7 +319,7 @@ class QnAPlugin extends MicroAppPlugin * @param Notice $notice * @param HTMLOutputter $out */ - function showNotice($notice, $out) + function showNotice(Notice $notice, $out) { switch ($notice->object_type) { case QnA_Question::OBJECT_TYPE: @@ -337,7 +337,7 @@ class QnAPlugin extends MicroAppPlugin } } - function showNoticeQuestion($notice, $out) + function showNoticeQuestion(Notice $notice, $out) { $user = common_current_user(); @@ -427,7 +427,7 @@ class QnAPlugin extends MicroAppPlugin return false; } - function showNoticeAnswer($notice, $out) + function showNoticeAnswer(Notice $notice, $out) { $user = common_current_user();