summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDirk Riestere2017-03-06 12:51:46 +0100
committerDirk Riestere2017-03-06 12:51:46 +0100
commit6a73907870f281563fd316d6a381a4b16b477db3 (patch)
treebdd64f966f5b5a29e3c96b922b59aaff7d958aa9
parentNoch mehr exeption werden gefangen und das verhalten bei errors ist vereinhei... (diff)
downloadslx-admin-6a73907870f281563fd316d6a381a4b16b477db3.tar.gz
slx-admin-6a73907870f281563fd316d6a381a4b16b477db3.tar.xz
slx-admin-6a73907870f281563fd316d6a381a4b16b477db3.zip
Noch mehr exeption werden gefangen und die errors verhalten sich jetzt wie beschrieben
-rw-r--r--modules-available/locationinfo/inc/coursebackend.inc.php23
-rw-r--r--modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php7
-rw-r--r--modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php17
3 files changed, 29 insertions, 18 deletions
diff --git a/modules-available/locationinfo/inc/coursebackend.inc.php b/modules-available/locationinfo/inc/coursebackend.inc.php
index 93381f2b..ab787738 100644
--- a/modules-available/locationinfo/inc/coursebackend.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend.inc.php
@@ -24,7 +24,8 @@ abstract class CourseBackend
/**
* CourseBackend constructor.
*/
- public final function __construct() {
+ public final function __construct()
+ {
$this->location = "";
$this->error = false;
$this->errormsg = "";
@@ -145,6 +146,8 @@ abstract class CourseBackend
$sqlr = '(' . $sqlr . ')';
$q = "SELECT locationid, calendar, serverroomid, lastcalendarupdate FROM location_info WHERE locationid IN " . $sqlr;
$dbquery1 = Database::simpleQuery($q);
+ $result = [];
+ $sRoomIDs = [];
foreach ($dbquery1->fetchAll(PDO::FETCH_ASSOC) as $row) {
$sroomID = $row['serverroomid'];
$lastUpdate = $row['lastcalendarupdate'];
@@ -153,7 +156,7 @@ abstract class CourseBackend
if (strtotime($lastUpdate) > strtotime("-" . $this->getCacheTime() . "seconds") && $this->getCacheTime() > 0) {
$result[$row['locationid']] = $calendar;
} else {
- $sroomIDs[$row['locationid']] = $sroomID;
+ $sRoomIDs[$row['locationid']] = $sroomID;
}
}
@@ -162,24 +165,28 @@ abstract class CourseBackend
$dbquery4 = Database::simpleQuery("SELECT locationid ,serverroomid, lastcalendarupdate FROM location_info WHERE serverid= :id", array('id' => $this->serverID));
foreach ($dbquery4->fetchAll(PDO::FETCH_COLUMN) as $row) {
if (strtotime($row['lastcalendarupdate']) > strtotime("-" . $this->getRefreshTime() . "seconds") && strtotime($row['lastcalendarupdate']) > strtotime("-" . $this->getCacheTime() . "seconds")) {
- $sroomIDs[$row['locationid']] = $row['serverroomid'];
+ $sRoomIDs[$row['locationid']] = $row['serverroomid'];
}
}
}
- $results = $this->fetchSchedulesInternal($sroomIDs);
- foreach ($sroomIDs as $location => $serverroom) {
- $newresult[$location] = $results[$serverroom];
+ $results = $this->fetchSchedulesInternal($sRoomIDs);
+ if ($results === false) {
+ return false;
+ }
+ $newResult = [];
+ foreach ($sRoomIDs as $location => $serverRoom) {
+ $newResult[$location] = $results[$serverRoom];
}
if ($this->getCacheTime() > 0) {
- foreach ($newresult as $key => $value) {
+ foreach ($newResult as $key => $value) {
$now = strtotime('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) {
- $result[$id] = $newresult[$id];
+ $result[$id] = $newResult[$id];
}
return $result;
}
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
index 3343d124..523823bf 100644
--- a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
@@ -54,7 +54,7 @@ class Coursebackend_Davinci extends CourseBackend
} catch (Exception $exception) {
$this->error = true;
$this->errormsg = "url did not send a xml";
- $array = [];
+ $array = false;
}
return $array;
}
@@ -95,8 +95,8 @@ class Coursebackend_Davinci extends CourseBackend
try {
foreach ($roomIds as $sroomId) {
$return = $this->fetchArray($sroomId);
- if ($this->error) {
- return $schedules;
+ if ($return === false) {
+ return false;
}
$lessons = $return['Lessons']['Lesson'];
$timetable = [];
@@ -121,6 +121,7 @@ class Coursebackend_Davinci extends CourseBackend
} catch (Exception $e) {
$this->error = true;
$this->errormsg = "url returns a wrong xml";
+ return false;
}
return $schedules;
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php
index fddd3184..ac958b2c 100644
--- a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php
@@ -139,7 +139,7 @@ class CourseBackend_HisInOne extends CourseBackend
}
} catch (Exception $exception) {
if ($this->error) {
- $id = [];
+ $id = false;
} else {
$this->error = true;
$this->errormsg = "url send a xml in a wrong format";
@@ -190,6 +190,7 @@ class CourseBackend_HisInOne extends CourseBackend
} catch (Exception $e) {
$this->error = true;
$this->errormsg = "url send a xml in a wrong format";
+ return false;
}
}
} else {
@@ -240,21 +241,21 @@ class CourseBackend_HisInOne extends CourseBackend
* Request for a timetable
*
* @param $param int the roomid
- * @return string the timetable as json
+ * @return string the timetable as json or false if there was an error
*/
public function getJson($param)
{
//get all eventIDs in a given room
$eventIDs = $this->findUnit($param);
if ($this->error == true) {
- return "[]";
+ return false;
}
//get all information on each event
$events = [];
foreach ($eventIDs as $each_event) {
$events[] = $this->readUnit((int)$each_event);
if ($this->error == true) {
- return "[]";
+ return false;
}
}
$timetable = array();
@@ -314,6 +315,7 @@ class CourseBackend_HisInOne extends CourseBackend
} catch (Exception $e) {
$this->error = true;
$this->errormsg = "url returns a wrong xml";
+ return false;
}
$timetable = json_encode($timetable);
return $timetable;
@@ -334,7 +336,7 @@ class CourseBackend_HisInOne extends CourseBackend
return $array;
}
- //Request for a timetable with roomids as array it will be empty if there was an error
+ //Request for a timetable with roomids as array it will be boolean false if there was an error
public function fetchSchedulesInternal($param)
{
$tTables = [];
@@ -345,14 +347,14 @@ class CourseBackend_HisInOne extends CourseBackend
var_dump($eventIDs);
$eventIDs = array_unique($eventIDs);
if ($this->error == true) {
- return $tTables;
+ return false;
}
}
//get all information on each event
foreach ($eventIDs as $each_event) {
$events[] = $this->readUnit(intval($each_event));
if ($this->error == true) {
- return $tTables;
+ return false;
}
}
$currentWeek = $this->getCurrentWeekDates();
@@ -412,6 +414,7 @@ class CourseBackend_HisInOne extends CourseBackend
} catch (Exception $e) {
$this->error = true;
$this->errormsg = "url returns a wrong xml";
+ return false;
}
return $tTables;
}