diff options
Diffstat (limited to 'modules-available/eventlog/page.inc.php')
-rw-r--r-- | modules-available/eventlog/page.inc.php | 69 |
1 files changed, 28 insertions, 41 deletions
diff --git a/modules-available/eventlog/page.inc.php b/modules-available/eventlog/page.inc.php index 250e1b24..9006c3c5 100644 --- a/modules-available/eventlog/page.inc.php +++ b/modules-available/eventlog/page.inc.php @@ -3,56 +3,43 @@ class Page_EventLog extends Page { + private $show; + protected function doPreprocess() { User::load(); - User::assertPermission('view'); - User::setLastSeenEvent(Property::getLastWarningId()); - } - protected function doRender() - { - Render::addTemplate("heading"); - $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'] = $this->typeToIcon($row['logtypeid']); - $row['color'] = $this->typeToColor($row['logtypeid']); - $lines[] = $row; + $this->show = Request::any('show', false, 'string'); + if ($this->show === false && Request::isGet()) { + if (User::hasPermission('view')) { + $this->show = 'log'; + } elseif (User::hasPermission('filter.rules.view')) { + $this->show = 'rules'; + } else { + User::assertPermission('filter.transports.view'); + $this->show = 'transports'; + } } - - $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'; + if ($this->show !== false) { + $this->show = preg_replace('/[^a-z0-9_\-]/', '', $this->show); + if (!file_exists('modules/eventlog/pages/' . $this->show . '.inc.php')) { + Message::addError('main.invalid-action', $this->show); + Util::redirect('?do=eventlog'); + } else { + require_once 'modules/eventlog/pages/' . $this->show . '.inc.php'; + SubPage::doPreprocess(); + } + } + if (Request::isPost()) { + Util::redirect('?do=eventlog&show=' . $this->show); } } - private function typeToColor($type) + protected function doRender() { - switch ($type) { - case 'info': - return ''; - case 'warning': - return 'orange'; - case 'failure': - return 'red'; - default: - return ''; + Render::addTemplate('page-header', ['active_' . $this->show => 'active']); + if ($this->show !== false) { + SubPage::doRender(); } } |