From 834b95629832fc3735756727b6c7cb1826d0e9d8 Mon Sep 17 00:00:00 2001 From: Christian Hofmaier Date: Tue, 16 Mar 2021 20:03:58 +0100 Subject: [rebootcontrol] Handle scheduler overlaps - Overlaps < 5 min are ignored, < 15 triggers reboot - Database: Make 1 line out of 2 --- modules-available/locations/pages/details.inc.php | 34 +++++++++-------------- 1 file changed, 13 insertions(+), 21 deletions(-) (limited to 'modules-available/locations/pages') diff --git a/modules-available/locations/pages/details.inc.php b/modules-available/locations/pages/details.inc.php index 2f444157..fd45646b 100644 --- a/modules-available/locations/pages/details.inc.php +++ b/modules-available/locations/pages/details.inc.php @@ -89,25 +89,25 @@ class SubPage array('locationid' => $locationid, 'openingtime' => $openingTimes)); if (Module::isAvailable('rebootcontrol')) { - if ($wol) { + if ($wol || $sd) { $options = array(); + // Sanity checks if ($woloffset > 15) $woloffset = 15; else if ($woloffset < 0) $woloffset = 0; - $options['wol-offset'] = $woloffset; - Scheduler::updateSchedule($locationid, 'wol', $options, $openingTimes); - } else { - Scheduler::deleteSchedule($locationid, 'wol'); - } - if ($sd) { - $options = array(); - // Sanity checks if ($sdoffset > 15) $sdoffset = 15; else if ($sdoffset < 0) $sdoffset = 0; + + // Set options + $options['wol'] = $wol; + $options['wol-offset'] = $woloffset; + $options['sd'] = $sd; $options['sd-offset'] = $sdoffset; - Scheduler::updateSchedule($locationid, 'sd', $options, $openingTimes); + + Scheduler::updateSchedule($locationid, $options, $openingTimes); + } else { - Scheduler::deleteSchedule($locationid, 'sd'); + Scheduler::deleteSchedule($locationid); } } } @@ -423,16 +423,8 @@ class SubPage $rebootcontrol = Module::isAvailable('rebootcontrol'); $data['rebootcontrol'] = $rebootcontrol; if ($rebootcontrol) { - $wol = Database::queryFirst("SELECT options FROM `reboot_scheduler` WHERE locationid = :id AND action = 'wol'", array('id' => $id)); - if ($wol !== false) { - $data['wol'] = true; - $data['wol-options'] = json_decode($wol['options']); - } - $sd = Database::queryFirst("SELECT options FROM `reboot_scheduler` WHERE locationid = :id AND action = 'sd'", array('id' => $id)); - if ($sd !== false) { - $data['sd'] = true; - $data['sd-options'] = json_decode($sd['options']); - } + $res = Database::queryFirst("SELECT * FROM `reboot_scheduler` WHERE locationid = :id", array('id' => $id)); + if ($res !== false) $data['scheduler-options'] = json_decode($res['options']); } echo Render::parse('ajax-opening-location', $data); -- cgit v1.2.3-55-g7522