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/
43 class BlacklistadminpanelAction extends AdminPanelAction
46 * title of the admin panel
48 * @return string title
52 return _m('Blacklist');
58 * @return string instructions
60 function getInstructions()
62 return _m('Blacklisted URLs and nicknames');
66 * Show the actual form
70 * @see BlacklistAdminPanelForm
74 $form = new BlacklistAdminPanelForm($this);
80 * Save the form settings
84 function saveSettings()
86 $nickPatterns = $this->splitPatterns($this->trimmed('blacklist-nicknames'));
87 Nickname_blacklist::saveNew($nickPatterns);
89 $urlPatterns = $this->splitPatterns($this->trimmed('blacklist-urls'));
90 Homepage_blacklist::saveNew($urlPatterns);
95 protected function splitPatterns($text)
98 foreach (explode("\n", $text) as $raw) {
99 $trimmed = trim($raw);
100 if ($trimmed != '') {
101 $patterns[] = $trimmed;
108 * Validate the values
110 * @param array &$values 2d array of values to check
112 * @return boolean success flag
114 function validate(&$values)
121 * Admin panel form for blacklist panel
125 * @author Evan Prodromou <evan@status.net>
126 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
127 * @link http://status.net/
129 class BlacklistAdminPanelForm extends Form
138 return 'blacklistadminpanel';
144 * @return string class
148 return 'form_settings';
154 * @return string action URL
158 return common_local_url('blacklistadminpanel');
162 * Show the form controls
168 $this->out->elementStart('ul', 'form_data');
170 $this->out->elementStart('li');
172 $nickPatterns = Nickname_blacklist::getPatterns();
174 $this->out->textarea('blacklist-nicknames', _m('Nicknames'),
175 implode("\r\n", $nickPatterns),
176 _m('Patterns of nicknames to block, one per line'));
177 $this->out->elementEnd('li');
179 $urlPatterns = Homepage_blacklist::getPatterns();
181 $this->out->elementStart('li');
182 $this->out->textarea('blacklist-urls', _m('URLs'),
183 implode("\r\n", $urlPatterns),
184 _m('Patterns of URLs to block, one per line'));
185 $this->out->elementEnd('li');
187 $this->out->elementEnd('ul');
191 * Buttons for submitting
195 function formActions()
197 $this->out->submit('submit',
201 _m('Save site settings'));