icingaweb2-module-director/application/tables/ActivityLogTable.php

69 lines
1.7 KiB
PHP
Raw Normal View History

2015-06-01 12:18:13 +02:00
<?php
namespace Icinga\Module\Director\Tables;
use Icinga\Module\Director\Web\Table\QuickTable;
class ActivityLogTable extends QuickTable
{
protected $filters = array();
protected $extraParams = array();
2015-06-01 12:18:13 +02:00
public function getColumns()
{
return array(
'id' => 'l.id',
'change_time' => 'l.change_time',
'author' => 'l.author',
'action' => "CONCAT(l.action_name || ' ' || REPLACE(l.object_type, 'icinga_', '') || ' \"' || l.object_name || '\"')"
);
}
protected function getActionUrl($row)
2015-06-01 12:18:13 +02:00
{
return $this->url(
'director/show/activitylog',
array_merge(array('id' => $row->id), $this->extraParams
));
2015-06-01 12:18:13 +02:00
}
public function getTitles()
{
$view = $this->view();
return array(
2015-11-17 21:16:37 +01:00
'change_time' => $view->translate('Timestamp'),
'author' => $view->translate('Author'),
'action' => $view->translate('Action'),
2015-06-01 12:18:13 +02:00
);
}
public function filterObject($type, $name)
{
$this->filters[] = array('l.object_type = ?', $type);
$this->filters[] = array('l.object_name = ?', $name);
$this->extraParams = array(
'type' => $type,
'name' => $name,
);
return $this;
}
public function getBaseQuery()
2015-06-01 12:18:13 +02:00
{
$db = $this->connection()->getConnection();
$query = $db->select()->from(
array('l' => 'director_activity_log'),
array()
2015-06-01 12:18:13 +02:00
)->order('change_time DESC');
foreach ($this->filters as $filter) {
$query->where($filter[0], $filter[1]);
}
return $query;
2015-06-01 12:18:13 +02:00
}
}