diff --git a/classes/form/outage/edit.php b/classes/form/outage/edit.php index d27d77d..10b44e2 100644 --- a/classes/form/outage/edit.php +++ b/classes/form/outage/edit.php @@ -147,7 +147,7 @@ class edit extends moodleform { * @throws coding_exception */ public function set_data($outage) { - global $OUTPUT; + global $OUTPUT, $CFG; $mform = $this->_form; // Cannot change method signature, check type. @@ -162,6 +162,15 @@ class edit extends moodleform { 'description' => ['text' => $outage->description, 'format' => '1'], ]); + // If the default_autostart is configured in config, then force autostart to be the default value. + if (array_key_exists('auth_outage', $CFG->forced_plugin_settings) + && array_key_exists('default_autostart', $CFG->forced_plugin_settings['auth_outage'])){ + $this->_form->setDefaults([ + 'autostart' => $CFG->forced_plugin_settings['auth_outage']['default_autostart'] + ]); + $mform->freeze('autostart'); + } + if (!empty($outage->id) && $outage->autostart && $outage->starttime < time() && $outage->stoptime > time()) { $warning = $mform->getElement('warningreenablemaintenancemode'); $warning->setValue($OUTPUT->notification(get_string('warningreenablemaintenancemode', 'auth_outage'),