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('STATUSNET')) {
32 // This check helps protect against security problems;
33 // your code file can't be executed directly from the web.
42 * @author Evan Prodromou <evan@status.net>
43 * @copyright 2011 StatusNet, Inc.
44 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
45 * @link http://status.net/
48 class OldschoolsettingsAction extends SettingsAction
53 * @return string Title of the page
57 // TRANS: Page title for profile settings.
58 return _('Old school UI settings');
62 * Instructions for use
64 * @return instructions for use
66 function getInstructions()
68 // TRANS: Usage instructions for profile settings.
69 return _('If you like it "the old way", you can set that here.');
73 * For initializing members of the class.
75 * @param array $argarray misc. arguments
77 * @return boolean true
80 function prepare($argarray)
82 if (!common_config('oldschool', 'enabled')) {
83 throw new ClientException("Old-school settings not enabled.");
85 parent::prepare($argarray);
92 * @param array $argarray is ignored since it's now passed in in prepare()
99 $user = common_current_user();
101 $osp = Old_school_prefs::getKV('user_id', $user->id);
107 $osp = new Old_school_prefs();
108 $osp->user_id = $user->id;
109 $osp->created = common_sql_now();
112 $osp->stream_mode_only = $this->boolean('stream_mode_only');
113 $osp->stream_nicknames = $this->boolean('stream_nicknames');
114 $osp->modified = common_sql_now();
122 // TRANS: Confirmation shown when user profile settings are saved.
123 $this->showForm(_('Settings saved.'), true);
128 function showContent()
130 $user = common_current_user();
131 $form = new OldSchoolForm($this, $user);
136 class OldSchoolForm extends Form
140 function __construct($out, $user)
142 parent::__construct($out);
147 * Visible or invisible data elements
149 * Display the form fields that make up the data of the form.
150 * Sub-classes should overload this to show their data.
157 $this->elementStart('fieldset');
158 $this->elementStart('ul', 'form_data');
159 $this->elementStart('li');
160 $this->checkbox('stream_mode_only', _('Only stream mode (no conversations) in timelines'),
161 $this->user->streamModeOnly());
162 $this->elementEnd('li');
163 $this->elementStart('li');
164 $this->checkbox('stream_nicknames', _('Show nicknames (not full names) in timelines'),
165 $this->user->streamNicknames());
166 $this->elementEnd('li');
167 $this->elementEnd('fieldset');
168 $this->elementEnd('ul');
172 * Buttons for form actions
174 * Submit and cancel buttons (or whatever)
175 * Sub-classes should overload this to show their own buttons.
180 function formActions()
182 $this->submit('submit', _('Save'));
188 * Should be unique on the page. Sub-classes should overload this
189 * to show their own IDs.
191 * @return int ID of the form
196 return 'form_oldschool';
200 * Action of the form.
202 * URL to post to. Should be overloaded by subclasses to give
203 * somewhere to post to.
205 * @return string URL to post to
210 return common_local_url('oldschoolsettings');
214 * Class of the form. May include space-separated list of multiple classes.
216 * @return string the form's class
221 return 'form_settings';