summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/api.inc.php
diff options
context:
space:
mode:
authorJannik Schönartz2017-04-03 16:26:09 +0200
committerJannik Schönartz2017-04-03 16:26:09 +0200
commit8ca62082650303c9a7e181919f3d6fd69098b54c (patch)
treec68660ac017469dc3c7bef2acc17ef4bbe9fd930 /modules-available/locationinfo/api.inc.php
parentDebug befehle entfernt (diff)
downloadslx-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.php45
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;
}
/**