Issue #47 - CLI will fail if outage plugin is not enabled.

This commit is contained in:
Daniel Thee Roperto
2016-09-26 10:51:32 +10:00
parent f8e671a80d
commit 909b4bbcd3
8 changed files with 43 additions and 17 deletions

View File

@@ -64,6 +64,11 @@ class cli_exception extends Exception {
*/
const ERROR_OUTAGE_CHANGED = 7;
/**
* The outage plugin is not enabled.
*/
const ERROR_PLUGIN_DISABLED = 8;
/**
* cliexception constructor.
* @param string $message An explanation of the exception.

View File

@@ -20,6 +20,7 @@ use coding_exception;
use core\session\manager;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/clilib.php');
/**
* Outage CLI base class.
@@ -47,7 +48,9 @@ abstract class clibase {
*/
public function __construct(array $options = null) {
global $CFG;
require_once($CFG->libdir.'/clilib.php');
if (!is_enabled_auth('outage')) {
throw new cli_exception(get_string('cliplugindisabled', 'auth_outage'), cli_exception::ERROR_PLUGIN_DISABLED);
}
$this->become_admin_user();