summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/api.inc.php
diff options
context:
space:
mode:
authorJannik Schönartz2017-03-09 00:23:56 +0100
committerJannik Schönartz2017-03-09 00:23:56 +0100
commit326766e9ce7caeaa653cb2bac20962d1147a7e6a (patch)
treefa48f4e8530dc64cabb4a48c04bde9149ba62155 /modules-available/locationinfo/api.inc.php
parentfrontend: fixed vertical mode in doorsign (diff)
downloadslx-admin-326766e9ce7caeaa653cb2bac20962d1147a7e6a.tar.gz
slx-admin-326766e9ce7caeaa653cb2bac20962d1147a7e6a.tar.xz
slx-admin-326766e9ce7caeaa653cb2bac20962d1147a7e6a.zip
Locationinfo: Errors from the CourseBackend are now safes in the db and shown in the Admin-Panel. Refresh-button added for the servers. Install.php needs to be executed!
Diffstat (limited to 'modules-available/locationinfo/api.inc.php')
-rw-r--r--modules-available/locationinfo/api.inc.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php
index 4fd7eee5..96685cab 100644
--- a/modules-available/locationinfo/api.inc.php
+++ b/modules-available/locationinfo/api.inc.php
@@ -66,13 +66,17 @@ function getCalendar($idList) {
$resultarray = array();
foreach ($serverList as $serverid => $server) {
$serverInstance = CourseBackend::getInstance($server['type']);
- $serverInstance->setCredentials($server['credentials'], $server['url'], $serverid);
- echo $serverInstance->getError();
+ $setCred = $serverInstance->setCredentials($server['credentials'], $server['url'], $serverid);
+
$calendarFromBackend = $serverInstance->fetchSchedule($server['idlist']);
$formattedArray = array();
- if ($calendarFromBackend === false) {
- // TODO: write error in db.
+ if ($calendarFromBackend === false || $setCred === false) {
+ $error['timestamp'] = time();
+ $error['error'] = $serverInstance->getError();
+ Database::exec("UPDATE `setting_location_info` Set error=:error WHERE serverid=:id", array('id' => $serverid, 'error' => json_encode($error, true)));
+ } else {
+ Database::exec("UPDATE `setting_location_info` Set error=NULL WHERE serverid=:id", array('id' => $serverid));
}
foreach ($calendarFromBackend as $key => $value) {