3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2011, StatusNet, Inc.
6 * Settings panel for old-school UI
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Affero General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Affero General Public License for more details.
20 * You should have received a copy of the GNU Affero General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * @author Evan Prodromou <evan@status.net>
26 * @copyright 2011 StatusNet, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
28 * @link http://status.net/
31 if (!defined('GNUSOCIAL')) { exit(1); }
38 * @author Evan Prodromou <evan@status.net>
39 * @copyright 2011 StatusNet, Inc.
40 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
41 * @link http://status.net/
44 class OldschoolsettingsAction extends SettingsAction
49 * @return string Title of the page
53 // TRANS: Page title for profile settings.
54 return _('Old school UI settings');
58 * Instructions for use
60 * @return instructions for use
62 function getInstructions()
64 // TRANS: Usage instructions for profile settings.
65 return _('If you like it "the old way", you can set that here.');
69 * For initializing members of the class.
71 * @param array $argarray misc. arguments
73 * @return boolean true
76 protected function doPreparation()
78 if (!common_config('oldschool', 'enabled')) {
79 throw new ClientException("Old-school settings not enabled.");
85 $osp = Old_school_prefs::getKV('user_id', $this->scoped->getID());
91 $osp = new Old_school_prefs();
92 $osp->user_id = $this->scoped->getID();
93 $osp->created = common_sql_now();
96 $osp->stream_mode_only = $this->boolean('stream_mode_only');
97 $osp->stream_nicknames = $this->boolean('stream_nicknames');
98 $osp->modified = common_sql_now();
100 if ($orig instanceof Old_school_prefs) {
106 // TRANS: Confirmation shown when user profile settings are saved.
107 return _('Settings saved.');
111 class OldSchoolSettingsForm extends Form
115 function __construct(Action $out)
117 parent::__construct($out);
118 $this->user = $out->getScoped()->getUser();
122 * Visible or invisible data elements
124 * Display the form fields that make up the data of the form.
125 * Sub-classes should overload this to show their data.
132 $this->elementStart('fieldset');
133 $this->elementStart('ul', 'form_data');
134 $this->elementStart('li');
135 $this->checkbox('stream_mode_only', _('Only stream mode (no conversations) in timelines'),
136 $this->user->streamModeOnly());
137 $this->elementEnd('li');
138 $this->elementStart('li');
139 $this->checkbox('stream_nicknames', _('Show nicknames (not full names) in timelines'),
140 $this->user->streamNicknames());
141 $this->elementEnd('li');
142 $this->elementEnd('fieldset');
143 $this->elementEnd('ul');
147 * Buttons for form actions
149 * Submit and cancel buttons (or whatever)
150 * Sub-classes should overload this to show their own buttons.
155 function formActions()
157 $this->submit('submit', _('Save'));
163 * Should be unique on the page. Sub-classes should overload this
164 * to show their own IDs.
166 * @return int ID of the form
171 return 'form_oldschool';
175 * Action of the form.
177 * URL to post to. Should be overloaded by subclasses to give
178 * somewhere to post to.
180 * @return string URL to post to
185 return common_local_url('oldschoolsettings');
189 * Class of the form. May include space-separated list of multiple classes.
191 * @return string the form's class
196 return 'form_settings';