summaryrefslogtreecommitdiffstats
path: root/modules/eventlog
diff options
context:
space:
mode:
authorJonathan Bauer2016-04-01 16:50:13 +0200
committerJonathan Bauer2016-04-01 16:50:13 +0200
commitdbc0d9614421e064cc62aacf116ebb783c83f2f3 (patch)
tree091844b8578ff1d9ac18edfd3cee3e63210133d7 /modules/eventlog
parent[ldapauth] Add homedir conf to ldap wizard (diff)
downloadslx-admin-dbc0d9614421e064cc62aacf116ebb783c83f2f3.tar.gz
slx-admin-dbc0d9614421e064cc62aacf116ebb783c83f2f3.tar.xz
slx-admin-dbc0d9614421e064cc62aacf116ebb783c83f2f3.zip
[merge] merging c3sl / fr - initial commit
Diffstat (limited to 'modules/eventlog')
-rw-r--r--modules/eventlog/config.json4
-rw-r--r--modules/eventlog/module.inc.php70
-rw-r--r--modules/eventlog/templates/_page.html41
3 files changed, 115 insertions, 0 deletions
diff --git a/modules/eventlog/config.json b/modules/eventlog/config.json
new file mode 100644
index 00000000..d42dc3e3
--- /dev/null
+++ b/modules/eventlog/config.json
@@ -0,0 +1,4 @@
+{
+ "category":"status",
+ "enabled":"true"
+}
diff --git a/modules/eventlog/module.inc.php b/modules/eventlog/module.inc.php
new file mode 100644
index 00000000..7cfc8a55
--- /dev/null
+++ b/modules/eventlog/module.inc.php
@@ -0,0 +1,70 @@
+<?php
+
+class Page_EventLog extends Page
+{
+
+ protected function doPreprocess()
+ {
+ User::load();
+ if (!User::hasPermission('superadmin')) {
+ Message::addError('no-permission');
+ Util::redirect('?do=Main');
+ }
+ User::setLastSeenEvent(Property::getLastWarningId());
+ }
+
+ protected function doRender()
+ {
+ Render::setTitle(Dictionary::translate('lang_titleEventLog'));
+ $today = date('d.m.Y');
+ $yesterday = date('d.m.Y', time() - 86400);
+ $lines = array();
+ $paginate = new Paginate("SELECT logid, dateline, logtypeid, description, extra FROM eventlog ORDER BY logid DESC", 50);
+ $res = $paginate->exec();
+ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ $day = date('d.m.Y', $row['dateline']);
+ if ($day === $today) {
+ $day = Dictionary::translate('today');
+ } elseif ($day === $yesterday) {
+ $day = Dictionary::translate('yesterday');
+ }
+ $row['date'] = $day . date(' H:i', $row['dateline']);
+ $row['icon'] = $this->typeToIcon($row['logtypeid']);
+ $row['color'] = $this->typeToColor($row['logtypeid']);
+ $lines[] = $row;
+ }
+
+ $paginate->render('_page', array(
+ 'list' => $lines
+ ));
+ }
+
+ private function typeToIcon($type)
+ {
+ switch ($type) {
+ case 'info':
+ return 'ok';
+ case 'warning':
+ return 'exclamation-sign';
+ case 'failure':
+ return 'remove';
+ default:
+ return 'question-sign';
+ }
+ }
+
+ private function typeToColor($type)
+ {
+ switch ($type) {
+ case 'info':
+ return '';
+ case 'warning':
+ return 'orange';
+ case 'failure':
+ return 'red';
+ default:
+ return '';
+ }
+ }
+
+}
diff --git a/modules/eventlog/templates/_page.html b/modules/eventlog/templates/_page.html
new file mode 100644
index 00000000..2e657805
--- /dev/null
+++ b/modules/eventlog/templates/_page.html
@@ -0,0 +1,41 @@
+<h1>{{lang_eventLog}}</h1>
+{{{pagenav}}}
+<table class="table table-striped table-condensed">
+ <thead>
+ <th width="1"></th>
+ <th>{{lang_when}}</th>
+ <th>{{lang_event}}</th>
+ <th width="1">{{lang_details}}</th>
+ </thead>
+ <tbody>
+ {{#list}}
+ <tr>
+ <td><span class="glyphicon glyphicon-{{icon}}" title="{{logtypeid}}"></span></td>
+ <td class="text-right" nowrap="nowrap">{{date}}</td>
+ <td class="{{color}}">{{description}}</td>
+ <td>{{#extra}}
+ <a class="btn btn-default btn-xs pull-left" onclick="$('#details-body').html($('#extra-{{logid}}').html())" data-toggle="modal" data-target="#myModal">&raquo;</a>
+ <div class="hidden" id="extra-{{logid}}">{{extra}}</div>
+ {{/extra}}</td>
+ </tr>
+ {{/list}}
+ </tbody>
+</table>
+{{{pagenav}}}
+
+<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+ <div class="modal-dialog modal-lg">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
+ <h4 class="modal-title" id="myModalLabel">{{lang_details}}</h4>
+ </div>
+ <div class="modal-body">
+ <pre id="details-body"></pre>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+ </div>
+ </div>
+ </div>
+</div>