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 = array();
93 $rawNickPatterns = explode("\n", $this->trimmed('blacklist-nicknames'));
95 foreach ($rawNickPatterns as $raw) {
96 $nickPatterns[] = trim($raw);
99 Nickname_blacklist::saveNew($nickPatterns);
101 $rawUrlPatterns = explode("\n", $this->trimmed('blacklist-urls'));
102 $urlPatterns = array();
104 foreach ($rawUrlPatterns as $raw) {
105 $urlPatterns[] = trim($raw);
108 Homepage_blacklist::saveNew($urlPatterns);
114 * Validate the values
116 * @param array &$values 2d array of values to check
118 * @return boolean success flag
121 function validate(&$values)
128 * Admin panel form for blacklist panel
132 * @author Evan Prodromou <evan@status.net>
133 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
134 * @link http://status.net/
137 class BlacklistAdminPanelForm extends Form
147 return 'blacklistadminpanel';
153 * @return string class
158 return 'form_settings';
164 * @return string action URL
169 return common_local_url('blacklistadminpanel');
173 * Show the form controls
180 $this->out->elementStart('ul', 'form_data');
182 $this->out->elementStart('li');
184 $nickPatterns = Nickname_blacklist::getPatterns();
186 $this->out->textarea('blacklist-nicknames', _m('Nicknames'),
187 implode("\r\n", $nickPatterns),
188 _('Patterns of nicknames to block, one per line'));
189 $this->out->elementEnd('li');
191 $urlPatterns = Homepage_blacklist::getPatterns();
193 $this->out->elementStart('li');
194 $this->out->textarea('blacklist-urls', _m('URLs'),
195 implode("\r\n", $urlPatterns),
196 _('Patterns of URLs to block, one per line'));
197 $this->out->elementEnd('li');
199 $this->out->elementEnd('ul');
203 * Buttons for submitting
208 function formActions()
210 $this->out->submit('submit',
214 _('Save site settings'));