From 16a22fd7b198eed5271cea93b2979e0d4c819171 Mon Sep 17 00:00:00 2001 From: Dirk Riestere Date: Sun, 5 Mar 2017 19:53:54 +0100 Subject: Noch mehr exeption werden gefangen und das verhalten bei errors ist vereinheitlicht --- .../coursebackend/coursebackend_davinci.inc.php | 25 ++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php') 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) { -- cgit v1.2.3-55-g7522