3 * StatusNet, the distributed open-source microblogging tool
5 * Base class for settings actions
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.
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.
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/>.
24 * @author Evan Prodromou <evan@status.net>
25 * @copyright 2008-2009 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/
30 if (!defined('STATUSNET') && !defined('LACONICA')) {
35 * Base class for settings group of actions
39 * @author Evan Prodromou <evan@status.net>
40 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
41 * @link http://status.net/
46 class SettingsAction extends Action
49 * A message for the user.
55 * Whether the message is a good one or a bad one.
61 * Handle input and output a page
63 * @param array $args $_REQUEST arguments
68 function handle($args)
70 parent::handle($args);
71 if (!common_logged_in()) {
72 // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
73 $this->clientError(_('Not logged in.'));
74 } else if (!common_is_real_login()) {
75 // Cookie theft means that automatic logins can't
76 // change important settings or see private info, and
77 // _all_ our settings are important
78 common_set_returnto($this->selfUrl());
79 $user = common_current_user();
80 if (Event::handle('RedirectToLogin', array($this, $user))) {
81 common_redirect(common_local_url('login'), 303);
83 } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
91 * Handle a POST request
93 * @return boolean success flag
102 * show the settings form
104 * @param string $msg an extra message for the user
105 * @param string $success good message or bad message?
110 function showForm($msg=null, $success=false)
113 $this->success = $success;
119 * show human-readable instructions for the page
124 function showPageNotice()
127 $this->element('div', ($this->success) ? 'success' : 'error',
130 $inst = $this->getInstructions();
131 $output = common_markup_to_html($inst);
133 $this->elementStart('div', 'instructions');
135 $this->elementEnd('div');
140 * instructions recipe for sub-classes
142 * Subclasses should override this to return readable instructions. They'll
143 * be processed by common_markup_to_html().
145 * @return string instructions text
148 function getInstructions()
154 * Show the local navigation menu
156 * This is the same for all settings, so we show it here.
161 function showLocalNav()
163 $menu = new SettingsNav($this);
173 function showNoticeForm()
178 function showProfileBlock()