diff options
author | Dirk Riestere | 2017-03-05 19:53:54 +0100 |
---|---|---|
committer | Dirk Riestere | 2017-03-05 19:53:54 +0100 |
commit | 16a22fd7b198eed5271cea93b2979e0d4c819171 (patch) | |
tree | 0f286b848f72e6bdb1187597faf28a1c0e58f2e4 /modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php | |
parent | Checkconnection prüft jetzt ob eine url existiert, array exeption sollten je... (diff) | |
download | slx-admin-16a22fd7b198eed5271cea93b2979e0d4c819171.tar.gz slx-admin-16a22fd7b198eed5271cea93b2979e0d4c819171.tar.xz slx-admin-16a22fd7b198eed5271cea93b2979e0d4c819171.zip |
Noch mehr exeption werden gefangen und das verhalten bei errors ist vereinheitlicht
Diffstat (limited to 'modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php')
-rw-r--r-- | modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php index 6c6db23c..3343d124 100644 --- a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php +++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php @@ -3,26 +3,24 @@ class Coursebackend_Davinci extends CourseBackend { - private $location; public function setCredentials($json, $location, $serverID) { $this->location = $location . "/DAVINCIIS.dll?"; $this->serverID = $serverID; //Davinci doesn't have credentials - $this->checkConnection(); - return $this->error; + return $this->checkConnection(); } public function checkConnection() { if ($this->location != "") { $this->fetchSchedulesInternal('B206'); - return $this->error; + return !$this->error; } - $this->error = false; + $this->error = true; $this->errormsg = "No url is given"; - return $this->error; + return !$this->error; } public function getCredentials() @@ -49,9 +47,15 @@ class Coursebackend_Davinci extends CourseBackend private function toArray($response) { - $cleanresponse = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $response); - $xml = new SimpleXMLElement($cleanresponse); - $array = json_decode(json_encode((array)$xml), true); + try { + $cleanresponse = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $response); + $xml = new SimpleXMLElement($cleanresponse); + $array = json_decode(json_encode((array)$xml), true); + } catch (Exception $exception) { + $this->error = true; + $this->errormsg = "url did not send a xml"; + $array = []; + } return $array; } @@ -91,6 +95,9 @@ class Coursebackend_Davinci extends CourseBackend try { foreach ($roomIds as $sroomId) { $return = $this->fetchArray($sroomId); + if ($this->error) { + return $schedules; + } $lessons = $return['Lessons']['Lesson']; $timetable = []; foreach ($lessons as $lesson) { |