summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDirk Riestere2017-03-08 18:23:58 +0100
committerDirk Riestere2017-03-08 18:23:58 +0100
commite4f91cedd4a29139d10edc1cbdedcadd83de3ce8 (patch)
tree4c9533824f673cd943d0a40701dffc0ce4506423
parentAPI: setCredentials without json_encode (diff)
downloadslx-admin-e4f91cedd4a29139d10edc1cbdedcadd83de3ce8.tar.gz
slx-admin-e4f91cedd4a29139d10edc1cbdedcadd83de3ce8.tar.xz
slx-admin-e4f91cedd4a29139d10edc1cbdedcadd83de3ce8.zip
setCredentials wie im Treffen besprochen geändert und fetchshedule gibt jetzt nur noch arrays zurück
-rw-r--r--modules-available/locationinfo/inc/coursebackend.inc.php5
-rw-r--r--modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php14
-rw-r--r--modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php51
3 files changed, 44 insertions, 26 deletions
diff --git a/modules-available/locationinfo/inc/coursebackend.inc.php b/modules-available/locationinfo/inc/coursebackend.inc.php
index ab787738..ea2dcd44 100644
--- a/modules-available/locationinfo/inc/coursebackend.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend.inc.php
@@ -106,12 +106,12 @@ abstract class CourseBackend
* uses json to setCredentials, the json must follow the form given in
* getCredentials
*
- * @param string $json jsonarray with the credentials
+ * @param string $data array with the credentials
* @param string $url address of the server
* @param int $serverID ID of the server
* @returns void
*/
- public abstract function setCredentials($json, $url, $serverID);
+ public abstract function setCredentials($data, $url, $serverID);
/**
* @return int desired caching time of results, in seconds. 0 = no caching
@@ -180,6 +180,7 @@ abstract class CourseBackend
if ($this->getCacheTime() > 0) {
foreach ($newResult as $key => $value) {
+ $value = json_encode($value);
$now = strtotime('Now');
Database::simpleQuery("UPDATE location_info SET calendar = :ttable, lastcalendarupdate = :now WHERE locationid = :id ", array('id' => $key, 'ttable' => $value, 'now' => $now));
}
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
index 523823bf..367bfb0d 100644
--- a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
@@ -4,22 +4,27 @@ class Coursebackend_Davinci extends CourseBackend
{
- public function setCredentials($json, $location, $serverID)
+ public function setCredentials($data, $location, $serverID)
{
+ if ($location = "") {
+ $this->error = true;
+ $this->errormsg = "No url is given";
+ return !$this->error;
+ }
$this->location = $location . "/DAVINCIIS.dll?";
$this->serverID = $serverID;
//Davinci doesn't have credentials
- return $this->checkConnection();
+ return true;
}
public function checkConnection()
{
if ($this->location != "") {
- $this->fetchSchedulesInternal('B206');
+ $this->fetchArray('B206');
return !$this->error;
}
$this->error = true;
- $this->errormsg = "No url is given";
+ $this->errormsg = "Credentials are not set";
return !$this->error;
}
@@ -115,7 +120,6 @@ class Coursebackend_Davinci extends CourseBackend
);
array_push($timetable, $json);
}
- $timetable = json_encode($timetable);
$schedules[$sroomId] = $timetable;
}
} catch (Exception $e) {
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php
index ac958b2c..60a5d163 100644
--- a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php
@@ -7,29 +7,39 @@ class CourseBackend_HisInOne extends CourseBackend
private $open;
//Sets the location and the login information of this client
- public function setCredentials($json, $location, $serverID)
+ public function setCredentials($data, $location, $serverID)
{
- $this->error = false;
- $data = json_decode($json, true);
- $this->password = $data['password'];
- $this->username = $data['username'] . "\t" . $data['role'];
- $this->open = $data['open'];
- if ($this->open) {
- $this->location = $location . "/qisserver/services2/OpenCourseService";
- } else {
- $this->location = $location . "/qisserver/services2/CourseService";
+ try {
+ $this->error = false;
+ $this->password = $data['password'];
+ $this->username = $data['username'] . "\t" . $data['role'];
+ $this->open = $data['open'];
+ if ($location = "") {
+ $this->error = true;
+ $this->errormsg = "No url is given";
+ return !$this->error;
+ }
+ if ($this->open) {
+ $this->location = $location . "/qisserver/services2/OpenCourseService";
+ } else {
+ $this->location = $location . "/qisserver/services2/CourseService";
+ }
+ $this->serverID = $serverID;
+ } catch (Exception $e) {
+ $this->error = true;
+ $this->errormsg = $e->getMessage();
+ return false;
}
- $this->serverID = $serverID;
- return $this->checkConnection();
+ return true;
}
public function checkConnection()
{
if ($this->location = "") {
$this->error = true;
- $this->errormsg = "No url is given";
- return !$this->error;
+ $this->errormsg = "Credentials are not set";
}
+
$this->findUnit(42);
return !$this->error;
}
@@ -53,7 +63,7 @@ class CourseBackend_HisInOne extends CourseBackend
public function getCredentials()
{
- $credentials = ["username" => "string", "role" => "string", "password" => "string", "open" => "boolean"];
+ $credentials = ["username" => "string", "role" => "string", "password" => "string", "open" => "bool"];
return $credentials;
}
@@ -178,7 +188,7 @@ class CourseBackend_HisInOne extends CourseBackend
return false;
}
$response2 = $this->toArray($response1);
- if (!$this->error) {
+ if ($response2 != false) {
if (isset($response2['soapenvBody']['soapenvFault'])) {
$this->error = true;
$this->errormsg = $response2['soapenvBody']['soapenvFault']['faultcode'] . " " . $response2['soapenvBody']['soapenvFault']['faultstring'];
@@ -343,8 +353,11 @@ class CourseBackend_HisInOne extends CourseBackend
//get all eventIDs in a given room
$eventIDs = [];
foreach ($param as $ID) {
- $eventIDs = array_merge($eventIDs, $this->findUnit($ID));
- var_dump($eventIDs);
+ $unitID = $this->findUnit($ID);
+ if ($unitID === false) {
+ return false;
+ }
+ $eventIDs = array_merge($eventIDs, $unitID);
$eventIDs = array_unique($eventIDs);
if ($this->error == true) {
return false;
@@ -409,7 +422,7 @@ class CourseBackend_HisInOne extends CourseBackend
}
}
}
- $tTables[$room] = json_encode($timetable);
+ $tTables[$room] = $timetable;
}
} catch (Exception $e) {
$this->error = true;