mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-05-16 21:41:31 +02:00
Added next 3 available window button for new outages #163
This commit is contained in:
@@ -164,7 +164,8 @@ class edit extends moodleform {
|
||||
|
||||
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'), 'notifywarning'));
|
||||
$warning->setValue($OUTPUT->notification(get_string('warningreenablemaintenancemode', 'auth_outage'),
|
||||
'notifywarning'));
|
||||
}
|
||||
} else {
|
||||
throw new coding_exception('$outage must be an outage object.', $outage);
|
||||
|
||||
@@ -79,6 +79,40 @@ class outagelib {
|
||||
self::inject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a time, usually now, when is the next outage window?
|
||||
*/
|
||||
public static function get_next_window($time = null) {
|
||||
|
||||
$config = self::get_config();
|
||||
|
||||
if (!$time) {
|
||||
$time = time();
|
||||
}
|
||||
|
||||
$default = $config->default_time;
|
||||
if ($default) {
|
||||
|
||||
// First try natural language parsing.
|
||||
$time = strtotime($default, $time);
|
||||
|
||||
// Lean on the Task API to convert the cron syntax to
|
||||
// the next valid outage date and time.
|
||||
$parts = explode(' ', $default);
|
||||
if (count($parts) == 5) {
|
||||
$task = new \core\task\calendar_cron_task();
|
||||
$task->set_minute($parts[0]);
|
||||
$task->set_hour($parts[1]);
|
||||
$task->set_day($parts[2]);
|
||||
$task->set_month($parts[3]);
|
||||
$task->set_day_of_week($parts[4]);
|
||||
$time = $task->get_next_scheduled_time();
|
||||
}
|
||||
}
|
||||
return $time;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Will check for ongoing or warning outages and will attach the message bar as required.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user