diff options
author | Jannik Schönartz | 2017-04-03 16:26:09 +0200 |
---|---|---|
committer | Jannik Schönartz | 2017-04-03 16:26:09 +0200 |
commit | 8ca62082650303c9a7e181919f3d6fd69098b54c (patch) | |
tree | c68660ac017469dc3c7bef2acc17ef4bbe9fd930 /modules-available/locationinfo/api.inc.php | |
parent | Debug befehle entfernt (diff) | |
download | slx-admin-8ca62082650303c9a7e181919f3d6fd69098b54c.tar.gz slx-admin-8ca62082650303c9a7e181919f3d6fd69098b54c.tar.xz slx-admin-8ca62082650303c9a7e181919f3d6fd69098b54c.zip |
Added a default config for rooms that have not saved a config yet.
Diffstat (limited to 'modules-available/locationinfo/api.inc.php')
-rw-r--r-- | modules-available/locationinfo/api.inc.php | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php index 319dc3a5..f3b99e45 100644 --- a/modules-available/locationinfo/api.inc.php +++ b/modules-available/locationinfo/api.inc.php @@ -297,20 +297,43 @@ function getConfig($locationID) WHERE l.locationid=:locationID", array('locationID' => $locationID)); $config = array(); - $config = json_decode($dbresult['config'], true); - $config['room'] = $dbresult['locationname']; - $date = getdate(); - $config['time'] = $date['year'] . "-" . $date['mon'] . "-" . $date['mday'] . " " . $date['hours'] . ":" . $date['minutes'] . ":" . $date['seconds']; + if ($dbresult['locationname'] == null) { + $config = array(); + } else { - if ($dbresult['servertype'] === "Frontend") { - $config['calendarqueryurl'] = $dbresult['serverurl'] . "/" . $dbresult['serverroomid'] . ".json"; - } + if ($dbresult['config'] == null) { + defaultConfig($config); + } else { + $config = json_decode($dbresult['config'], true); + } - if (empty($config)) { - echo json_encode(array()); - } else { - echo json_encode($config, JSON_UNESCAPED_SLASHES); + $config['room'] = $dbresult['locationname']; + $date = getdate(); + $config['time'] = $date['year'] . "-" . $date['mon'] . "-" . $date['mday'] . " " . $date['hours'] . ":" . $date['minutes'] . ":" . $date['seconds']; } + echo json_encode($config, true); +} + +/** + * Creates and returns a default config for room that didn't saved a config yet. + * + * @return Return a default config. + */ +function defaultConfig(&$config) { + $config['language'] = 'en'; + $config['mode'] = 1; + $config['vertical'] = false; + $config['eco'] = false; + $config['scaledaysauto'] = true; + $config['daystoshow'] = 7; + $config['rotation'] = 0; + $config['scale'] = 50; + $config['switchtime'] = 20; + $config['calupdate'] = 30; + $config['roomupdate'] = 5; + $config['configupdate'] = 180; + + return $config; } /** |