3 * StatusNet, the distributed open-source microblogging tool
5 * Site access 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 * Administer site access settings
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 AccessadminpanelAction extends AdminPanelAction
44 * Returns the page title
46 * @return string page title
50 // TRANS: Page title for Access admin panel that allows configuring site access.
55 * Instructions for using this form.
57 * @return string instructions
59 function getInstructions()
61 // TRANS: Page notice.
62 return _('Site access settings');
66 * Show the site admin panel form
72 $form = new AccessAdminPanelForm($this);
78 * Save settings from the form
82 function saveSettings()
84 static $booleans = array('site' => array('private', 'inviteonly', 'closed'),
85 'public' => array('localonly'));
87 foreach ($booleans as $section => $parts) {
88 foreach ($parts as $setting) {
89 $values[$section][$setting] = ($this->boolean($setting)) ? 1 : 0;
93 $config = new Config();
95 $config->query('BEGIN');
97 foreach ($booleans as $section => $parts) {
98 foreach ($parts as $setting) {
99 Config::save($section, $setting, $values[$section][$setting]);
103 $config->query('COMMIT');
109 class AccessAdminPanelForm extends AdminForm
114 * @return int ID of the form
118 return 'form_site_admin_panel';
124 * @return string class of the form
128 return 'form_settings';
134 * @return string URL of the action
138 return common_local_url('accessadminpanel');
142 * Data elements of the form
148 $this->out->elementStart('fieldset', array('id' => 'settings_admin_account_access'));
149 // TRANS: Form legend for registration form.
150 $this->out->element('legend', null, _('Registration'));
151 $this->out->elementStart('ul', 'form_data');
154 // TRANS: Checkbox instructions for admin setting "Invite only".
155 $instructions = _('Make registration invitation only.');
156 // TRANS: Checkbox label for configuring site as invite only.
157 $this->out->checkbox('inviteonly', _('Invite only'),
158 (bool) $this->value('inviteonly'),
163 // TRANS: Checkbox instructions for admin setting "Closed" (no new registrations).
164 $instructions = _('Disable new registrations.');
165 // TRANS: Checkbox label for disabling new user registrations.
166 $this->out->checkbox('closed', _('Closed'),
167 (bool) $this->value('closed'),
171 $this->out->elementEnd('ul');
172 $this->out->elementEnd('fieldset');
175 // Public access settings (login requirements for feeds etc.)
176 $this->out->elementStart('fieldset', array('id' => 'settings_admin_public_access'));
177 // TRANS: Form legend for registration form.
178 $this->out->element('legend', null, _('Feed access'));
179 $this->out->elementStart('ul', 'form_data');
181 // TRANS: Checkbox instructions for admin setting "Private".
182 $instructions = _('Prohibit anonymous users (not logged in) from viewing site?');
183 // TRANS: Checkbox label for prohibiting anonymous users from viewing site.
184 $this->out->checkbox('private', _m('LABEL', 'Private'),
185 (bool) $this->value('private'),
190 // TRANS: Description of the full network notice stream views..
191 $instructions = _('The full network view includes (public) remote notices which may be unrelated to local conversations.');
192 // TRANS: Checkbox label for hiding remote network posts if they have not been interacted with locally.
193 $this->out->checkbox('localonly', _('Restrict full network view to accounts'),
194 (bool) $this->value('localonly', 'public'),
198 $this->out->elementEnd('ul');
199 $this->out->elementEnd('fieldset');
207 function formActions()
209 // TRANS: Button title to save access settings in site admin panel.
210 $title = _('Save access settings.');
211 // TRANS: Button text to save access settings in site admin panel.
212 $this->out->submit('submit', _m('BUTTON', 'Save'), 'submit', null, $title);