2008-05-14 23:54:36 +09:00
|
|
|
<?php
|
2009-01-17 04:35:37 +09:00
|
|
|
/**
|
|
|
|
* Laconica, 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
|
|
|
|
* @package Laconica
|
|
|
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
|
|
|
* @author Earle Martin <earle@downlode.org>
|
|
|
|
* @copyright 2008-2009 Control Yourself, Inc.
|
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
|
|
|
* @link http://laconi.ca/
|
2008-05-15 04:26:48 +09:00
|
|
|
*/
|
2008-05-21 04:14:12 +09:00
|
|
|
|
2009-01-17 04:35:37 +09:00
|
|
|
if (!defined('LACONICA')) {
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
require_once INSTALLDIR.'/lib/settingsgroupnav.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base class for settings group of actions
|
|
|
|
*
|
|
|
|
* @category Settings
|
|
|
|
* @package Laconica
|
|
|
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
|
|
|
* @link http://laconi.ca/
|
|
|
|
*
|
|
|
|
* @see Widget
|
|
|
|
*/
|
2008-05-14 23:54:36 +09:00
|
|
|
|
2008-12-24 04:49:23 +09:00
|
|
|
class SettingsAction extends Action
|
|
|
|
{
|
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());
|
2008-06-24 11:52:34 +09:00
|
|
|
common_redirect(common_local_url('login'));
|
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 04:35:37 +09:00
|
|
|
$inst = $this->get_instructions();
|
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);
|
|
|
|
$this->elementEend('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 '';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the local navigation menu
|
|
|
|
*
|
|
|
|
* This is the same for all settings, so we show it here.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
|
|
|
|
function showLocalNav()
|
|
|
|
{
|
|
|
|
$menu = new SettingsGroupNav($this);
|
|
|
|
$menu->show();
|
2008-06-24 07:36:41 +09:00
|
|
|
}
|
2008-05-16 01:28:44 +09:00
|
|
|
}
|