2008-05-14 15:54:36 +01:00
|
|
|
<?php
|
2009-01-16 19:35:37 +00:00
|
|
|
/**
|
2009-08-25 23:12:20 +01:00
|
|
|
* StatusNet, the distributed open-source microblogging tool
|
2008-05-20 20:14:12 +01:00
|
|
|
*
|
2009-01-16 19:35:37 +00:00
|
|
|
* Base class for settings actions
|
|
|
|
*
|
|
|
|
* PHP version 5
|
|
|
|
*
|
|
|
|
* LICENCE: This program is free software: you can redistribute it and/or modify
|
2008-05-14 20:26:48 +01:00
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2008-05-20 20:14:12 +01:00
|
|
|
*
|
2008-05-14 20:26:48 +01:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
2008-05-20 20:14:12 +01:00
|
|
|
*
|
2008-05-14 20:26:48 +01:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-01-16 19:35:37 +00:00
|
|
|
*
|
|
|
|
* @category Settings
|
2009-08-25 23:12:20 +01:00
|
|
|
* @package StatusNet
|
2009-08-25 23:19:04 +01:00
|
|
|
* @author Evan Prodromou <evan@status.net>
|
2009-08-25 23:12:20 +01:00
|
|
|
* @copyright 2008-2009 StatusNet, Inc.
|
2009-01-16 19:35:37 +00:00
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
2009-08-25 23:16:46 +01:00
|
|
|
* @link http://status.net/
|
2008-05-14 20:26:48 +01:00
|
|
|
*/
|
2008-05-20 20:14:12 +01:00
|
|
|
|
2009-08-26 15:41:36 +01:00
|
|
|
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
2009-01-16 19:35:37 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base class for settings group of actions
|
|
|
|
*
|
|
|
|
* @category Settings
|
2009-08-25 23:12:20 +01:00
|
|
|
* @package StatusNet
|
2009-08-25 23:19:04 +01:00
|
|
|
* @author Evan Prodromou <evan@status.net>
|
2009-01-16 19:35:37 +00:00
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
2009-08-25 23:16:46 +01:00
|
|
|
* @link http://status.net/
|
2009-01-16 19:35:37 +00:00
|
|
|
*
|
|
|
|
* @see Widget
|
|
|
|
*/
|
2008-05-14 15:54:36 +01:00
|
|
|
|
2011-06-09 21:20:19 +01:00
|
|
|
class SettingsAction extends Action
|
2008-12-23 19:49:23 +00:00
|
|
|
{
|
2009-01-16 19:35:37 +00:00
|
|
|
/**
|
|
|
|
* A message for the user.
|
|
|
|
*/
|
|
|
|
|
|
|
|
var $msg = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the message is a good one or a bad one.
|
|
|
|
*/
|
|
|
|
|
|
|
|
var $success = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle input and output a page
|
|
|
|
*
|
|
|
|
* @param array $args $_REQUEST arguments
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-05-15 17:28:44 +01:00
|
|
|
|
2008-12-23 19:33:23 +00:00
|
|
|
function handle($args)
|
|
|
|
{
|
2008-06-23 23:36:41 +01:00
|
|
|
parent::handle($args);
|
|
|
|
if (!common_logged_in()) {
|
2011-04-03 23:41:21 +01:00
|
|
|
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
|
2009-01-16 19:35:37 +00:00
|
|
|
$this->clientError(_('Not logged in.'));
|
2008-06-24 03:52:34 +01:00
|
|
|
} else if (!common_is_real_login()) {
|
2009-01-16 19:35:37 +00:00
|
|
|
// Cookie theft means that automatic logins can't
|
|
|
|
// change important settings or see private info, and
|
|
|
|
// _all_ our settings are important
|
|
|
|
common_set_returnto($this->selfUrl());
|
2009-02-05 16:46:17 +00:00
|
|
|
$user = common_current_user();
|
2009-08-04 18:10:37 +01:00
|
|
|
if (Event::handle('RedirectToLogin', array($this, $user))) {
|
2009-08-04 18:17:43 +01:00
|
|
|
common_redirect(common_local_url('login'), 303);
|
2009-02-05 16:46:17 +00:00
|
|
|
}
|
2008-06-23 23:36:41 +01:00
|
|
|
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
2009-01-16 19:35:37 +00:00
|
|
|
$this->handlePost();
|
2008-06-23 23:36:41 +01:00
|
|
|
} else {
|
2009-01-16 19:35:37 +00:00
|
|
|
$this->showForm();
|
2008-06-23 23:36:41 +01:00
|
|
|
}
|
|
|
|
}
|
2008-05-15 17:28:44 +01:00
|
|
|
|
2009-01-16 19:35:37 +00:00
|
|
|
/**
|
|
|
|
* Handle a POST request
|
|
|
|
*
|
|
|
|
* @return boolean success flag
|
|
|
|
*/
|
2008-05-20 20:14:12 +01:00
|
|
|
|
2009-01-16 19:35:37 +00:00
|
|
|
function handlePost()
|
2008-12-23 19:33:23 +00:00
|
|
|
{
|
2008-06-23 23:36:41 +01:00
|
|
|
return false;
|
|
|
|
}
|
2008-05-17 13:20:45 +01:00
|
|
|
|
2009-01-16 19:35:37 +00:00
|
|
|
/**
|
|
|
|
* show the settings form
|
|
|
|
*
|
|
|
|
* @param string $msg an extra message for the user
|
|
|
|
* @param string $success good message or bad message?
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-05-20 20:14:12 +01:00
|
|
|
|
2009-01-16 19:35:37 +00:00
|
|
|
function showForm($msg=null, $success=false)
|
2008-12-25 14:46:01 +00:00
|
|
|
{
|
2009-01-16 19:35:37 +00:00
|
|
|
$this->msg = $msg;
|
|
|
|
$this->success = $success;
|
2008-12-25 14:46:01 +00:00
|
|
|
|
2009-01-16 19:35:37 +00:00
|
|
|
$this->showPage();
|
2008-12-25 14:46:01 +00:00
|
|
|
}
|
2008-06-30 18:03:42 +01:00
|
|
|
|
2009-01-16 19:35:37 +00:00
|
|
|
/**
|
|
|
|
* show human-readable instructions for the page
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
|
|
|
|
function showPageNotice()
|
2008-12-23 19:33:23 +00:00
|
|
|
{
|
2009-01-16 19:35:37 +00:00
|
|
|
if ($this->msg) {
|
|
|
|
$this->element('div', ($this->success) ? 'success' : 'error',
|
|
|
|
$this->msg);
|
2008-12-23 19:19:07 +00:00
|
|
|
} else {
|
2009-01-16 20:00:26 +00:00
|
|
|
$inst = $this->getInstructions();
|
2008-12-23 19:19:07 +00:00
|
|
|
$output = common_markup_to_html($inst);
|
2009-01-16 19:35:37 +00:00
|
|
|
|
|
|
|
$this->elementStart('div', 'instructions');
|
|
|
|
$this->raw($output);
|
2009-01-16 20:00:26 +00:00
|
|
|
$this->elementEnd('div');
|
2008-12-23 19:19:07 +00:00
|
|
|
}
|
|
|
|
}
|
2008-06-30 18:03:42 +01:00
|
|
|
|
2009-01-16 19:35:37 +00:00
|
|
|
/**
|
|
|
|
* instructions recipe for sub-classes
|
|
|
|
*
|
|
|
|
* Subclasses should override this to return readable instructions. They'll
|
|
|
|
* be processed by common_markup_to_html().
|
|
|
|
*
|
|
|
|
* @return string instructions text
|
|
|
|
*/
|
|
|
|
|
|
|
|
function getInstructions()
|
2008-12-23 19:33:23 +00:00
|
|
|
{
|
2009-01-16 19:35:37 +00:00
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2011-01-23 17:35:35 +00:00
|
|
|
/**
|
|
|
|
* Show the local navigation menu
|
|
|
|
*
|
|
|
|
* This is the same for all settings, so we show it here.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
|
|
|
|
function showLocalNav()
|
|
|
|
{
|
|
|
|
$menu = new SettingsNav($this);
|
|
|
|
$menu->show();
|
|
|
|
}
|
2011-03-03 03:09:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Show notice form.
|
|
|
|
*
|
|
|
|
* @return nothing
|
|
|
|
*/
|
|
|
|
|
|
|
|
function showNoticeForm()
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2011-03-14 16:00:07 +00:00
|
|
|
|
|
|
|
function showProfileBlock()
|
|
|
|
{
|
|
|
|
}
|
2008-05-15 17:28:44 +01:00
|
|
|
}
|