From a96035be922c28664cb3784619a5d4ea7a839322 Mon Sep 17 00:00:00 2001 From: abhinavgandham Date: Wed, 14 Jan 2026 12:00:01 +1000 Subject: [PATCH 1/4] Issue #390: Changed outage auto-start default parameter from checkbox to dropdown with option to fully disable. --- lang/en/auth_outage.php | 3 +++ settings.php | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lang/en/auth_outage.php b/lang/en/auth_outage.php index 470c44e..64257dc 100644 --- a/lang/en/auth_outage.php +++ b/lang/en/auth_outage.php @@ -32,6 +32,8 @@ $string['allowedipsnoconfig'] = 'Your config.php does not have the extra setup t $string['auth_outagedescription'] = 'Auxiliary plugin that warns users about a future outage and prevents them from logging in once the outage starts.'; $string['autostart'] = 'Auto start maintenance mode.'; $string['autostart_help'] = 'If selected, when the outage starts it will automatically turn on Moodle maintenance mode.'; +$string['autostartoff'] = 'Default off'; +$string['autostarton'] = 'Default on'; $string['builtinallowediplist'] = 'Builtin Allowed IP List'; $string['builtinallowediplist_desc'] = 'A second allowed IP list which makes it easier to have some IPs forced in config.php and others editable in the UI'; $string['clicreateexamples'] = "Create an outage starting in 10 seconds\n\n> php create.php -s=10"; @@ -99,6 +101,7 @@ $string['defaultwarningdurationdescription'] = 'Default warning time (in minutes $string['description'] = 'Public Description'; $string['description_help'] = 'A full description of the outage, publicly visible by all users.'; $string['finish'] = 'Finish'; +$string['forceoff'] = 'Force off'; $string['info15secondsbefore'] = '15 seconds before'; $string['infoendofoutage'] = 'end of outage'; $string['infofrom'] = 'From:'; diff --git a/settings.php b/settings.php index 870dba6..c905def 100644 --- a/settings.php +++ b/settings.php @@ -43,11 +43,16 @@ if ($hassiteconfig) { get_string('settingssectiondefaultsdescription', 'auth_outage') . $description )); - $settings->add(new admin_setting_configcheckbox( + $settings->add(new admin_setting_configselect( 'auth_outage/default_autostart', get_string('defaultoutageautostart', 'auth_outage'), get_string('defaultoutageautostartdescription', 'auth_outage'), - $defaults['default_autostart'] + 'off', + [ + '0' => get_string('autostartoff', 'auth_outage'), + '1' => get_string('autostarton', 'auth_outage'), + '2' => get_string('forceoff', 'auth_outage'), + ] )); $settings->add(new admin_setting_configduration( From a32c923aaa6f999376741ee32d08d9bd4d94858b Mon Sep 17 00:00:00 2001 From: abhinavgandham Date: Thu, 15 Jan 2026 13:55:43 +1000 Subject: [PATCH 2/4] Included logic for 'Force off' setting. --- classes/dml/outagedb.php | 6 ++++++ classes/form/outage/edit.php | 7 +++++-- classes/local/outagelib.php | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/classes/dml/outagedb.php b/classes/dml/outagedb.php index 9126159..1bab0a5 100644 --- a/classes/dml/outagedb.php +++ b/classes/dml/outagedb.php @@ -100,6 +100,12 @@ class outagedb { $outage->modifiedby = $USER->id; $outage->lastmodified = time(); + // Setting autostart to false if the default autostart is configured to "Force off". + if (get_config('default_autostart', 'auth_outage') === '2') { + $outage->autostart = 0; + } + + if ($outage->id === null) { // If new outage, set its creator. $outage->createdby = $USER->id; diff --git a/classes/form/outage/edit.php b/classes/form/outage/edit.php index 60e3276..4fbcac8 100644 --- a/classes/form/outage/edit.php +++ b/classes/form/outage/edit.php @@ -48,8 +48,11 @@ class edit extends moodleform { $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); - $mform->addElement('checkbox', 'autostart', get_string('autostart', 'auth_outage')); - $mform->addHelpButton('autostart', 'autostart', 'auth_outage'); + + if (get_config('auth_outage', 'default_autostart') !== '2') { + $mform->addElement('checkbox', 'autostart', get_string('autostart', 'auth_outage')); + $mform->addHelpButton('autostart', 'autostart', 'auth_outage'); + } $mform->addElement('duration', 'warningduration', get_string('warningduration', 'auth_outage')); $mform->addHelpButton('warningduration', 'warningduration', 'auth_outage'); diff --git a/classes/local/outagelib.php b/classes/local/outagelib.php index c6943ae..0316ef5 100644 --- a/classes/local/outagelib.php +++ b/classes/local/outagelib.php @@ -223,7 +223,7 @@ class outagelib { * @param outage|null $outage Outage or null if no scheduled outage. */ private static function update_maintenance_later($outage) { - if (is_null($outage) || !$outage->autostart) { + if (is_null($outage) || !$outage->autostart || get_config('default_autostart', 'auth_outage') === '2') { unset_config('maintenance_later'); } else { $message = get_config('moodle', 'maintenance_message'); From fdd556932437d652559c7bb7b9cb3d2116849277 Mon Sep 17 00:00:00 2001 From: abhinavgandham Date: Thu, 15 Jan 2026 14:10:23 +1000 Subject: [PATCH 3/4] Formatting fixes. --- classes/dml/outagedb.php | 1 - classes/form/outage/edit.php | 1 - 2 files changed, 2 deletions(-) diff --git a/classes/dml/outagedb.php b/classes/dml/outagedb.php index 1bab0a5..6d78b86 100644 --- a/classes/dml/outagedb.php +++ b/classes/dml/outagedb.php @@ -105,7 +105,6 @@ class outagedb { $outage->autostart = 0; } - if ($outage->id === null) { // If new outage, set its creator. $outage->createdby = $USER->id; diff --git a/classes/form/outage/edit.php b/classes/form/outage/edit.php index 4fbcac8..3393396 100644 --- a/classes/form/outage/edit.php +++ b/classes/form/outage/edit.php @@ -48,7 +48,6 @@ class edit extends moodleform { $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); - if (get_config('auth_outage', 'default_autostart') !== '2') { $mform->addElement('checkbox', 'autostart', get_string('autostart', 'auth_outage')); $mform->addHelpButton('autostart', 'autostart', 'auth_outage'); From a8d496121f812b368bd4db2f46770672c35850e9 Mon Sep 17 00:00:00 2001 From: abhinavgandham Date: Thu, 15 Jan 2026 16:31:58 +1000 Subject: [PATCH 4/4] Fixed default parameter in configselect and updated 'Force off' lang string. --- lang/en/auth_outage.php | 2 +- settings.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lang/en/auth_outage.php b/lang/en/auth_outage.php index 64257dc..b0f3d89 100644 --- a/lang/en/auth_outage.php +++ b/lang/en/auth_outage.php @@ -34,6 +34,7 @@ $string['autostart'] = 'Auto start maintenance mode.'; $string['autostart_help'] = 'If selected, when the outage starts it will automatically turn on Moodle maintenance mode.'; $string['autostartoff'] = 'Default off'; $string['autostarton'] = 'Default on'; +$string['autostartforcedoff'] = 'Force off'; $string['builtinallowediplist'] = 'Builtin Allowed IP List'; $string['builtinallowediplist_desc'] = 'A second allowed IP list which makes it easier to have some IPs forced in config.php and others editable in the UI'; $string['clicreateexamples'] = "Create an outage starting in 10 seconds\n\n> php create.php -s=10"; @@ -101,7 +102,6 @@ $string['defaultwarningdurationdescription'] = 'Default warning time (in minutes $string['description'] = 'Public Description'; $string['description_help'] = 'A full description of the outage, publicly visible by all users.'; $string['finish'] = 'Finish'; -$string['forceoff'] = 'Force off'; $string['info15secondsbefore'] = '15 seconds before'; $string['infoendofoutage'] = 'end of outage'; $string['infofrom'] = 'From:'; diff --git a/settings.php b/settings.php index c905def..eeb10f0 100644 --- a/settings.php +++ b/settings.php @@ -47,11 +47,11 @@ if ($hassiteconfig) { 'auth_outage/default_autostart', get_string('defaultoutageautostart', 'auth_outage'), get_string('defaultoutageautostartdescription', 'auth_outage'), - 'off', + '0', [ '0' => get_string('autostartoff', 'auth_outage'), '1' => get_string('autostarton', 'auth_outage'), - '2' => get_string('forceoff', 'auth_outage'), + '2' => get_string('autostartforcedoff', 'auth_outage'), ] ));