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 ++++++++++++------ .../inc/coursebackend/coursebackend_hisinone.inc.php | 15 ++++++++------- modules-available/locationinfo/lang/de/davinci.json | 3 +++ modules-available/locationinfo/lang/de/hisinone.json | 10 ++++++++++ modules-available/locationinfo/lang/en/davinci.json | 3 +++ modules-available/locationinfo/lang/en/hisinone.json | 10 ++++++++++ 6 files changed, 46 insertions(+), 13 deletions(-) create mode 100644 modules-available/locationinfo/lang/de/davinci.json create mode 100644 modules-available/locationinfo/lang/de/hisinone.json create mode 100644 modules-available/locationinfo/lang/en/davinci.json create mode 100644 modules-available/locationinfo/lang/en/hisinone.json 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"&& $ierror = 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; } diff --git a/modules-available/locationinfo/lang/de/davinci.json b/modules-available/locationinfo/lang/de/davinci.json new file mode 100644 index 00000000..0e0dcd23 --- /dev/null +++ b/modules-available/locationinfo/lang/de/davinci.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/modules-available/locationinfo/lang/de/hisinone.json b/modules-available/locationinfo/lang/de/hisinone.json new file mode 100644 index 00000000..d783c173 --- /dev/null +++ b/modules-available/locationinfo/lang/de/hisinone.json @@ -0,0 +1,10 @@ +{ + "username": "Nutzername", + "username_title": "Der Nutzername, der in HisInOne verwendet wird.", + "password": "Passwort", + "password_title": "Das Passwort, das in HisInOne verwendet wird.", + "open":"open", + "open_title":"Verwende die openCourseService Api.", + "role":"Rolle", + "role_title":"Die Rolle die der Nutzername in HisInOne verwendet." +} \ No newline at end of file diff --git a/modules-available/locationinfo/lang/en/davinci.json b/modules-available/locationinfo/lang/en/davinci.json new file mode 100644 index 00000000..0e0dcd23 --- /dev/null +++ b/modules-available/locationinfo/lang/en/davinci.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/modules-available/locationinfo/lang/en/hisinone.json b/modules-available/locationinfo/lang/en/hisinone.json new file mode 100644 index 00000000..3dd14602 --- /dev/null +++ b/modules-available/locationinfo/lang/en/hisinone.json @@ -0,0 +1,10 @@ +{ + "username": "username", + "username_title": "The username used in HisInOne.", + "password": "password", + "password_title": "The password used in HisInOne.", + "open":"open", + "open_title":"Use openCourseService api.", + "role":"role", + "role_title":"The role used by the username in HisInOne." +} \ No newline at end of file -- cgit v1.2.3-55-g7522