]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/accessadminpanel.php
Don't abort on too long notices in Notice::saveActivity
[quix0rs-gnu-social.git] / actions / accessadminpanel.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Site access administration panel
6  *
7  * PHP version 5
8  *
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.
13  *
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.
18  *
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/>.
21  *
22  * @category  Settings
23  * @package   StatusNet
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/
28  */
29
30 if (!defined('GNUSOCIAL')) { exit(1); }
31
32 /**
33  * Administer site access settings
34  *
35  * @category Admin
36  * @package  StatusNet
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/
40  */
41 class AccessadminpanelAction extends AdminPanelAction
42 {
43     /**
44      * Returns the page title
45      *
46      * @return string page title
47      */
48     function title()
49     {
50         // TRANS: Page title for Access admin panel that allows configuring site access.
51         return _('Access');
52     }
53
54     /**
55      * Instructions for using this form.
56      *
57      * @return string instructions
58      */
59     function getInstructions()
60     {
61         // TRANS: Page notice.
62         return _('Site access settings');
63     }
64
65     /**
66      * Show the site admin panel form
67      *
68      * @return void
69      */
70     function showForm()
71     {
72         $form = new AccessAdminPanelForm($this);
73         $form->show();
74         return;
75     }
76
77     /**
78      * Save settings from the form
79      *
80      * @return void
81      */
82     function saveSettings()
83     {
84         static $booleans = array('site' => array('private', 'inviteonly', 'closed'),
85                                  'public' => array('localonly'));
86
87         foreach ($booleans as $section => $parts) {
88             foreach ($parts as $setting) {
89                 $values[$section][$setting] = ($this->boolean($setting)) ? 1 : 0;
90             }
91         }
92
93         $config = new Config();
94
95         $config->query('BEGIN');
96
97         foreach ($booleans as $section => $parts) {
98             foreach ($parts as $setting) {
99                 Config::save($section, $setting, $values[$section][$setting]);
100             }
101         }
102
103         $config->query('COMMIT');
104
105         return;
106     }
107 }
108
109 class AccessAdminPanelForm extends AdminForm
110 {
111     /**
112      * ID of the form
113      *
114      * @return int ID of the form
115      */
116     function id()
117     {
118         return 'form_site_admin_panel';
119     }
120
121     /**
122      * class of the form
123      *
124      * @return string class of the form
125      */
126     function formClass()
127     {
128         return 'form_settings';
129     }
130
131     /**
132      * Action of the form
133      *
134      * @return string URL of the action
135      */
136     function action()
137     {
138         return common_local_url('accessadminpanel');
139     }
140
141     /**
142      * Data elements of the form
143      *
144      * @return void
145      */
146     function formData()
147     {
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');
152
153         $this->li();
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'),
159                              $instructions);
160         $this->unli();
161
162         $this->li();
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'),
168                              $instructions);
169         $this->unli();
170
171         $this->out->elementEnd('ul');
172         $this->out->elementEnd('fieldset');
173
174
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');
180         $this->li();
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'),
186                              $instructions);
187         $this->unli();
188
189         $this->li();
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'),
195                              $instructions);
196         $this->unli();
197
198         $this->out->elementEnd('ul');
199         $this->out->elementEnd('fieldset');
200     }
201
202     /**
203      * Action elements
204      *
205      * @return void
206      */
207     function formActions()
208     {
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);
213     }
214 }