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->conversation_tree = $this->boolean('conversation_tree');
114 $osp->stream_nicknames = $this->boolean('stream_nicknames');
115 $osp->modified = common_sql_now();
123 // TRANS: Confirmation shown when user profile settings are saved.
124 $this->showForm(_('Settings saved.'), true);
129 function showContent()
131 $user = common_current_user();
132 $form = new OldSchoolForm($this, $user);
137 class OldSchoolForm extends Form
141 function __construct($out, $user)
143 parent::__construct($out);
148 * Visible or invisible data elements
150 * Display the form fields that make up the data of the form.
151 * Sub-classes should overload this to show their data.
158 $this->elementStart('fieldset');
159 $this->elementStart('ul', 'form_data');
160 $this->elementStart('li');
161 $this->checkbox('stream_mode_only', _('Only stream mode (no conversations) in timelines'),
162 $this->user->streamModeOnly());
163 $this->elementEnd('li');
164 $this->elementStart('li');
165 $this->checkbox('conversation_tree', _('Show conversation page as hierarchical trees'),
166 $this->user->conversationTree());
167 $this->elementEnd('li');
168 $this->elementStart('li');
169 $this->checkbox('stream_nicknames', _('Show nicknames (not full names) in timelines'),
170 $this->user->streamNicknames());
171 $this->elementEnd('li');
172 $this->elementEnd('fieldset');
173 $this->elementEnd('ul');
177 * Buttons for form actions
179 * Submit and cancel buttons (or whatever)
180 * Sub-classes should overload this to show their own buttons.
185 function formActions()
187 $this->submit('submit', _('Save'));
193 * Should be unique on the page. Sub-classes should overload this
194 * to show their own IDs.
196 * @return int ID of the form
201 return 'form_oldschool';
205 * Action of the form.
207 * URL to post to. Should be overloaded by subclasses to give
208 * somewhere to post to.
210 * @return string URL to post to
215 return common_local_url('oldschoolsettings');
219 * Class of the form. May include space-separated list of multiple classes.
221 * @return string the form's class
226 return 'form_settings';