Commit 998f4351 authored by Evan Giles's avatar Evan Giles Committed by Aaron Wells

Bug 1517279: CLI tool for maintenance mode

behatnotneeded, this commit adds a file which is not accessible to behat

Change-Id: I3af54df7ed8e30de78faee0540e48bbaa44a3013
Signed-off-by: Aaron Wells's avatarAaron Wells <aaronw@catalyst.net.nz>
parent 76f9c9d2
<?php
/**
*
* @package mahara
* @subpackage core
* @author Evan Giles
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
* @copyright (C) 2015 Evan Giles <evan@catalyst-au.net>
*
*/
define('INTERNAL', 1);
define('ADMIN', 1);
define('CLI', 1);
define('INSTALLER', 1);
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require(get_config('libroot') . 'cli.php');
require(get_config('libroot') . 'upgrade.php');
$cli = get_cli();
$options = array();
$options['close'] = (object) array(
'shortoptions' => array('cl', 'c'),
'description' => get_string('closesite', 'admin'),
);
$options['open'] = (object) array(
'shortoptions' => array('op', 'o'),
'description' => get_string('reopensite', 'admin'),
);
$settings = (object) array(
'info' => get_string('cli_close_site_info', 'admin'),
'options' => $options,
);
$cli->setup($settings);
$opensite = $cli->get_cli_param('open');
$closesite = $cli->get_cli_param('close');
if ($closesite) {
set_config('siteclosedbyadmin', 1);
require_once(get_config('docroot') . 'auth/session.php');
remove_all_sessions();
$cli->cli_exit(get_string('cli_close_site_siteclosed', 'admin'));
}
else if ($opensite) {
set_config('siteclosedbyadmin', 0);
$cli->cli_exit(get_string('cli_close_site_siteopen', 'admin'));
}
$cli->cli_print_help(true);
\ No newline at end of file
......@@ -1227,3 +1227,8 @@ $string['cli_pwreset_prompt2'] = 'Retype new password';
$string['cli_pwreset_success'] = 'Successfully reset password for user "%s".';
$string['cli_pwreset_success_forcepasswordchange'] = 'The user will be forced to reset their password at their next login.';
$string['cli_pwreset_typo'] = 'Sorry, passwords do not match.';
// Maintenance mode script
$string['cli_close_site_info'] = 'This command-line PHP script allows you to close your site to non-admin users, and open it again. (This is the same as pressing the "Close site" button on the Administration homepage.)';
$string['cli_close_site_siteclosed'] = 'Site closed for maintenance.';
$string['cli_close_site_siteopen'] = 'Site open.';
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment