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('GNUSOCIAL')) { exit(1); }
33 * Update the site-wide notice text
37 * @author Zach Copley <zach@status.net>
38 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
39 * @link http://status.net/
41 class SitenoticeadminpanelAction extends AdminPanelAction
44 * Returns the page title
46 * @return string page title
50 // TRANS: Page title for site-wide notice tab in admin panel.
51 return _('Site Notice');
55 * Instructions for using this form.
57 * @return string instructions
59 function getInstructions()
61 // TRANS: Instructions for site-wide notice tab in admin panel.
62 return _('Edit site-wide message');
66 * Show the site notice admin panel form
72 $form = new SiteNoticeAdminPanelForm($this);
78 * Save settings from the form
82 function saveSettings()
84 $siteNotice = $this->trimmed('site-notice');
86 // assert(all values are valid);
87 // This throws an exception on validation errors
89 $this->validate($siteNotice);
91 $config = new Config();
93 $result = Config::save('site', 'notice', $siteNotice);
96 // TRANS: Server error displayed when saving a site-wide notice was impossible.
97 $this->ServerError(_('Unable to save site notice.'));
101 function validate(&$siteNotice)
103 // Validate notice text
105 if (mb_strlen($siteNotice) > 255) {
107 // TRANS: Client error displayed when a site-wide notice was longer than allowed.
108 _('Maximum length for the site-wide notice is 255 characters.')
113 $siteNotice = common_purify($siteNotice);
117 class SiteNoticeAdminPanelForm extends AdminForm
122 * @return int ID of the form
127 return 'form_site_notice_admin_panel';
133 * @return string class of the form
138 return 'form_settings';
144 * @return string URL of the action
149 return common_local_url('sitenoticeadminpanel');
153 * Data elements of the form
160 $this->out->elementStart('ul', 'form_data');
162 $this->out->elementStart('li');
163 $this->out->textarea(
165 // TRANS: Label for site-wide notice text field in admin panel.
166 _('Site notice text'),
167 common_config('site', 'notice'),
168 // TRANS: Tooltip for site-wide notice text field in admin panel.
169 _('Site-wide notice text (255 characters maximum; HTML allowed)')
171 $this->out->elementEnd('li');
173 $this->out->elementEnd('ul');
182 function formActions()
186 // TRANS: Button text for saving site notice in admin panel.
190 // TRANS: Button title to save site notice in admin panel.
191 _('Save site notice.')