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 // TRANS: Title of blacklist plugin administration panel.
53 return _m('TITLE','Blacklist');
59 * @return string instructions
61 function getInstructions()
63 // TRANS: Instructions for blacklist plugin administration panel.
64 return _m('Blacklisted URLs and nicknames');
68 * Show the actual form
72 * @see BlacklistAdminPanelForm
76 $form = new BlacklistAdminPanelForm($this);
82 * Save the form settings
86 function saveSettings()
88 $nickPatterns = $this->splitPatterns($this->trimmed('blacklist-nicknames'));
89 Nickname_blacklist::saveNew($nickPatterns);
91 $urlPatterns = $this->splitPatterns($this->trimmed('blacklist-urls'));
92 Homepage_blacklist::saveNew($urlPatterns);
97 protected function splitPatterns($text)
100 foreach (explode("\n", $text) as $raw) {
101 $trimmed = trim($raw);
102 if ($trimmed != '') {
103 $patterns[] = $trimmed;
110 * Validate the values
112 * @param array &$values 2d array of values to check
114 * @return boolean success flag
116 function validate(&$values)
123 * Admin panel form for blacklist panel
127 * @author Evan Prodromou <evan@status.net>
128 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
129 * @link http://status.net/
131 class BlacklistAdminPanelForm extends Form
140 return 'blacklistadminpanel';
146 * @return string class
150 return 'form_settings';
156 * @return string action URL
160 return common_local_url('blacklistadminpanel');
164 * Show the form controls
170 $this->out->elementStart('ul', 'form_data');
172 $this->out->elementStart('li');
174 $nickPatterns = Nickname_blacklist::getPatterns();
176 // TRANS: Field label in blacklist plugin administration panel.
177 $this->out->textarea('blacklist-nicknames', _m('Nicknames'),
178 implode("\r\n", $nickPatterns),
179 // TRANS: Field title in blacklist plugin administration panel.
180 _m('Patterns of nicknames to block, one per line.'));
181 $this->out->elementEnd('li');
183 $urlPatterns = Homepage_blacklist::getPatterns();
185 $this->out->elementStart('li');
186 // TRANS: Field label in blacklist plugin administration panel.
187 $this->out->textarea('blacklist-urls', _m('URLs'),
188 implode("\r\n", $urlPatterns),
189 // TRANS: Field title in blacklist plugin administration panel.
190 _m('Patterns of URLs to block, one per line.'));
191 $this->out->elementEnd('li');
193 $this->out->elementEnd('ul');
197 * Buttons for submitting
201 function formActions()
203 $this->out->submit('submit',
204 // TRANS: Button text in blacklist plugin administration panel to save settings.
208 // TRANS: Button title in blacklist plugin administration panel to save settings.
209 _m('Save site settings.'));