summaryrefslogtreecommitdiffstats
path: root/modules-available/locations/pages
diff options
context:
space:
mode:
authorChristian Hofmaier2021-03-16 20:03:58 +0100
committerChristian Hofmaier2021-03-16 20:03:58 +0100
commit834b95629832fc3735756727b6c7cb1826d0e9d8 (patch)
treeff465ef0063c59d92f8c77e89f15a2a7a2405977 /modules-available/locations/pages
parent[sysconfig] yes -> true (diff)
downloadslx-admin-834b95629832fc3735756727b6c7cb1826d0e9d8.tar.gz
slx-admin-834b95629832fc3735756727b6c7cb1826d0e9d8.tar.xz
slx-admin-834b95629832fc3735756727b6c7cb1826d0e9d8.zip
[rebootcontrol] Handle scheduler overlaps
- Overlaps < 5 min are ignored, < 15 triggers reboot - Database: Make 1 line out of 2
Diffstat (limited to 'modules-available/locations/pages')
-rw-r--r--modules-available/locations/pages/details.inc.php34
1 files changed, 13 insertions, 21 deletions
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);