2008-05-14 15:54:36 +01:00
|
|
|
<?php
|
2009-01-16 19:35:37 +00:00
|
|
|
/**
|
|
|
|
* Laconica, 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
|
|
|
|
* @package Laconica
|
|
|
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
|
|
|
* @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-14 20:26:48 +01:00
|
|
|
*/
|
2008-05-20 20:14:12 +01:00
|
|
|
|
2009-01-16 19:35:37 +00: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 15:54:36 +01:00
|
|
|
|
2008-12-23 19:49:23 +00:00
|
|
|
class SettingsAction extends Action
|
|
|
|
{
|
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()) {
|
2009-01-16 19:35:37 +00:00
|
|
|
$this->clientError(_('Not logged in.'));
|
2008-06-23 23:36:41 +01:00
|
|
|
return;
|
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());
|
2008-06-24 03:52:34 +01:00
|
|
|
common_redirect(common_local_url('login'));
|
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 '';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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-23 23:36:41 +01:00
|
|
|
}
|
2008-05-15 17:28:44 +01:00
|
|
|
}
|