From aa86e073b0111e61b1ba9a080604d945381ccb6a Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 12 Apr 2017 14:04:56 +0200 Subject: [locationinfo] Format php files --- .../coursebackend/coursebackend_davinci.inc.php | 4 +- .../inc/coursebackend/coursebackend_dummy.inc.php | 129 ++++++++++++--------- .../coursebackend/coursebackend_hisinone.inc.php | 31 +++-- 3 files changed, 90 insertions(+), 74 deletions(-) (limited to 'modules-available/locationinfo/inc/coursebackend') 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 @@ 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; -- cgit v1.2.3-55-g7522