diff options
author | Dirk Riestere | 2017-03-22 18:57:57 +0100 |
---|---|---|
committer | Dirk Riestere | 2017-03-22 18:57:57 +0100 |
commit | 45a3dfee35a2a03296531b865bd6ea2cac0d7c53 (patch) | |
tree | b6039986c08922c4f348078a3ebdbcf18a17a822 /modules-available/locationinfo/inc | |
parent | frontend fixed scrolling (diff) | |
download | slx-admin-45a3dfee35a2a03296531b865bd6ea2cac0d7c53.tar.gz slx-admin-45a3dfee35a2a03296531b865bd6ea2cac0d7c53.tar.xz slx-admin-45a3dfee35a2a03296531b865bd6ea2cac0d7c53.zip |
Übersetzungen der Credentials eingebaut und nicht fatale errors werden nun im errorlog ausgegeben
Diffstat (limited to 'modules-available/locationinfo/inc')
-rw-r--r-- | modules-available/locationinfo/inc/coursebackend.inc.php | 18 | ||||
-rw-r--r-- | modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php | 15 |
2 files changed, 20 insertions, 13 deletions
diff --git a/modules-available/locationinfo/inc/coursebackend.inc.php b/modules-available/locationinfo/inc/coursebackend.inc.php index 83e4febd..95f39ea8 100644 --- a/modules-available/locationinfo/inc/coursebackend.inc.php +++ b/modules-available/locationinfo/inc/coursebackend.inc.php @@ -22,6 +22,7 @@ abstract class CourseBackend public $errormsg; public $serverID; public $location; + const nrOtherRooms = 5; /** * CourseBackend constructor. @@ -125,8 +126,9 @@ abstract class CourseBackend * Internal version of fetch, to be overridden by subclasses. * * @param $roomIds array with local ID as key and serverID as value - * @return array a multidimensional array that uses the roomID as key - * and has the schedules as string in the value + * @return array a recursive array that uses the roomID as key + * and has the schedule array as value. A shedule array contains jsons in this format: + * {"start":JJJJ-MM-DD HH:MM:SS,"end":JJJJ-MM-DD HH:MM:SS,"title":string} */ protected abstract function fetchSchedulesInternal($roomId); @@ -151,20 +153,22 @@ abstract class CourseBackend $calendar = $row['calendar']; //Check if in cache if lastUpdate is null then it is interpreted as 1970 if ($lastUpdate > strtotime("-" . $this->getCacheTime() . "seconds")) { - $newResult[$row['locationid']] = json_decode($calendar); + $result[$row['locationid']] = json_decode($calendar); } else { $sRoomIDs[$row['locationid']] = $sRoomID; } } //Check if we should refresh other rooms recently requested by front ends - if ($this->getCacheTime() > 0 && $this->getRefreshTime() > 0) { + if ($this->getCacheTime() > 0) { + $i = 0; //number of rooms getting refreshed $dbquery4 = Database::simpleQuery("SELECT locationid ,serverroomid, lastcalendarupdate FROM location_info WHERE serverid= :id", array('id' => $this->serverID)); foreach ($dbquery4->fetchAll(PDO::FETCH_COLUMN) as $row) { if (isset($row['lastcalendarupdate'])) { $lastUpdate = $row['lastcalendarupdate']; - if (strtotime($lastUpdate) > strtotime("-" . $this->getRefreshTime() . "seconds") && strtotime($lastUpdate) > strtotime("-" . $this->getCacheTime() . "seconds")) { + if ($lastUpdate < strtotime("-" . $this->getRefreshTime() . "seconds") && $lastUpdate > strtotime("-" . $this->getCacheTime() . "seconds"&& $i<self::nrOtherRooms)) { $sRoomIDs[$row['locationid']] = $row['serverroomid']; + $i = $i +1; } } } @@ -187,7 +191,9 @@ abstract class CourseBackend } //get all schedules that are wanted from roomIDs foreach ($roomIDs as $id) { - $result[$id] = $newResult[$id]; + if(isset($newResult[$id])){ + $result[$id] = $newResult[$id]; + } } return $result; } diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php index b250d114..61d50938 100644 --- a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php +++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php @@ -41,7 +41,7 @@ class CourseBackend_HisInOne extends CourseBackend $this->error = true; $this->errormsg = "Credentials are not set"; } - $this->fetchSchedulesInternal([190=>190]); + $this->findUnit(190); return !$this->error; } @@ -219,7 +219,7 @@ class CourseBackend_HisInOne extends CourseBackend public function getCredentials() { - $credentials = ["username" => ["string", "Name used to identify on HisInOne", false], "role" =>["string", "Role used to identify on HisInOne", false], "password" => ["string", "Password for the username on HisInOne", true], "open" => ["bool", "If checked the opencourseservice interface is used", false]]; + $credentials = ["username" => "string", "role" =>"string", "password" => "password", "open" => "bool"]; return $credentials; } @@ -237,13 +237,12 @@ class CourseBackend_HisInOne extends CourseBackend foreach ($param as $ID) { $unitID = $this->findUnit($ID); if ($unitID == false) { - return false; + $this->error = false; + error_log($this->errormsg); + continue; } $eventIDs = array_merge($eventIDs, $unitID); $eventIDs = array_unique($eventIDs); - if ($this->error == true) { - return false; - } } if (empty($eventIDs)) { foreach ($param as $room) { @@ -256,7 +255,9 @@ class CourseBackend_HisInOne extends CourseBackend foreach ($eventIDs as $each_event) { $event = $this->readUnit(intval($each_event)); if ($event === false) { - return false; + $this->error = false; + error_log($this->errormsg); + continue; } $events[] = $event; } |