summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/inc
diff options
context:
space:
mode:
authorSimon Rettberg2017-04-12 14:04:56 +0200
committerSimon Rettberg2017-04-12 14:04:56 +0200
commitaa86e073b0111e61b1ba9a080604d945381ccb6a (patch)
treeed95c1d630f33b85d7bc55b387289c80e5386d7c /modules-available/locationinfo/inc
parent[locationinfo] Format templates (diff)
downloadslx-admin-aa86e073b0111e61b1ba9a080604d945381ccb6a.tar.gz
slx-admin-aa86e073b0111e61b1ba9a080604d945381ccb6a.tar.xz
slx-admin-aa86e073b0111e61b1ba9a080604d945381ccb6a.zip
[locationinfo] Format php files
Diffstat (limited to 'modules-available/locationinfo/inc')
-rw-r--r--modules-available/locationinfo/inc/coursebackend.inc.php22
-rw-r--r--modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php4
-rw-r--r--modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php129
-rw-r--r--modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php31
4 files changed, 105 insertions, 81 deletions
diff --git a/modules-available/locationinfo/inc/coursebackend.inc.php b/modules-available/locationinfo/inc/coursebackend.inc.php
index e14e9443..11d833e6 100644
--- a/modules-available/locationinfo/inc/coursebackend.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend.inc.php
@@ -140,7 +140,7 @@ abstract class CourseBackend
*/
public final function fetchSchedule($roomIDs)
{
- if(empty($roomIDs)){
+ if (empty($roomIDs)) {
$this->error = true;
$this->errormsg = 'No roomid was given to fetch Shedule';
return false;
@@ -171,15 +171,17 @@ abstract class CourseBackend
foreach ($dbquery4->fetchAll(PDO::FETCH_COLUMN) as $row) {
if (isset($row['lastcalendarupdate'])) {
$lastUpdate = $row['lastcalendarupdate'];
- if ($lastUpdate < strtotime("-" . $this->getRefreshTime() . "seconds") && $lastUpdate > strtotime("-" . $this->getCacheTime() . "seconds"&& $i<self::nrOtherRooms)) {
+ if ($lastUpdate < strtotime("-" . $this->getRefreshTime() . "seconds")
+ && $lastUpdate > strtotime("-" . $this->getCacheTime() . "seconds"
+ && $i < self::nrOtherRooms)) {
$sRoomIDs[$row['locationid']] = $row['serverroomid'];
- $i = $i +1;
+ $i = $i + 1;
}
}
}
}
//This is true if there is no need to check the HisInOne Server
- if(empty($sRoomIDs)){
+ if (empty($sRoomIDs)) {
return $result;
}
$results = $this->fetchSchedulesInternal($sRoomIDs);
@@ -195,12 +197,17 @@ abstract class CourseBackend
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));
+ Database::simpleQuery("UPDATE location_info SET calendar = :ttable, lastcalendarupdate = :now
+ WHERE locationid = :id ", array(
+ 'id' => $key,
+ 'ttable' => $value,
+ 'now' => $now
+ ));
}
}
//get all schedules that are wanted from roomIDs
foreach ($roomIDs as $id) {
- if(isset($newResult[$id])){
+ if (isset($newResult[$id])) {
$result[$id] = $newResult[$id];
}
}
@@ -217,6 +224,7 @@ abstract class CourseBackend
}
return false;
}
+
/**
* Query path in array-representation of XML document.
* e.g. 'path/syntax/foo/wanteditem'
@@ -262,7 +270,7 @@ abstract class CourseBackend
$return = [];
foreach ($array[$element] as $item) {
$test = $this->getAttributes($item, $path);
- If(gettype($test) == "array" ){
+ If (gettype($test) == "array") {
$return = array_merge($return, $test);
}
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
index 3a2e4e0c..2d53e762 100644
--- a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
@@ -89,7 +89,7 @@ class Coursebackend_Davinci extends CourseBackend
$output = curl_exec($ch);
if ($output === false) {
$this->error = true;
- $this->errormsg = 'Curl error: ' . curl_error($ch).$url;
+ $this->errormsg = 'Curl error: ' . curl_error($ch) . $url;
return false;
} else {
$this->error = false;
@@ -109,7 +109,7 @@ class Coursebackend_Davinci extends CourseBackend
if ($return === false) {
return false;
}
- $lessons = $this->getAttributes($return,'Lessons/Lesson');
+ $lessons = $this->getAttributes($return, 'Lessons/Lesson');
if (!$lessons) {
$this->error = true;
$this->errormsg = "url send a xml in a wrong format";
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php
index 482ca097..484a5286 100644
--- a/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php
@@ -1,6 +1,8 @@
<?php
-class Coursebackend_Dummy extends CourseBackend {
- private $pw;
+
+class Coursebackend_Dummy extends CourseBackend
+{
+ private $pw;
/**
* uses json to setCredentials, the json must follow the form given in
@@ -11,62 +13,77 @@ class Coursebackend_Dummy extends CourseBackend {
* @param int $serverID ID of the server
* @returns bool if the credentials were in the correct format
*/
- public function setCredentials($json,$location,$serverID) {
- $x = $json;
- $this->pw = $x['password'];
+ public function setCredentials($json, $location, $serverID)
+ {
+ $x = $json;
+ $this->pw = $x['password'];
- if ($this->pw == "mfg") {
- $this->error = false;
- return true;
- } else {
- $this->errormsg = "USE mfg as password!";
- $this->error = true;
- return false;
- }
- }
+ if ($this->pw === "mfg") {
+ $this->error = false;
+ return true;
+ } else {
+ $this->errormsg = "USE mfg as password!";
+ $this->error = true;
+ return false;
+ }
+ }
/**
* @return boolean true if the connection works, false otherwise
*/
- public function checkConnection(){
- if ($this->pw == "mfg") {
- $this->error = false;
- return true;
- } else {
- $this->errormsg = "USE mfg as password!";
- $this->error = true;
- return false;
- }
- }
+ public function checkConnection()
+ {
+ if ($this->pw == "mfg") {
+ $this->error = false;
+ return true;
+ } else {
+ $this->errormsg = "USE mfg as password!";
+ $this->error = true;
+ return false;
+ }
+ }
/**
* @returns array with parameter name as key and and an array with type, help text and mask as value
*/
- public function getCredentials(){
- $options = ["opt1", "opt2", "opt3", "opt4", "opt5", "opt6", "opt7", "opt8"];
- $credentials = ["username" => "string","password"=>"password","integer"=>"int","option"=>$options,"CheckTheBox" =>"bool","CB2 t" =>"bool"];
- return $credentials;
- }
+ public function getCredentials()
+ {
+ $options = ["opt1", "opt2", "opt3", "opt4", "opt5", "opt6", "opt7", "opt8"];
+ $credentials = [
+ "username" => "string",
+ "password" => "password",
+ "integer" => "int",
+ "option" => $options,
+ "CheckTheBox" => "bool",
+ "CB2 t" => "bool"
+ ];
+ return $credentials;
+ }
/**
* @return string return display name of backend
*/
- public function getDisplayName(){
- return'Dummy with array';
- }
+ public function getDisplayName()
+ {
+ return 'Dummy with array';
+ }
+
/**
* @return int desired caching time of results, in seconds. 0 = no caching
*/
- public function getCacheTime(){
- return 0;
- }
+ public function getCacheTime()
+ {
+ return 0;
+ }
+
/**
- * @return int age after which timetables are no longer refreshed should be
- * greater then CacheTime
- */
- public function getRefreshTime(){
- return 0;
- }
+ * @return int age after which timetables are no longer refreshed should be
+ * greater then CacheTime
+ */
+ public function getRefreshTime()
+ {
+ return 0;
+ }
/**
* Internal version of fetch, to be overridden by subclasses.
@@ -76,22 +93,24 @@ class Coursebackend_Dummy extends CourseBackend {
* and has the schedule array as value. A shedule array contains an array in this format:
* ["start"=>'JJJJ-MM-DD HH:MM:SS',"end"=>'JJJJ-MM-DD HH:MM:SS',"title"=>string]
*/
- public function fetchSchedulesInternal($roomId){
- $a = array();
- foreach ($roomId as $id) {
- $x['id'] = $id;
- $calendar['title'] = "test exam";
- $calendar['start'] = "2017-3-08 13:00:00";
- $calendar['end'] = "2017-3-08 16:00:00";
- $calarray = array();
- $calarray[] = $calendar;
- $x['calendar'] = $calarray;
- $a[$id] = $calarray;
- }
+ public function fetchSchedulesInternal($roomId)
+ {
+ $a = array();
+ foreach ($roomId as $id) {
+ $x['id'] = $id;
+ $calendar['title'] = "test exam";
+ $calendar['start'] = "2017-3-08 13:00:00";
+ $calendar['end'] = "2017-3-08 16:00:00";
+ $calarray = array();
+ $calarray[] = $calendar;
+ $x['calendar'] = $calarray;
+ $a[$id] = $calarray;
+ }
- return $a;
- }
+ return $a;
+ }
}
+
?>
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php
index ee79cec9..0e7c5328 100644
--- a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php
@@ -31,7 +31,6 @@ class CourseBackend_HisInOne extends CourseBackend
return false;
}
-
return true;
}
@@ -79,7 +78,7 @@ class CourseBackend_HisInOne extends CourseBackend
$body->appendChild($findUnit);
$termYearN = $doc->createElement('termYear', $termYear);
$findUnit->appendChild($termYearN);
- if($termType1 !=3 && $termType1 != 10){
+ if ($termType1 != 3 && $termType1 != 10) {
$termTypeValueId = $doc->createElement('termTypeValueId', $termType);
$findUnit->appendChild($termTypeValueId);
}
@@ -101,12 +100,12 @@ class CourseBackend_HisInOne extends CourseBackend
$this->errormsg = $response2['soapenvBody']['soapenvFault']['faultcode'] . " " . $response2['soapenvBody']['soapenvFault']['faultstring'];
return false;
} elseif ($this->open) {
- $units = $this->getAttributes($response2,'soapenvBody/hisfindUnitResponse/hisunits/hisunit');
+ $units = $this->getAttributes($response2, 'soapenvBody/hisfindUnitResponse/hisunits/hisunit');
foreach ($units as $unit) {
$id[] = $unit['hisid'];
}
} elseif (!$this->open) {
- $id = $this->getAttributes($response2,'soapenvBody/hisfindUnitResponse/hisunitIds/hisid');
+ $id = $this->getAttributes($response2, 'soapenvBody/hisfindUnitResponse/hisunitIds/hisid');
} else {
$this->error = true;
$this->errormsg = "url send a xml in a wrong format";
@@ -199,14 +198,12 @@ class CourseBackend_HisInOne extends CourseBackend
}
-
public function getCacheTime()
{
- return 30* 60;
+ return 30 * 60;
}
-
public function getRefreshTime()
{
return 60 * 60;
@@ -221,12 +218,11 @@ class CourseBackend_HisInOne extends CourseBackend
public function getCredentials()
{
- $credentials = ["username" => "string", "role" =>"string", "password" => "password", "open" => "bool"];
+ $credentials = ["username" => "string", "role" => "string", "password" => "password", "open" => "bool"];
return $credentials;
}
-
public function fetchSchedulesInternal($param)
{
if (empty($param)) {
@@ -270,18 +266,19 @@ class CourseBackend_HisInOne extends CourseBackend
$timetable = array();
//Here I go over the soapresponse
foreach ($events as $event) {
- $name = $this->getAttributes($event,'/hisunit/hisdefaulttext');
- if($name==false){
+ $name = $this->getAttributes($event, '/hisunit/hisdefaulttext');
+ if ($name == false) {
//if HisInOne has no default text then there is no name
$name = [''];
}
- $dates = $this->getAttributes($event,'/hisunit/hisplanelements/hisplanelement/hisplannedDates/hisplannedDate/hisindividualDates/hisindividualDate');
+ $dates = $this->getAttributes($event,
+ '/hisunit/hisplanelements/hisplanelement/hisplannedDates/hisplannedDate/hisindividualDates/hisindividualDate');
foreach ($dates as $date) {
- $roomID =$this->getAttributes($date,'/hisroomId')[0];
- $datum = $this->getAttributes($date,'/hisexecutiondate')[0];
+ $roomID = $this->getAttributes($date, '/hisroomId')[0];
+ $datum = $this->getAttributes($date, '/hisexecutiondate')[0];
if (intval($roomID) == $room && in_array($datum, $currentWeek)) {
- $startTime = $this->getAttributes($date,'hisstarttime')[0];
- $endTime = $this->getAttributes($date,'hisendtime')[0];
+ $startTime = $this->getAttributes($date, 'hisstarttime')[0];
+ $endTime = $this->getAttributes($date, 'hisendtime')[0];
$json = array(
'title' => $name[0],
'start' => $datum . " " . $startTime,
@@ -331,7 +328,7 @@ class CourseBackend_HisInOne extends CourseBackend
if ($response2 != false) {
if (isset($response2['soapenvBody']['soapenvFault'])) {
$this->error = true;
- $this->errormsg = 'SOAP-Fault'.$response2['soapenvBody']['soapenvFault']['faultcode'] . " " . $response2['soapenvBody']['soapenvFault']['faultstring'];
+ $this->errormsg = 'SOAP-Fault' . $response2['soapenvBody']['soapenvFault']['faultcode'] . " " . $response2['soapenvBody']['soapenvFault']['faultstring'];
return false;
} elseif (isset($response2['soapenvBody']['hisreadUnitResponse'])) {
$this->error = false;