diff options
author | Michael Scherle | 2017-04-03 23:01:14 +0200 |
---|---|---|
committer | Michael Scherle | 2017-04-03 23:01:14 +0200 |
commit | 0b80dd9203d44a380bc1df36faece4b12ba8f4e9 (patch) | |
tree | 9d3f08babeddbbec71fe716f763bfa3b14033092 /modules-available/locationinfo | |
parent | frontend fixed switchtime not working (diff) | |
parent | Added a default config for rooms that have not saved a config yet. (diff) | |
download | slx-admin-0b80dd9203d44a380bc1df36faece4b12ba8f4e9.tar.gz slx-admin-0b80dd9203d44a380bc1df36faece4b12ba8f4e9.tar.xz slx-admin-0b80dd9203d44a380bc1df36faece4b12ba8f4e9.zip |
Merge branch 'location-info-panel' of git.openslx.org:openslx-ng/slx-admin into location-info-panel
Diffstat (limited to 'modules-available/locationinfo')
4 files changed, 72 insertions, 16 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; } /** diff --git a/modules-available/locationinfo/inc/coursebackend.inc.php b/modules-available/locationinfo/inc/coursebackend.inc.php index 74af45ff..e14e9443 100644 --- a/modules-available/locationinfo/inc/coursebackend.inc.php +++ b/modules-available/locationinfo/inc/coursebackend.inc.php @@ -128,7 +128,7 @@ abstract class CourseBackend * @param $roomIds array with local ID as key and serverID as value * @return array a recursive array that uses the roomID as key * and has the schedule array as value. A shedule array contains an array in this format: - * {"start"=>'JJJJ-MM-DD HH:MM:SS',"end"=>'JJJJ-MM-DD HH:MM:SS',"title"=>string} + * ["start"=>'JJJJ-MM-DD HH:MM:SS',"end"=>'JJJJ-MM-DD HH:MM:SS',"title"=>string] */ protected abstract function fetchSchedulesInternal($roomId); diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php index b8aa44a0..482ca097 100644 --- a/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php +++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php @@ -2,6 +2,15 @@ class Coursebackend_Dummy extends CourseBackend { private $pw; + /** + * uses json to setCredentials, the json must follow the form given in + * getCredentials + * + * @param array $data with the credentials + * @param string $url address of the server + * @param int $serverID ID of the server + * @returns bool if the credentials were in the correct format + */ public function setCredentials($json,$location,$serverID) { $x = $json; $this->pw = $x['password']; @@ -16,6 +25,9 @@ class Coursebackend_Dummy extends CourseBackend { } } + /** + * @return boolean true if the connection works, false otherwise + */ public function checkConnection(){ if ($this->pw == "mfg") { $this->error = false; @@ -27,24 +39,43 @@ class Coursebackend_Dummy extends CourseBackend { } } + /** + * @returns array with parameter name as key and and an array with type, help text and mask as value + */ public function getCredentials(){ $options = ["opt1", "opt2", "opt3", "opt4", "opt5", "opt6", "opt7", "opt8"]; $credentials = ["username" => "string","password"=>"password","integer"=>"int","option"=>$options,"CheckTheBox" =>"bool","CB2 t" =>"bool"]; return $credentials; } + /** + * @return string return display name of backend + */ public function getDisplayName(){ return'Dummy with array'; } - + /** + * @return int desired caching time of results, in seconds. 0 = no caching + */ public function getCacheTime(){ return 0; } - + /** + * @return int age after which timetables are no longer refreshed should be + * greater then CacheTime + */ public function getRefreshTime(){ return 0; } + /** + * Internal version of fetch, to be overridden by subclasses. + * + * @param $roomIds array with local ID as key and serverID as value + * @return array a recursive array that uses the roomID as key + * and has the schedule array as value. A shedule array contains an array in this format: + * ["start"=>'JJJJ-MM-DD HH:MM:SS',"end"=>'JJJJ-MM-DD HH:MM:SS',"title"=>string] + */ public function fetchSchedulesInternal($roomId){ $a = array(); foreach ($roomId as $id) { diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php index 4333f0a8..ee79cec9 100644 --- a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php +++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php @@ -79,8 +79,10 @@ class CourseBackend_HisInOne extends CourseBackend $body->appendChild($findUnit); $termYearN = $doc->createElement('termYear', $termYear); $findUnit->appendChild($termYearN); - $termTypeValueId = $doc->createElement('termTypeValueId', $termType); - $findUnit->appendChild($termTypeValueId); + if($termType1 !=3 && $termType1 != 10){ + $termTypeValueId = $doc->createElement('termTypeValueId', $termType); + $findUnit->appendChild($termTypeValueId); + } $roomIdN = $doc->createElement('ns1:roomId', $roomID); $findUnit->appendChild($roomIdN); |