mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-05-16 21:41:31 +02:00
Show warning if outage editing will trigger re-enabling maintenance mode #172.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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.<br />Untick "Auto start maintenance mode" if you want to prevent this.';
|
||||
|
||||
/*
|
||||
* Privacy provider (GDPR)
|
||||
|
||||
Reference in New Issue
Block a user