diff --git a/classes/form/outage/edit.php b/classes/form/outage/edit.php index 11ff166..96edaa2 100644 --- a/classes/form/outage/edit.php +++ b/classes/form/outage/edit.php @@ -82,8 +82,6 @@ class edit extends moodleform { $mform->addHelpButton('description', 'description', 'auth_outage'); $mform->addElement('static', 'usagehints', '', get_string('textplaceholdershint', 'auth_outage')); - - $this->add_action_buttons(); } /** @@ -146,6 +144,8 @@ class edit extends moodleform { * @throws coding_exception */ public function set_data($outage) { + global $OUTPUT; + // Cannot change method signature, check type. if ($outage instanceof outage) { $this->_form->setDefaults([ @@ -157,6 +157,14 @@ class edit extends moodleform { 'title' => $outage->title, 'description' => ['text' => $outage->description, 'format' => '1'], ]); + + if (!empty($outage->id) && $outage->autostart && $outage->starttime < time() && + $outage->stoptime > time()) { + $this->_form->addElement('html', + $OUTPUT->notification(get_string('warningreenablemaintenancemode', 'auth_outage'), 'notifywarning')); + } + + $this->add_action_buttons(); } else { throw new coding_exception('$outage must be an outage object.', $outage); } diff --git a/lang/en/auth_outage.php b/lang/en/auth_outage.php index dde625c..6b5f497 100644 --- a/lang/en/auth_outage.php +++ b/lang/en/auth_outage.php @@ -143,6 +143,7 @@ $string['title_help'] = 'A short title to for this outage. It will be displayed $string['warningdurationerrorinvalid'] = 'Warning duration must be positive.'; $string['warningduration'] = 'Warning duration'; $string['warningduration_help'] = 'How long before the start of the outage should the warning be displayed.'; +$string['warningreenablemaintenancemode'] = 'Please note that saving this outage will re-enable maintenance mode.
Untick "Auto start maintenance mode" if you want to prevent this.'; /* * Privacy provider (GDPR)