diff options
author | Jannik Schönartz | 2017-12-14 13:03:44 +0100 |
---|---|---|
committer | Jannik Schönartz | 2017-12-14 13:03:44 +0100 |
commit | 5d5c2f27bee5d4fbd3747555efbf2ac9f337805b (patch) | |
tree | c65898e1b3d6f0f46366a280bbbaf4c6ccbc477c /modules-available/locationinfo/inc/locationinfo.inc.php | |
parent | [usb-lock-off] Design changes to fit the design_guidelines. TODO: lang_discar... (diff) | |
parent | [sysconfig] Update translations (diff) | |
download | slx-admin-5d5c2f27bee5d4fbd3747555efbf2ac9f337805b.tar.gz slx-admin-5d5c2f27bee5d4fbd3747555efbf2ac9f337805b.tar.xz slx-admin-5d5c2f27bee5d4fbd3747555efbf2ac9f337805b.zip |
Merge branch 'master' into usb-lock-off
Diffstat (limited to 'modules-available/locationinfo/inc/locationinfo.inc.php')
-rw-r--r-- | modules-available/locationinfo/inc/locationinfo.inc.php | 86 |
1 files changed, 61 insertions, 25 deletions
diff --git a/modules-available/locationinfo/inc/locationinfo.inc.php b/modules-available/locationinfo/inc/locationinfo.inc.php index a5feb9ed..2ed3622d 100644 --- a/modules-available/locationinfo/inc/locationinfo.inc.php +++ b/modules-available/locationinfo/inc/locationinfo.inc.php @@ -6,7 +6,7 @@ class LocationInfo /** * Gets the pc data and returns it's state. * - * @param array $pc The pc data from the db. Array('logintime' =>, 'lastseen' =>, 'lastboot' =>) + * @param array $pc The pc data from the db. Array('state' => xx, 'lastseen' => xxx) * @return int pc state */ public static function getPcState($pc) @@ -16,16 +16,32 @@ class LocationInfo $lastboot = (int)$pc['lastboot']; $NOW = time(); - if ($NOW - $lastseen > 14 * 86400) { + if ($pc['state'] === 'OFFLINE' && $NOW - $lastseen > 21 * 86400) { return "BROKEN"; - } elseif (($NOW - $lastseen > 610) || $lastboot === 0) { - return "OFF"; - } elseif ($logintime === 0) { - return "IDLE"; - } elseif ($logintime > 0) { - return "OCCUPIED"; } - return -1; + return $pc['state']; + } + + /** + * Return list of locationids associated with given panel. + * @param string $paneluuid panel + * @param bool $recursive if true and paneltype == SUMMARY the result is recursive with all child room ids. + * @return int[] locationIds + */ + public static function getLocationsOr404($paneluuid, $recursive = true) + { + $panel = Database::queryFirst('SELECT paneltype, locationids FROM locationinfo_panel WHERE paneluuid = :paneluuid', + compact('paneluuid')); + if ($panel !== false) { + $idArray = array_map('intval', explode(',', $panel['locationids'])); + if ($panel['paneltype'] == "SUMMARY" && $recursive) { + $idList = Location::getRecursiveFlat($idArray); + $idArray = array_keys($idList); + } + return $idArray; + } + http_response_code(404); + die('Panel not found'); } /** @@ -53,27 +69,38 @@ class LocationInfo } /** - * Creates and returns a default config for room that didn't saved a config yet. + * Creates and returns a default config for room that didn't save a config yet. * * @return array Return a default config. */ public static function defaultPanelConfig($type) { - return array( - 'language' => 'en', - 'mode' => 1, - 'vertical' => false, - 'eco' => false, - 'prettytime' => true, - 'scaledaysauto' => true, - 'daystoshow' => 7, - 'rotation' => 0, - 'scale' => 50, - 'switchtime' => 20, - 'calupdate' => 30, - 'roomupdate' => 15, - 'configupdate' => 180, - ); + if ($type === 'DEFAULT') { + return array( + 'language' => 'en', + 'mode' => 1, + 'vertical' => false, + 'eco' => false, + 'prettytime' => true, + 'scaledaysauto' => true, + 'daystoshow' => 7, + 'rotation' => 0, + 'scale' => 50, + 'switchtime' => 20, + 'calupdate' => 30, + 'roomupdate' => 15, + 'configupdate' => 180, + ); + } + if ($type === 'SUMMARY') { + return array( + 'language' => 'en', + 'calupdate' => 30, + 'roomupdate' => 15, + 'configupdate' => 180, + ); + } + return array(); } /** @@ -87,6 +114,12 @@ class LocationInfo return $ret['panelname']; } + /** + * Hook called by runmode module where we should modify the client config according to our + * needs. Disable standby/logout timeouts, enable autologin, set URL. + * @param $machineUuid + * @param $panelUuid + */ public static function configHook($machineUuid, $panelUuid) { $row = Database::queryFirst('SELECT paneltype, panelconfig FROM locationinfo_panel WHERE paneluuid = :uuid', @@ -104,6 +137,9 @@ class LocationInfo ConfigHolder::add('SLX_ADDONS', '', 1000); ConfigHolder::add('SLX_LOGOUT_TIMEOUT', '', 1000); ConfigHolder::add('SLX_SCREEN_STANDBY_TIMEOUT', '', 1000); + ConfigHolder::add('SLX_SYSTEM_STANDBY_TIMEOUT', '', 1000); + ConfigHolder::add('SLX_AUTOLOGIN', '1', 1000); + ConfigHolder::add('SLX_BROWSER_INSECURE', '1'); // TODO: Sat server might redirect to HTTPS, which in turn could have a self-signed cert - push to client } } |