3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2012, StatusNet, Inc.
6 * Stream of latest spam messages
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Affero General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Affero General Public License for more details.
20 * You should have received a copy of the GNU Affero General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * @author Evan Prodromou <evan@status.net>
26 * @copyright 2012 StatusNet, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
28 * @link http://status.net/
31 if (!defined('STATUSNET')) {
32 // This check helps protect against security problems;
33 // your code file can't be executed directly from the web.
37 require_once INSTALLDIR.'/lib/noticelist.php';
42 * Shows the latest spam on the service
46 * @author Evan Prodromou <evan@status.net>
47 * @copyright 2012 StatusNet, Inc.
48 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
49 * @link http://status.net/
52 class SpamAction extends Action
58 return _("Latest Spam");
62 * For initializing members of the class.
64 * @param array $argarray misc. arguments
66 * @return boolean true
69 function prepare($argarray)
71 parent::prepare($argarray);
73 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
75 // User must be logged in.
77 $user = common_current_user();
80 throw new ClientException(_("You must be logged in to review."), 403);
83 // User must have the right to review spam
85 if (!$user->hasRight(ActivitySpamPlugin::REVIEWSPAM)) {
86 throw new ClientException(_('You cannot review spam on this site.'), 403);
89 $stream = new SpamNoticeStream($user->getProfile());
91 $this->notices = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
92 NOTICES_PER_PAGE + 1);
94 if($this->page > 1 && $this->notices->N == 0) {
95 throw new ClientException(_('No such page.'), 404);
104 * @param array $argarray is ignored since it's now passed in in prepare()
109 function handle($argarray=null)
111 parent::handle($args);
117 * Fill the content area
119 * Shows a list of the notices in the public stream, with some pagination
125 function showContent()
127 $nl = new NoticeList($this->notices, $this);
132 $this->showEmptyList();
135 $this->pagination($this->page > 1,
136 $cnt > NOTICES_PER_PAGE,
141 function showEmptyList()
143 // TRANS: Text displayed for public feed when there are no public notices.
144 $message = _('This is the timeline of spam messages for %%site.name%% but none have been detected yet.');
146 $this->elementStart('div', 'guide');
147 $this->raw(common_markup_to_html($message));
148 $this->elementEnd('div');
152 * Return true if read only.
156 * @param array $args other arguments
158 * @return boolean is read only action?
161 function isReadOnly($args)