From 45a3dfee35a2a03296531b865bd6ea2cac0d7c53 Mon Sep 17 00:00:00 2001 From: Dirk Riestere Date: Wed, 22 Mar 2017 18:57:57 +0100 Subject: Übersetzungen der Credentials eingebaut und nicht fatale errors werden nun im errorlog ausgegeben --- .../locationinfo/inc/coursebackend.inc.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'modules-available/locationinfo/inc/coursebackend.inc.php') 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