From 8f79c88942c31727f5507b1f86a40c6d41430271 Mon Sep 17 00:00:00 2001 From: Dirk Riestere Date: Sun, 5 Mar 2017 18:31:21 +0100 Subject: Checkconnection prüft jetzt ob eine url existiert, array exeption sollten jetzt gefangen werden und die credentials werden gleich getestet --- .../coursebackend/coursebackend_davinci.inc.php | 55 +++++++++++++--------- 1 file changed, 34 insertions(+), 21 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 ce549c72..f00b9193 100644 --- a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php +++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php @@ -10,11 +10,18 @@ class Coursebackend_Davinci extends CourseBackend $this->location = $location . "/DAVINCIIS.dll?"; $this->serverID = $serverID; //Davinci doesn't have credentials + $this->checkConnection(); + return $this->error; } public function checkConnection() { - $this->fetchSchedulesInternal('B206'); + if ($this->location != "") { + $this->fetchSchedulesInternal('B206'); + return $this->error; + } + $this->error = false; + $this->errormsg = "No url is given"; return $this->error; } @@ -81,28 +88,34 @@ class Coursebackend_Davinci extends CourseBackend public function fetchSchedulesInternal($roomIds) { $schedules = []; - foreach ($roomIds as $sroomId) { - $return = $this->fetchArray($sroomId); - $lessons = $return['Lessons']['Lesson']; - $timetable = []; - foreach ($lessons as $lesson) { - $date = $lesson['Date']; - $date = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6, 2); - $start = $lesson['Start']; - $start = substr($start, 0, 2) . ':' . substr($start, 2, 2); - $end = $lesson['Finish']; - $end = substr($end, 0, 2) . ':' . substr($end, 2, 2); - $subject = $lesson['Subject']; - $json = array( - 'title' => $subject, - 'start' => $date . " " . $start . ':00', - 'end' => $date . " " . $end . ':00' - ); - array_push($timetable, $json); + try { + foreach ($roomIds as $sroomId) { + $return = $this->fetchArray($sroomId); + $lessons = $return['Lessons']['Lesson']; + $timetable = []; + foreach ($lessons as $lesson) { + $date = $lesson['Date']; + $date = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6, 2); + $start = $lesson['Start']; + $start = substr($start, 0, 2) . ':' . substr($start, 2, 2); + $end = $lesson['Finish']; + $end = substr($end, 0, 2) . ':' . substr($end, 2, 2); + $subject = $lesson['Subject']; + $json = array( + 'title' => $subject, + 'start' => $date . " " . $start . ':00', + 'end' => $date . " " . $end . ':00' + ); + array_push($timetable, $json); + } + $timetable = json_encode($timetable); + $schedules[$sroomId] = $timetable; } - $timetable = json_encode($timetable); - $schedules[$sroomId] = $timetable; + } catch (Exception $e) { + $this->error = true; + $this->errormsg = $e->getMessage(); } + return $schedules; } } -- cgit v1.2.3-55-g7522