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 static $settings = array(
92 'blacklist' => array('nicknames', 'urls'),
97 foreach ($settings as $section => $parts) {
98 foreach ($parts as $setting) {
99 $values[$section][$setting] = $this->trimmed("$section-$setting");
103 // This throws an exception on validation errors
105 $this->validate($values);
107 // assert(all values are valid);
109 $config = new Config();
111 $config->query('BEGIN');
113 foreach ($settings as $section => $parts) {
114 foreach ($parts as $setting) {
115 Config::save($section, $setting, $values[$section][$setting]);
119 $config->query('COMMIT');
125 * Validate the values
127 * @param array &$values 2d array of values to check
129 * @return boolean success flag
132 function validate(&$values)
139 * Admin panel form for blacklist panel
143 * @author Evan Prodromou <evan@status.net>
144 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
145 * @link http://status.net/
148 class BlacklistAdminPanelForm extends Form
158 return 'blacklistadminpanel';
164 * @return string class
169 return 'form_settings';
175 * @return string action URL
180 return common_local_url('blacklistadminpanel');
184 * Show the form controls
191 $this->out->elementStart('ul', 'form_data');
193 $this->out->elementStart('li');
194 $this->out->textarea('blacklist-nicknames', _m('Nicknames'),
195 common_config('blacklist', 'nicknames'),
196 _('Patterns of nicknames to block, one per line'));
197 $this->out->elementEnd('li');
199 $this->out->elementStart('li');
200 $this->out->textarea('blacklist-urls', _m('URLs'),
201 common_config('blacklist', 'urls'),
202 _('Patterns of URLs to block, one per line'));
203 $this->out->elementEnd('li');
205 $this->out->elementEnd('ul');
209 * Buttons for submitting
214 function formActions()
216 $this->out->submit('submit',
220 _('Save site settings'));