summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/inc/coursebackend.inc.php
diff options
context:
space:
mode:
authorDirk Riestere2017-03-22 18:57:57 +0100
committerDirk Riestere2017-03-22 18:57:57 +0100
commit45a3dfee35a2a03296531b865bd6ea2cac0d7c53 (patch)
treeb6039986c08922c4f348078a3ebdbcf18a17a822 /modules-available/locationinfo/inc/coursebackend.inc.php
parentfrontend fixed scrolling (diff)
downloadslx-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/coursebackend.inc.php')
-rw-r--r--modules-available/locationinfo/inc/coursebackend.inc.php18
1 files changed, 12 insertions, 6 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;
}