diff --git a/classes/local/cli/cli_exception.php b/classes/local/cli/cli_exception.php index c2f1b47..2b7a447 100644 --- a/classes/local/cli/cli_exception.php +++ b/classes/local/cli/cli_exception.php @@ -78,6 +78,11 @@ class cli_exception extends Exception { */ const ERROR_PLUGIN_DISABLED = 8; + /** + * Moodle maintenance mode is enabled. + */ + const ERROR_MAINTENANCE_MODE = 9; + /** * cliexception constructor. * @param string $message An explanation of the exception. diff --git a/classes/local/cli/finish.php b/classes/local/cli/finish.php index e00b2fb..ee8d832 100644 --- a/classes/local/cli/finish.php +++ b/classes/local/cli/finish.php @@ -46,9 +46,9 @@ class finish extends clibase { public function generate_options() { // Do not provide some defaults, if cloning an outage we need to know which parameters were provided. $options = [ - 'help' => false, + 'help' => false, 'outageid' => null, - 'active' => false, + 'active' => false, ]; return $options; } @@ -59,9 +59,9 @@ class finish extends clibase { */ public function generate_shortcuts() { return [ - 'h' => 'help', + 'h' => 'help', 'id' => 'outageid', - 'a' => 'active', + 'a' => 'active', ]; } @@ -75,6 +75,12 @@ class finish extends clibase { return; } + // Cannot run during CLI_MAINTENANCE mode. + if (CLI_MAINTENANCE) { + throw new cli_exception(get_string('cliinmaintenancemode', 'auth_outage'), + cli_exception::ERROR_MAINTENANCE_MODE); + } + // Requires outageid or active but not both at the same time. $byid = !is_null($this->options['outageid']); $byactive = $this->options['active']; diff --git a/lang/en/auth_outage.php b/lang/en/auth_outage.php index d6a20f3..887b6c2 100644 --- a/lang/en/auth_outage.php +++ b/lang/en/auth_outage.php @@ -42,6 +42,7 @@ $string['clifinishnotongoing'] = 'Outage is not ongoing.'; $string['clifinishparamhelp'] = 'shows parameters help.'; $string['clifinishparamactive'] = 'finishes the currently active outage.'; $string['clifinishparamoutageid'] = 'the id of the outage to finish.'; +$string['cliinmaintenancemode'] = 'Moodle maintenance mode is on. Use "admin/cli/maintenance.php --disable" to disable it before finishing the outage.'; $string['cliplugindisabled'] = 'The authentication plugin \'Outage\' is disabled. Please enable it in the site administration it and try again.'; $string['cliwaitforiterroridxoractive'] = 'You must use --outageid=# or --active parameter but not both.'; $string['cliwaitforithelp'] = 'Waits until an outage starts.';