summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/page.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2017-04-18 15:53:07 +0200
committerSimon Rettberg2017-04-18 15:53:07 +0200
commit865db83c68f919d2ecf6fa5c0fed37f70541ba15 (patch)
treec1f10a2d4a8a30edf8881d7b2ac7f093a1f3795e /modules-available/locationinfo/page.inc.php
parent[locations] Make Location::getTree() public (diff)
downloadslx-admin-865db83c68f919d2ecf6fa5c0fed37f70541ba15.tar.gz
slx-admin-865db83c68f919d2ecf6fa5c0fed37f70541ba15.tar.xz
slx-admin-865db83c68f919d2ecf6fa5c0fed37f70541ba15.zip
[locationinfo] Use Location helper for getRoomTree, check backend validity in getCalendar
Diffstat (limited to 'modules-available/locationinfo/page.inc.php')
-rw-r--r--modules-available/locationinfo/page.inc.php27
1 files changed, 2 insertions, 25 deletions
diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php
index d5f98cce..31702dff 100644
--- a/modules-available/locationinfo/page.inc.php
+++ b/modules-available/locationinfo/page.inc.php
@@ -286,7 +286,7 @@ class Page_LocationInfo extends Page
$serverInstance = CourseBackend::getInstance($dbresult['servertype']);
if ($serverInstance === false) {
- $this->setServerError($serverid, 'Unknown backend type: ' . $dbresult['servertype']);
+ LocationInfo::setServerError($serverid, 'Unknown backend type: ' . $dbresult['servertype']);
return;
}
$credentialsOk = $serverInstance->setCredentials(json_decode($dbresult['credentials'], true), $dbresult['serverurl'], $serverid);
@@ -295,32 +295,9 @@ class Page_LocationInfo extends Page
$connectionOk = $serverInstance->checkConnection();
}
- if (!$credentialsOk || !$connectionOk) {
- $this->setServerError($serverid, $serverInstance->getError());
- } else {
- $this->setServerError($serverid, null);
- }
+ LocationInfo::setServerError($serverid, $serverInstance->getError());
}
- /**
- * Set current error message of given server. Pass empty message to clear.
- * @param int $serverid id of server
- * @param string $message error message to set
- */
- private function setServerError($serverid, $message)
- {
- if (empty($message)) {
- Database::exec("UPDATE `setting_location_info` SET error = NULL
- WHERE serverid = :id", array('id' => $serverid));
- } else {
- $error = json_encode(array(
- 'timestamp' => time(),
- 'error' => $message
- ));
- Database::exec("UPDATE `setting_location_info` SET error = :error
- WHERE serverid = :id", array('id' => $serverid, 'error' => $error));
- }
- }
/**
* Sets the new hidden value and checks childs and parents.