summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/page.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2019-03-07 13:29:48 +0100
committerSimon Rettberg2019-03-07 13:29:48 +0100
commit35078669abfbe296b578b3f131a30dcb38ed99f5 (patch)
tree2b1ee1010ce9605007bf0cc95e80ed9767843212 /modules-available/locationinfo/page.inc.php
parent[locationinfo] Fix form<->button relation (delete, check, etc.) (diff)
downloadslx-admin-35078669abfbe296b578b3f131a30dcb38ed99f5.tar.gz
slx-admin-35078669abfbe296b578b3f131a30dcb38ed99f5.tar.xz
slx-admin-35078669abfbe296b578b3f131a30dcb38ed99f5.zip
[locationinfo] Add error log for backends
Diffstat (limited to 'modules-available/locationinfo/page.inc.php')
-rw-r--r--modules-available/locationinfo/page.inc.php43
1 files changed, 38 insertions, 5 deletions
diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php
index 7be875d0..b082c0f4 100644
--- a/modules-available/locationinfo/page.inc.php
+++ b/modules-available/locationinfo/page.inc.php
@@ -59,11 +59,16 @@ class Page_LocationInfo extends Page
*/
protected function doRender()
{
+ $data = array('class-' . $this->show => 'active', 'errors' => []);
// Do this here so we always see backend errors
if (User::hasPermission('backend.*')) {
$backends = $this->loadBackends();
+ foreach ($backends as $backend) {
+ if (!empty($backend['error'])) {
+ $data['errors'][] = $backend;
+ }
+ }
}
- $data = array('class-' . $this->show => 'active');
Permission::addGlobalTags($data['perms'], null, ['backend.*', 'location.*', 'panel.list']);
Render::addTemplate('page-tabs', $data);
switch ($this->show) {
@@ -79,6 +84,9 @@ class Page_LocationInfo extends Page
case 'panels':
$this->showPanelsTable();
break;
+ case 'backendlog':
+ $this->showBackendLog();
+ break;
default:
Util::redirect('?do=locationinfo');
}
@@ -471,7 +479,7 @@ class Page_LocationInfo extends Page
$serverInstance->checkConnection();
}
- LocationInfo::setServerError($serverid, $serverInstance->getError());
+ LocationInfo::setServerError($serverid, $serverInstance->getErrors());
}
private function loadBackends()
@@ -495,14 +503,14 @@ class Page_LocationInfo extends Page
}
if (!empty($row['error'])) {
- $row['autherror'] = true;
$error = json_decode($row['error'], true);
if (isset($error['timestamp'])) {
- $time = date('Y/m/d H:i:s', $error['timestamp']);
+ $time = date('Y-m-d H:i', $error['timestamp']);
} else {
$time = '???';
}
- Message::addError('auth-failed', $row['servername'], $time, $error['error']);
+ $row['error'] = $error['error'];
+ $row['errtime'] = $time;
}
$serverlist[] = $row;
}
@@ -523,6 +531,31 @@ class Page_LocationInfo extends Page
Render::addTemplate('page-servers', $data);
}
+ private function showBackendLog()
+ {
+ $id = Request::get('serverid', false, 'int');
+ if ($id === false) {
+ Message::addError('main.parameter-missing', 'serverid');
+ Util::redirect('?do=locationinfo');
+ }
+ $server = Database::queryFirst('SELECT servername FROM locationinfo_coursebackend
+ WHERE serverid = :id', ['id' => $id]);
+ if ($server === false) {
+ Message::addError('invalid-server-id', $id);
+ Util::redirect('?do=locationinfo');
+ }
+ $server['list'] = [];
+ $res = Database::simpleQuery('SELECT dateline, message FROM locationinfo_backendlog
+ WHERE serverid = :id ORDER BY logid DESC LIMIT 100', ['id' => $id]);
+ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ $row['dateline_s'] = Util::prettyTime($row['dateline']);
+ $row['class'] = substr($row['message'], 0, 3) === '[F]' ? 'text-danger' : 'text-warning';
+ $row['message'] = Substr($row['message'], 3);
+ $server['list'][] = $row;
+ }
+ Render::addTemplate('page-server-log', $server);
+ }
+
private function showLocationsTable()
{
$allowedLocations = User::getAllowedLocations('location.edit');