summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/inc/coursebackend
diff options
context:
space:
mode:
authorDirk Riestere2017-03-02 18:32:54 +0100
committerDirk Riestere2017-03-02 18:32:54 +0100
commit885aba04832c840aed3a45c3bb09bf088ce01a0c (patch)
tree838e1b582dc0f2d30c99da1d91d6ddc897f3bc66 /modules-available/locationinfo/inc/coursebackend
parentDas HisInOne Backend funktioniert nun auch mit OpenCourseService (diff)
downloadslx-admin-885aba04832c840aed3a45c3bb09bf088ce01a0c.tar.gz
slx-admin-885aba04832c840aed3a45c3bb09bf088ce01a0c.tar.xz
slx-admin-885aba04832c840aed3a45c3bb09bf088ce01a0c.zip
Bugfixes und Davincii ist jetzt implementiert
Diffstat (limited to 'modules-available/locationinfo/inc/coursebackend')
-rw-r--r--modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php75
-rw-r--r--modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php8
2 files changed, 70 insertions, 13 deletions
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
index 6e07e1f4..c62ad4f4 100644
--- a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
@@ -1,22 +1,18 @@
<?php
-class Coursebackend_Davinci extends CourseBackend {
+class Coursebackend_Davinci extends CourseBackend
+{
private $location;
public $serverID;
- function __construct($location, $serverID) {
-
- }
public function setCredentials($json,$location,$serverID) {
- $this->error = true;
- $this->errormsg = "This class is just a place holder";
- $this->location = $location."/daVinciIS.dll?";
+ $this->location = $location."/DAVINCIIS.dll?";
$this->serverID = $serverID;
//Davinci doesn't have credentials
}
public function checkConection(){
- $this->fetchSchedulesInternal(42);
+ $this->fetchSchedulesInternal('B206');
return $this->error;
}
public function getCredentials(){
@@ -32,9 +28,70 @@ class Coursebackend_Davinci extends CourseBackend {
public function getRefreshTime(){
return 0;
}
- public function fetchSchedulesInternal($roomId){
+ private function toArray($response){
+
+ $cleanresponse = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $response);
+ $xml = new SimpleXMLElement($cleanresponse);
+ $array = json_decode(json_encode((array)$xml), TRUE);
+ return $array;
+ }
+ private function fetchArray($roomId){
+ $startdate= new DateTime('monday this week');
+ $enddate = new DateTime('sunday');
+ $url= $this->location."content=xml&type=room&name=".$roomId."&startdate=".$startdate->format('d.m.Y')."&enddate=".$enddate->format('d.m.Y');
+ $ch=curl_init();
+ $options = array(
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_FOLLOWLOCATION => true,
+ CURLOPT_SSL_VERIFYHOST => false,
+ CURLOPT_SSL_VERIFYPEER => false,
+ CURLOPT_URL => $url ,
+ );
+
+ curl_setopt_array($ch, $options);
+ $output=curl_exec($ch);
+ if( $output === false)
+ {
+ $this->error = true;
+ $this->errormsg = 'Curl error: ' . curl_error($soap_do);
+ return 'Curl error: ' . curl_error($soap_do);
+ }
+ else
+ {
+ $this->error = false;
+ $this->errormsg ="";
+ ///Operation completed successfully
+ }
+ curl_close($ch);
+ return $this->toArray($output);
}
+ public function fetchSchedulesInternal($roomIds){
+ $shedules = [];
+ foreach ($roomIds as $locationId => $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);
+ $shedules[$locationId] = $timetable;
+ }
+ return $shedules;
+ }
}
?>
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php
index d126e674..157a5bf6 100644
--- a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php
@@ -14,7 +14,7 @@ class CourseBackend_HisInOne extends CourseBackend
$data = json_decode($json, TRUE);
$this->password = $data['password'];
$this->username = $data['username']."\t".$data['role'];
- $this->open = $data['Open'];
+ $this->open = $data['open'];
if($this->open){
$this->location = $location."/qisserver/services2/OpenCourseService";
}
@@ -85,7 +85,7 @@ class CourseBackend_HisInOne extends CourseBackend
$doc->formatOutput = true;
$envelope = $doc->createElementNS('http://schemas.xmlsoap.org/soap/envelope/', 'SOAP-ENV:Envelope');
$doc->appendChild($envelope);
- if($this->Open){
+ if($this->open){
$envelope->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:ns1', 'http://www.his.de/ws/OpenCourseService');
}
else{
@@ -120,7 +120,7 @@ class CourseBackend_HisInOne extends CourseBackend
$this->error = false;
}
if($this->open){
- $units = $respons2['soapenvBody']['hisfindUnitResponse']['hisunits'];
+ $units = $respons2['soapenvBody']['hisfindUnitResponse']['hisunits']['hisunit'];
foreach ($units as $unit) {
$id[]= $unit['hisid'];
}
@@ -138,7 +138,7 @@ class CourseBackend_HisInOne extends CourseBackend
$doc->formatOutput = true;
$envelope = $doc->createElementNS('http://schemas.xmlsoap.org/soap/envelope/', 'SOAP-ENV:Envelope');
$doc->appendChild($envelope);
- if($this->Open){
+ if($this->open){
$envelope->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:ns1', 'http://www.his.de/ws/OpenCourseService');
}
else{