2010-01-29 06:04:14 +00:00
|
|
|
<?php
|
2020-06-08 10:25:01 +01:00
|
|
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
|
|
|
//
|
|
|
|
// GNU social is free software: you can redistribute it and/or modify
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// GNU social 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.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2010-01-29 06:04:14 +00:00
|
|
|
/**
|
|
|
|
* Sessions administration panel
|
|
|
|
*
|
|
|
|
* @category Settings
|
2020-06-08 10:25:01 +01:00
|
|
|
* @package GNUsocial
|
2010-01-29 06:04:14 +00:00
|
|
|
* @author Zach Copley <zach@status.net>
|
|
|
|
* @copyright 2010 StatusNet, Inc.
|
2020-06-08 10:25:01 +01:00
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
2010-01-29 06:04:14 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-08 10:25:01 +01:00
|
|
|
defined('GNUSOCIAL') || die();
|
2010-01-29 06:04:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Admin site sessions
|
|
|
|
*
|
2020-06-08 10:25:01 +01:00
|
|
|
* @category Admin
|
|
|
|
* @package GNUsocial
|
|
|
|
* @author Zach Copley <zach@status.net>
|
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
2010-01-29 06:04:14 +00:00
|
|
|
*/
|
|
|
|
class SessionsadminpanelAction extends AdminPanelAction
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Returns the page title
|
|
|
|
*
|
|
|
|
* @return string page title
|
|
|
|
*/
|
2020-06-08 10:25:01 +01:00
|
|
|
public function title()
|
2010-01-29 06:04:14 +00:00
|
|
|
{
|
2011-03-24 10:47:57 +00:00
|
|
|
// TRANS: Title for the sessions administration panel.
|
2020-06-08 10:25:01 +01:00
|
|
|
return _m('TITLE', 'Sessions');
|
2010-01-29 06:04:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Instructions for using this form.
|
|
|
|
*
|
|
|
|
* @return string instructions
|
|
|
|
*/
|
2020-06-08 10:25:01 +01:00
|
|
|
public function getInstructions()
|
2010-01-29 06:04:14 +00:00
|
|
|
{
|
2011-03-24 10:47:57 +00:00
|
|
|
// TRANS: Instructions for the sessions administration panel.
|
2010-09-17 22:32:18 +01:00
|
|
|
return _('Session settings for this StatusNet site');
|
2010-01-29 06:04:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the site admin panel form
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2020-06-08 10:25:01 +01:00
|
|
|
public function showForm()
|
2010-01-29 06:04:14 +00:00
|
|
|
{
|
|
|
|
$form = new SessionsAdminPanelForm($this);
|
|
|
|
$form->show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save settings from the form
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2020-06-08 10:25:01 +01:00
|
|
|
public function saveSettings()
|
2010-01-29 06:04:14 +00:00
|
|
|
{
|
|
|
|
static $booleans = array('sessions' => array('handle', 'debug'));
|
|
|
|
|
|
|
|
$values = array();
|
|
|
|
|
|
|
|
foreach ($booleans as $section => $parts) {
|
|
|
|
foreach ($parts as $setting) {
|
|
|
|
$values[$section][$setting] = ($this->boolean($setting)) ? 1 : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This throws an exception on validation errors
|
|
|
|
|
|
|
|
$this->validate($values);
|
|
|
|
|
|
|
|
// assert(all values are valid);
|
|
|
|
|
|
|
|
$config = new Config();
|
|
|
|
|
2020-06-08 10:25:01 +01:00
|
|
|
$config->query('START TRANSACTION');
|
2010-01-29 06:04:14 +00:00
|
|
|
|
|
|
|
foreach ($booleans as $section => $parts) {
|
|
|
|
foreach ($parts as $setting) {
|
|
|
|
Config::save($section, $setting, $values[$section][$setting]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$config->query('COMMIT');
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-06-08 10:25:01 +01:00
|
|
|
public function validate(&$values)
|
2010-01-29 06:04:14 +00:00
|
|
|
{
|
|
|
|
// stub
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-24 10:47:57 +00:00
|
|
|
// @todo FIXME: Class documentation missing.
|
2010-01-29 06:04:14 +00:00
|
|
|
class SessionsAdminPanelForm extends AdminForm
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* ID of the form
|
|
|
|
*
|
|
|
|
* @return int ID of the form
|
|
|
|
*/
|
2020-06-08 10:25:01 +01:00
|
|
|
public function id()
|
2010-01-29 06:04:14 +00:00
|
|
|
{
|
|
|
|
return 'sessionsadminpanel';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* class of the form
|
|
|
|
*
|
|
|
|
* @return string class of the form
|
|
|
|
*/
|
2020-06-08 10:25:01 +01:00
|
|
|
public function formClass()
|
2010-01-29 06:04:14 +00:00
|
|
|
{
|
|
|
|
return 'form_settings';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Action of the form
|
|
|
|
*
|
|
|
|
* @return string URL of the action
|
|
|
|
*/
|
2020-06-08 10:25:01 +01:00
|
|
|
public function action()
|
2010-01-29 06:04:14 +00:00
|
|
|
{
|
|
|
|
return common_local_url('sessionsadminpanel');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Data elements of the form
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2020-06-08 10:25:01 +01:00
|
|
|
public function formData()
|
2010-01-29 06:04:14 +00:00
|
|
|
{
|
|
|
|
$this->out->elementStart('fieldset', array('id' => 'settings_user_sessions'));
|
2011-03-24 10:47:57 +00:00
|
|
|
// TRANS: Fieldset legend on the sessions administration panel.
|
2020-06-08 10:25:01 +01:00
|
|
|
$this->out->element('legend', null, _m('LEGEND', 'Sessions'));
|
2010-01-29 06:04:14 +00:00
|
|
|
|
|
|
|
$this->out->elementStart('ul', 'form_data');
|
|
|
|
|
|
|
|
$this->li();
|
2011-03-24 10:47:57 +00:00
|
|
|
// TRANS: Checkbox title on the sessions administration panel.
|
|
|
|
// TRANS: Indicates if StatusNet should handle session administration.
|
2020-06-08 10:25:01 +01:00
|
|
|
$this->out->checkbox(
|
|
|
|
'handle',
|
|
|
|
_('Handle sessions'),
|
|
|
|
(bool) $this->value('handle', 'sessions'),
|
|
|
|
// TRANS: Checkbox title on the sessions administration panel.
|
|
|
|
// TRANS: Indicates if StatusNet should handle session administration.
|
|
|
|
_('Handle sessions ourselves.')
|
|
|
|
);
|
2010-01-29 06:04:14 +00:00
|
|
|
$this->unli();
|
|
|
|
|
|
|
|
$this->li();
|
2011-03-24 10:47:57 +00:00
|
|
|
// TRANS: Checkbox label on the sessions administration panel.
|
|
|
|
// TRANS: Indicates if StatusNet should write session debugging output.
|
2020-06-08 10:25:01 +01:00
|
|
|
$this->out->checkbox(
|
|
|
|
'debug',
|
|
|
|
_('Session debugging'),
|
|
|
|
(bool) $this->value('debug', 'sessions'),
|
|
|
|
// TRANS: Checkbox title on the sessions administration panel.
|
|
|
|
_('Enable debugging output for sessions.')
|
|
|
|
);
|
2010-01-29 06:04:14 +00:00
|
|
|
$this->unli();
|
|
|
|
|
|
|
|
$this->out->elementEnd('ul');
|
|
|
|
|
|
|
|
$this->out->elementEnd('fieldset');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Action elements
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2020-06-08 10:25:01 +01:00
|
|
|
public function formActions()
|
2010-01-29 06:04:14 +00:00
|
|
|
{
|
2020-06-08 10:25:01 +01:00
|
|
|
$this->out->submit(
|
|
|
|
'submit',
|
|
|
|
// TRANS: Submit button text on the sessions administration panel.
|
|
|
|
_m('BUTTON', 'Save'),
|
|
|
|
'submit',
|
|
|
|
null,
|
|
|
|
// TRANS: Title for submit button on the sessions administration panel.
|
|
|
|
_('Save session settings')
|
|
|
|
);
|
2010-01-29 06:04:14 +00:00
|
|
|
}
|
|
|
|
}
|