From e88a313149cb39e187baf74a2fc18cc7c5d86d81 Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Thu, 30 Nov 2017 12:59:49 +0100 Subject: [locationinfo] Reworked summary-panel to the new panel uuid stuff. --- .../locationinfo/inc/infopanel.inc.php | 3 + .../locationinfo/inc/locationinfo.inc.php | 76 +++++++++++++++++----- 2 files changed, 63 insertions(+), 16 deletions(-) (limited to 'modules-available/locationinfo/inc') diff --git a/modules-available/locationinfo/inc/infopanel.inc.php b/modules-available/locationinfo/inc/infopanel.inc.php index c612e518..dacf860f 100644 --- a/modules-available/locationinfo/inc/infopanel.inc.php +++ b/modules-available/locationinfo/inc/infopanel.inc.php @@ -20,6 +20,7 @@ class InfoPanel } if ($panel['paneltype'] === 'URL') { + // Shortcut for URL redirect $config = json_decode($panel['panelconfig'], true); return $panel['paneltype']; } @@ -31,6 +32,7 @@ class InfoPanel if (!empty($panel['panelconfig'])) { $json = json_decode($panel['panelconfig'], true); if (is_array($json)) { + // Put location-specific overrides in separate variable for later use if (isset($json['overrides']) && is_array($json['overrides'])) { $overrides = $json['overrides']; } @@ -48,6 +50,7 @@ class InfoPanel 'id' => $lid, 'name' => isset($locations[$lid]) ? $locations[$lid]['locationname'] : 'noname00.pas', ); + // Now apply any overrides from above if (isset($overrides[$lid]) && is_array($overrides[$lid])) { $config['locations'][$lid]['config'] = $overrides[$lid]; } diff --git a/modules-available/locationinfo/inc/locationinfo.inc.php b/modules-available/locationinfo/inc/locationinfo.inc.php index 933eaf4d..64070cd4 100644 --- a/modules-available/locationinfo/inc/locationinfo.inc.php +++ b/modules-available/locationinfo/inc/locationinfo.inc.php @@ -22,6 +22,32 @@ class LocationInfo 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(); + + foreach ($idList as $key => $value) { + $idArray[] = $key; + } + } + return $idArray; + } + http_response_code(404); + die('Panel not found'); + } + /** * Set current error message of given server. Pass null or false to clear. * @@ -47,27 +73,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(); } /** @@ -81,6 +118,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', @@ -98,6 +141,7 @@ 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); } -- cgit v1.2.3-55-g7522