summaryrefslogtreecommitdiffstats
path: root/modules-available/locations/pages/details.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/locations/pages/details.inc.php')
-rw-r--r--modules-available/locations/pages/details.inc.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/modules-available/locations/pages/details.inc.php b/modules-available/locations/pages/details.inc.php
index a55460cf..81c2f2fa 100644
--- a/modules-available/locations/pages/details.inc.php
+++ b/modules-available/locations/pages/details.inc.php
@@ -36,6 +36,10 @@ class SubPage
private static function updateOpeningTimes() {
$openingTimes = Request::post('openingtimes', '', 'string');
$locationid = Request::post('locationid', false, 'int');
+ $wol = Request::post('wol', false, 'bool');
+ $woloffset = Request::post('wol-offset', 0, 'int');
+ $sd = Request::post('sd', false, 'bool');
+ $sdoffset = Request::post('sd-offset', 0, 'int');
User::assertPermission('location.edit', $locationid);
@@ -83,6 +87,29 @@ class SubPage
Database::exec('UPDATE location SET openingtime = :openingtime WHERE locationid = :locationid',
array('locationid' => $locationid, 'openingtime' => $openingTimes));
+ if (Module::isAvailable('rebootcontrol')) {
+ if ($wol) {
+ $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;
+ $options['sd-offset'] = $sdoffset;
+ Scheduler::updateSchedule($locationid, 'sd', $options, $openingTimes);
+ } else {
+ Scheduler::deleteSchedule($locationid, 'sd');
+ }
+ }
+
return true;
}
@@ -394,6 +421,21 @@ class SubPage
$data['expertMode'] = !self::isSimpleMode($openingTimes);
$data['schedule_data'] = json_encode($openingTimes);
+ $rebootcontrol = Module::isAvailable('rebootcontrol');
+ $data['rebootcontrol'] = $rebootcontrol;
+ if ($rebootcontrol) {
+ $wol = Database::queryFirst("SELECT options FROM `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 `scheduler` WHERE locationid = :id AND action = 'sd'", array('id' => $id));
+ if ($sd !== false) {
+ $data['sd'] = true;
+ $data['sd-options'] = json_decode($sd['options']);
+ }
+ }
+
echo Render::parse('ajax-opening-location', $data);
}