summaryrefslogtreecommitdiffstats
path: root/modules-available/eventlog/pages/log.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/eventlog/pages/log.inc.php')
-rw-r--r--modules-available/eventlog/pages/log.inc.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/modules-available/eventlog/pages/log.inc.php b/modules-available/eventlog/pages/log.inc.php
new file mode 100644
index 00000000..66826b08
--- /dev/null
+++ b/modules-available/eventlog/pages/log.inc.php
@@ -0,0 +1,56 @@
+<?php
+
+class SubPage
+{
+
+ public static function doPreprocess()
+ {
+ User::assertPermission('view');
+ User::setLastSeenEvent(Property::getLastWarningId());
+ }
+
+ public static function doRender()
+ {
+ $lines = array();
+ $paginate = new Paginate("SELECT logid, dateline, logtypeid, description, extra FROM eventlog ORDER BY logid DESC", 50);
+ $res = $paginate->exec();
+ foreach ($res as $row) {
+ $row['date'] = Util::prettyTime($row['dateline']);
+ $row['icon'] = self::typeToIcon($row['logtypeid']);
+ $row['color'] = self::typeToColor($row['logtypeid']);
+ $lines[] = $row;
+ }
+
+ $paginate->render('_page', array(
+ 'list' => $lines
+ ));
+ }
+
+ private static function typeToIcon(string $type): string
+ {
+ switch ($type) {
+ case 'info':
+ return 'ok';
+ case 'warning':
+ return 'exclamation-sign';
+ case 'failure':
+ return 'remove';
+ default:
+ return 'question-sign';
+ }
+ }
+
+ private static function typeToColor(string $type): string
+ {
+ switch ($type) {
+ case 'warning':
+ return 'orange';
+ case 'failure':
+ return 'red';
+ case 'info':
+ default:
+ return '';
+ }
+ }
+
+} \ No newline at end of file