summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
diff options
context:
space:
mode:
authorDirk Riestere2017-03-09 01:41:31 +0100
committerDirk Riestere2017-03-09 01:41:31 +0100
commit9cabedcfc2c95beda6a7455042bfab5b93ba5c0a (patch)
tree8dafd15a54e8ed128206d39a0c8dbc30a7a88b5e /modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
parentLocationinfo: Errors from the CourseBackend are now safes in the db and shown... (diff)
downloadslx-admin-9cabedcfc2c95beda6a7455042bfab5b93ba5c0a.tar.gz
slx-admin-9cabedcfc2c95beda6a7455042bfab5b93ba5c0a.tar.xz
slx-admin-9cabedcfc2c95beda6a7455042bfab5b93ba5c0a.zip
Fehler beim xml lesen behoben
Diffstat (limited to 'modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php')
-rw-r--r--modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php63
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;
}
}