diff options
Diffstat (limited to 'modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php')
-rw-r--r-- | modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php | 63 |
1 files changed, 31 insertions, 32 deletions
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php index 367bfb0d..e857a26b 100644 --- a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php +++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php @@ -6,7 +6,7 @@ class Coursebackend_Davinci extends CourseBackend public function setCredentials($data, $location, $serverID) { - if ($location = "") { + if ($location == "") { $this->error = true; $this->errormsg = "No url is given"; return !$this->error; @@ -82,8 +82,8 @@ class Coursebackend_Davinci extends CourseBackend $output = curl_exec($ch); if ($output === false) { $this->error = true; - $this->errormsg = 'Curl error: ' . curl_error($ch); - return 'Curl error: ' . curl_error($ch); + $this->errormsg = 'Curl error: ' . curl_error($ch).$url; + return false; } else { $this->error = false; $this->errormsg = ""; @@ -97,37 +97,36 @@ class Coursebackend_Davinci extends CourseBackend public function fetchSchedulesInternal($roomIds) { $schedules = []; - try { - foreach ($roomIds as $sroomId) { - $return = $this->fetchArray($sroomId); - if ($return === false) { - return false; - } - $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); - } - $schedules[$sroomId] = $timetable; + + foreach ($roomIds as $sroomId) { + $return = $this->fetchArray($sroomId); + if ($return === false) { + return false; + } elseif (!isset($return['Lessons']['Lesson'])) { + $this->error = true; + $this->errormsg = "url send a xml in a wrong format"; + return false; } - } catch (Exception $e) { - $this->error = true; - $this->errormsg = "url returns a wrong xml"; - return false; + $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); + } + $schedules[$sroomId] = $timetable; } - return $schedules; } } |