mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-10-22 18:18:07 +02:00
Allow default start time using cron syntax #163
This commit is contained in:
1 parent
e6a63f02e6
commit
3b1b1ea0e1
5 files changed
+30
-2
No files matched your search
@@ -61,6 +61,24 @@ if ($clone) {
|
||||
} else {
|
||||
$config = outagelib::get_config();
|
||||
$time = time();
|
||||
|
||||
$default = $config->default_time;
|
||||
if ($default) {
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
||||
$outage = new outage([
|
||||
'autostart' => $config->default_autostart,
|
||||
'starttime' => $time,
|
||||
|
||||
Reference in new issue
Block a user