]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/siteadminpanel.php
8a15458385e920eacf948ac8a2dd15c7ac241b56
[quix0rs-gnu-social.git] / actions / siteadminpanel.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Site 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    Evan Prodromou <evan@status.net>
25  * @author    Zach Copley <zach@status.net>
26  * @author    Sarven Capadisli <csarven@status.net>
27  * @copyright 2008-2009 StatusNet, Inc.
28  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
29  * @link      http://status.net/
30  */
31
32 if (!defined('STATUSNET')) {
33     exit(1);
34 }
35
36 /**
37  * Administer site settings
38  *
39  * @category Admin
40  * @package  StatusNet
41  * @author   Evan Prodromou <evan@status.net>
42  * @author   Zach Copley <zach@status.net>
43  * @author   Sarven Capadisli <csarven@status.net>
44  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
45  * @link     http://status.net/
46  */
47
48 class SiteadminpanelAction extends AdminPanelAction
49 {
50     /**
51      * Returns the page title
52      *
53      * @return string page title
54      */
55
56     function title()
57     {
58         return _('Site');
59     }
60
61     /**
62      * Instructions for using this form.
63      *
64      * @return string instructions
65      */
66
67     function getInstructions()
68     {
69         return _('Basic settings for this StatusNet site.');
70     }
71
72     /**
73      * Show the site admin panel form
74      *
75      * @return void
76      */
77
78     function showForm()
79     {
80         $form = new SiteAdminPanelForm($this);
81         $form->show();
82         return;
83     }
84
85     /**
86      * Save settings from the form
87      *
88      * @return void
89      */
90
91     function saveSettings()
92     {
93         $name = $this->trimmed('name');
94
95         $config = new Config();
96
97         $config->query('BEGIN');
98
99         Config::save('site', 'name', $name);
100
101         $config->query('COMMIT');
102
103         return;
104     }
105 }
106
107 class SiteAdminPanelForm extends Form
108 {
109     /**
110      * ID of the form
111      *
112      * @return int ID of the form
113      */
114
115     function id()
116     {
117         return 'siteadminpanel';
118     }
119
120     /**
121      * class of the form
122      *
123      * @return string class of the form
124      */
125
126     function formClass()
127     {
128         return 'form_site_admin_panel';
129     }
130
131     /**
132      * Action of the form
133      *
134      * @return string URL of the action
135      */
136
137     function action()
138     {
139         return common_local_url('siteadminpanel');
140     }
141
142     /**
143      * Data elements of the form
144      *
145      * @return void
146      */
147
148     function formData()
149     {
150         $this->out->input('name', _('Site name'),
151                           ($this->out->arg('name')) ? $this->out->arg('name') :
152                           common_config('site', 'name'),
153                           _('The name of your site, like "Yourcompany Microblog"'));
154     }
155
156     /**
157      * Action elements
158      *
159      * @return void
160      */
161
162     function formActions()
163     {
164         $this->out->submit('submit', _('Save'), 'submit', null, _('Save site settings'));
165     }
166 }