summaryrefslogblamecommitdiffstats
path: root/modules-available/eventlog/pages/log.inc.php
blob: 66826b08916558d00ae606846b7350986d95d459 (plain) (tree)



























                                                                                                                                        
                                                                












                                                  
                                                                 

                                



                                        
                            





                                  
<?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 '';
		}
	}

}