summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
diff options
context:
space:
mode:
authorDirk Riestere2017-03-05 18:31:21 +0100
committerDirk Riestere2017-03-05 18:31:21 +0100
commit8f79c88942c31727f5507b1f86a40c6d41430271 (patch)
treebd54f845ca6e38d8207fc63f6d31dfa1a6411944 /modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
parentAdmin-panel: Credentials Button is now red/green if the connection failed/suc... (diff)
downloadslx-admin-8f79c88942c31727f5507b1f86a40c6d41430271.tar.gz
slx-admin-8f79c88942c31727f5507b1f86a40c6d41430271.tar.xz
slx-admin-8f79c88942c31727f5507b1f86a40c6d41430271.zip
Checkconnection prüft jetzt ob eine url existiert, array exeption sollten jetzt gefangen werden und die credentials werden gleich getestet
Diffstat (limited to 'modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php')
-rw-r--r--modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php55
1 files changed, 34 insertions, 21 deletions
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;
}
}