From 140062e0b606495f90fd77b8f290987844c79cab Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 29 Apr 2022 17:38:00 +0200 Subject: [locations/remoteaccess] Add option to veto remoteaccess mode Remoteaccess mode can now be forced to be disabled for individual locations in locations module, either unconditionally, or whenever the openingtimes schedule says the room is open. A reboot will be triggered whenever the room opens/closes to force clients into the proper runmode. --- modules-available/locations/pages/details.inc.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'modules-available/locations/pages/details.inc.php') diff --git a/modules-available/locations/pages/details.inc.php b/modules-available/locations/pages/details.inc.php index 86bfebd6..d2ec7b24 100644 --- a/modules-available/locations/pages/details.inc.php +++ b/modules-available/locations/pages/details.inc.php @@ -39,9 +39,10 @@ class SubPage $openingTimes = Request::post('openingtimes', Request::REQUIRED, 'string'); $locationid = Request::post('locationid', Request::REQUIRED, 'int'); $wol = Request::post('wol', false, 'bool'); - $woloffset = Request::post('wol-offset', 0, 'int'); + $wolOffset = Request::post('wol-offset', 0, 'int'); $sd = Request::post('sd', false, 'bool'); - $sdoffset = Request::post('sd-offset', 0, 'int'); + $sdOffset = Request::post('sd-offset', 0, 'int'); + $raMode = Request::post('ra-mode', 'ALWAYS', 'string'); User::assertPermission('location.edit.openingtimes', $locationid); @@ -93,7 +94,16 @@ class SubPage if (Module::isAvailable('rebootcontrol')) { // Set options - Scheduler::setLocationOptions($locationid, $wol, $sd, $woloffset, $sdoffset); + if (!Scheduler::isValidRaMode($raMode)) { + $raMode = Scheduler::RA_ALWAYS; + } + Scheduler::setLocationOptions($locationid, [ + 'wol' => $wol, + 'sd' => $sd, + 'wol-offset' => $wolOffset, + 'sd-offset' => $sdOffset, + 'ra-mode' => $raMode, + ]); } } @@ -396,7 +406,7 @@ class SubPage if (Module::get('rebootcontrol') !== false) { $res = Database::queryFirst("SELECT action, nextexecution FROM `reboot_scheduler` WHERE locationid = :id", ['id' => $locationId]); - if ($res !== false) { + if ($res !== false && $res['nextexecution'] > 0) { $data['next_action'] = $res['action']; $data['next_time'] = Util::prettyTime($res['nextexecution']); } @@ -431,12 +441,13 @@ class SubPage $data['rebootcontrol'] = $rebootcontrol; if ($rebootcontrol) { $data['scheduler-options'] = Scheduler::getLocationOptions($id); + $data['scheduler_' . $data['scheduler-options']['ra-mode'] . '_checked'] = 'checked'; } echo Render::parse('ajax-opening-location', $data); } - private static function isSimpleMode(&$array) + private static function isSimpleMode(&$array): bool { if (empty($array)) return true; -- cgit v1.2.3-55-g7522