3 * StatusNet, the distributed open-source microblogging tool
5 * Site notice 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 Zach Copley <zach@status.net>
25 * @copyright 2010 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('STATUSNET')) {
34 require_once INSTALLDIR.'/extlib/htmLawed/htmLawed.php';
37 * Update the site-wide notice text
41 * @author Zach Copley <zach@status.net>
42 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
43 * @link http://status.net/
46 class SitenoticeadminpanelAction extends AdminPanelAction
49 * Returns the page title
51 * @return string page title
56 return _('Site Notice');
60 * Instructions for using this form.
62 * @return string instructions
65 function getInstructions()
67 return _('Edit site-wide message');
71 * Show the site notice admin panel form
78 $form = new SiteNoticeAdminPanelForm($this);
84 * Save settings from the form
89 function saveSettings()
91 $siteNotice = $this->trimmed('site-notice');
93 // assert(all values are valid);
94 // This throws an exception on validation errors
96 $this->validate($siteNotice);
98 $config = new Config();
100 $result = Config::save('site', 'notice', $siteNotice);
103 $this->ServerError(_("Unable to save site notice."));
107 function validate(&$siteNotice)
109 // Validate notice text
111 if (mb_strlen($siteNotice) > 255) {
113 _('Max length for the site-wide notice is 255 chars.')
121 'deny_attribute' => 'id,style,on*'
124 $siteNotice = htmLawed($siteNotice, $config);
128 class SiteNoticeAdminPanelForm extends AdminForm
133 * @return int ID of the form
138 return 'form_site_notice_admin_panel';
144 * @return string class of the form
149 return 'form_settings';
155 * @return string URL of the action
160 return common_local_url('sitenoticeadminpanel');
164 * Data elements of the form
171 $this->out->elementStart('ul', 'form_data');
173 $this->out->elementStart('li');
174 $this->out->textarea(
176 _('Site notice text'),
177 common_config('site', 'notice'),
178 _('Site-wide notice text (255 chars max; HTML okay)')
180 $this->out->elementEnd('li');
182 $this->out->elementEnd('ul');
191 function formActions()
198 _('Save site notice')