2008-05-14 23:54:36 +09:00
|
|
|
<?php
|
2009-01-17 04:35:37 +09:00
|
|
|
/**
|
2009-08-26 07:12:20 +09:00
|
|
|
* StatusNet, the distributed open-source microblogging tool
|
2008-05-21 04:14:12 +09:00
|
|
|
*
|
2009-01-17 04:35:37 +09:00
|
|
|
* Base class for settings actions
|
|
|
|
*
|
|
|
|
* PHP version 5
|
|
|
|
*
|
|
|
|
* LICENCE: This program is free software: you can redistribute it and/or modify
|
2008-05-15 04:26:48 +09: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-21 04:14:12 +09:00
|
|
|
*
|
2008-05-15 04:26:48 +09: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-21 04:14:12 +09:00
|
|
|
*
|
2008-05-15 04:26:48 +09: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-17 04:35:37 +09:00
|
|
|
*
|
|
|
|
* @category Settings
|
2009-08-26 07:12:20 +09:00
|
|
|
* @package StatusNet
|
2009-08-26 07:19:04 +09:00
|
|
|
* @author Evan Prodromou <evan@status.net>
|
2009-08-26 07:12:20 +09:00
|
|
|
* @copyright 2008-2009 StatusNet, Inc.
|
2009-01-17 04:35:37 +09:00
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
2009-08-26 07:16:46 +09:00
|
|
|
* @link http://status.net/
|
2008-05-15 04:26:48 +09:00
|
|
|
*/
|
2008-05-21 04:14:12 +09:00
|
|
|
|
2009-08-26 23:41:36 +09:00
|
|
|
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
2009-01-17 04:35:37 +09:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base class for settings group of actions
|
|
|
|
*
|
|
|
|
* @category Settings
|
2009-08-26 07:12:20 +09:00
|
|
|
* @package StatusNet
|
2009-08-26 07:19:04 +09:00
|
|
|
* @author Evan Prodromou <evan@status.net>
|
2009-01-17 04:35:37 +09:00
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
2009-08-26 07:16:46 +09:00
|
|
|
* @link http://status.net/
|
2009-01-17 04:35:37 +09:00
|
|
|
*
|
|
|
|
* @see Widget
|
|
|
|
*/
|
2008-05-14 23:54:36 +09:00
|
|
|
|
2009-05-24 12:40:11 +09:00
|
|
|
class SettingsAction extends CurrentUserDesignAction
|
2008-12-24 04:49:23 +09:00
|
|
|
{
|
2009-01-17 04:35:37 +09: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-16 01:28:44 +09:00
|
|
|
|
2008-12-24 04:33:23 +09:00
|
|
|
function handle($args)
|
|
|
|
{
|
2008-06-24 07:36:41 +09:00
|
|
|
parent::handle($args);
|
|
|
|
if (!common_logged_in()) {
|
2009-01-17 04:35:37 +09:00
|
|
|
$this->clientError(_('Not logged in.'));
|
2008-06-24 07:36:41 +09:00
|
|
|
return;
|
2008-06-24 11:52:34 +09:00
|
|
|
} else if (!common_is_real_login()) {
|
2009-01-17 04:35:37 +09: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-06 01:46:17 +09:00
|
|
|
$user = common_current_user();
|
2009-08-05 02:10:37 +09:00
|
|
|
if (Event::handle('RedirectToLogin', array($this, $user))) {
|
2009-08-05 02:17:43 +09:00
|
|
|
common_redirect(common_local_url('login'), 303);
|
2009-02-06 01:46:17 +09:00
|
|
|
}
|
2008-06-24 07:36:41 +09:00
|
|
|
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
2009-01-17 04:35:37 +09:00
|
|
|
$this->handlePost();
|
2008-06-24 07:36:41 +09:00
|
|
|
} else {
|
2009-01-17 04:35:37 +09:00
|
|
|
$this->showForm();
|
2008-06-24 07:36:41 +09:00
|
|
|
}
|
|
|
|
}
|
2008-05-16 01:28:44 +09:00
|
|
|
|
2009-01-17 04:35:37 +09:00
|
|
|
/**
|
|
|
|
* Handle a POST request
|
|
|
|
*
|
|
|
|
* @return boolean success flag
|
|
|
|
*/
|
2008-05-21 04:14:12 +09:00
|
|
|
|
2009-01-17 04:35:37 +09:00
|
|
|
function handlePost()
|
2008-12-24 04:33:23 +09:00
|
|
|
{
|
2008-06-24 07:36:41 +09:00
|
|
|
return false;
|
|
|
|
}
|
2008-05-17 21:20:45 +09:00
|
|
|
|
2009-01-17 04:35:37 +09: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-21 04:14:12 +09:00
|
|
|
|
2009-01-17 04:35:37 +09:00
|
|
|
function showForm($msg=null, $success=false)
|
2008-12-25 23:46:01 +09:00
|
|
|
{
|
2009-01-17 04:35:37 +09:00
|
|
|
$this->msg = $msg;
|
|
|
|
$this->success = $success;
|
2008-12-25 23:46:01 +09:00
|
|
|
|
2009-01-17 04:35:37 +09:00
|
|
|
$this->showPage();
|
2008-12-25 23:46:01 +09:00
|
|
|
}
|
2008-07-01 02:03:42 +09:00
|
|
|
|
2009-01-17 04:35:37 +09:00
|
|
|
/**
|
|
|
|
* show human-readable instructions for the page
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
|
|
|
|
function showPageNotice()
|
2008-12-24 04:33:23 +09:00
|
|
|
{
|
2009-01-17 04:35:37 +09:00
|
|
|
if ($this->msg) {
|
|
|
|
$this->element('div', ($this->success) ? 'success' : 'error',
|
|
|
|
$this->msg);
|
2008-12-24 04:19:07 +09:00
|
|
|
} else {
|
2009-01-17 05:00:26 +09:00
|
|
|
$inst = $this->getInstructions();
|
2008-12-24 04:19:07 +09:00
|
|
|
$output = common_markup_to_html($inst);
|
2009-01-17 04:35:37 +09:00
|
|
|
|
|
|
|
$this->elementStart('div', 'instructions');
|
|
|
|
$this->raw($output);
|
2009-01-17 05:00:26 +09:00
|
|
|
$this->elementEnd('div');
|
2008-12-24 04:19:07 +09:00
|
|
|
}
|
|
|
|
}
|
2008-07-01 02:03:42 +09:00
|
|
|
|
2009-01-17 04:35:37 +09: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-24 04:33:23 +09:00
|
|
|
{
|
2009-01-17 04:35:37 +09:00
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2011-01-24 02:35:35 +09: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 12:09:26 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Show notice form.
|
|
|
|
*
|
|
|
|
* @return nothing
|
|
|
|
*/
|
|
|
|
|
|
|
|
function showNoticeForm()
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2008-05-16 01:28:44 +09:00
|
|
|
}
|