3 * StatusNet, the distributed open-source microblogging tool
5 * Blacklist administration panel
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Evan Prodromou <evan@status.net>
25 * @copyright 2010 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
27 * @link http://status.net/
30 if (!defined('STATUSNET')) {
35 * Administer blacklist
39 * @author Evan Prodromou <evan@status.net>
40 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
41 * @link http://status.net/
44 class BlacklistadminpanelAction extends AdminPanelAction
47 * title of the admin panel
49 * @return string title
54 return _('Blacklist');
60 * @return string instructions
63 function getInstructions()
65 return _('Blacklisted URLs and nicknames');
69 * Show the actual form
73 * @see BlacklistAdminPanelForm
78 $form = new BlacklistAdminPanelForm($this);
84 * Save the form settings
89 function saveSettings()
91 $nickPatterns = $this->splitPatterns($this->trimmed('blacklist-nicknames'));
92 Nickname_blacklist::saveNew($nickPatterns);
94 $urlPatterns = $this->splitPatterns($this->trimmed('blacklist-urls'));
95 Homepage_blacklist::saveNew($urlPatterns);
100 protected function splitPatterns($text)
103 foreach (explode("\n", $text) as $raw) {
104 $trimmed = trim($raw);
105 if ($trimmed != '') {
106 $patterns[] = $trimmed;
113 * Validate the values
115 * @param array &$values 2d array of values to check
117 * @return boolean success flag
120 function validate(&$values)
127 * Admin panel form for blacklist panel
131 * @author Evan Prodromou <evan@status.net>
132 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
133 * @link http://status.net/
136 class BlacklistAdminPanelForm extends Form
146 return 'blacklistadminpanel';
152 * @return string class
157 return 'form_settings';
163 * @return string action URL
168 return common_local_url('blacklistadminpanel');
172 * Show the form controls
179 $this->out->elementStart('ul', 'form_data');
181 $this->out->elementStart('li');
183 $nickPatterns = Nickname_blacklist::getPatterns();
185 $this->out->textarea('blacklist-nicknames', _m('Nicknames'),
186 implode("\r\n", $nickPatterns),
187 _('Patterns of nicknames to block, one per line'));
188 $this->out->elementEnd('li');
190 $urlPatterns = Homepage_blacklist::getPatterns();
192 $this->out->elementStart('li');
193 $this->out->textarea('blacklist-urls', _m('URLs'),
194 implode("\r\n", $urlPatterns),
195 _('Patterns of URLs to block, one per line'));
196 $this->out->elementEnd('li');
198 $this->out->elementEnd('ul');
202 * Buttons for submitting
207 function formActions()
209 $this->out->submit('submit',
213 _('Save site settings'));