2015-06-03 14:34:54 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\Tables;
|
|
|
|
|
2015-12-15 17:16:07 +01:00
|
|
|
use Icinga\Module\Director\Web\Table\IcingaObjectTable;
|
2015-06-03 14:34:54 +02:00
|
|
|
|
2016-03-18 13:02:45 +01:00
|
|
|
// TODO: quickform once apply has been moved elsewhere
|
2015-12-15 17:16:07 +01:00
|
|
|
class IcingaServiceTable extends IcingaObjectTable
|
2015-06-03 14:34:54 +02:00
|
|
|
{
|
2015-07-29 15:30:10 +02:00
|
|
|
protected $searchColumns = array(
|
|
|
|
'service',
|
|
|
|
);
|
|
|
|
|
2015-06-03 14:34:54 +02:00
|
|
|
public function getColumns()
|
|
|
|
{
|
|
|
|
return array(
|
2015-12-15 17:16:07 +01:00
|
|
|
'id' => 's.id',
|
|
|
|
'service' => 's.object_name',
|
|
|
|
'object_type' => 's.object_type',
|
2015-06-03 14:34:54 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getActionUrl($row)
|
|
|
|
{
|
2016-03-18 13:02:45 +01:00
|
|
|
// TODO: Remove once we got a separate apply table
|
2016-03-06 14:28:12 +01:00
|
|
|
if ($row->object_type === 'apply') {
|
|
|
|
$params['id'] = $row->id;
|
|
|
|
} else {
|
|
|
|
$params = array('name' => $row->service);
|
2016-03-18 13:02:45 +01:00
|
|
|
|
2015-12-10 12:55:34 +01:00
|
|
|
}
|
2016-03-06 14:28:12 +01:00
|
|
|
|
2015-12-10 12:55:34 +01:00
|
|
|
return $this->url('director/service', $params);
|
2015-06-03 14:34:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitles()
|
|
|
|
{
|
|
|
|
$view = $this->view();
|
|
|
|
return array(
|
|
|
|
'service' => $view->translate('Servicename'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-07-30 16:24:17 +02:00
|
|
|
public function getUnfilteredQuery()
|
2015-06-03 14:34:54 +02:00
|
|
|
{
|
|
|
|
$db = $this->connection()->getConnection();
|
|
|
|
$query = $db->select()->from(
|
|
|
|
array('s' => 'icinga_service'),
|
2015-07-23 16:19:22 +02:00
|
|
|
array()
|
2015-06-03 14:34:54 +02:00
|
|
|
);
|
|
|
|
|
2015-07-23 16:19:22 +02:00
|
|
|
return $query;
|
2015-06-03 14:34:54 +02:00
|
|
|
}
|
2015-07-30 16:24:17 +02:00
|
|
|
|
|
|
|
public function getBaseQuery()
|
|
|
|
{
|
2016-03-18 13:02:45 +01:00
|
|
|
// TODO: remove apply
|
|
|
|
return $this->getUnfilteredQuery()->where(
|
|
|
|
's.object_type IN (?)',
|
|
|
|
array('template', 'apply')
|
|
|
|
);
|
2015-07-30 16:24:17 +02:00
|
|
|
}
|
2015-06-03 14:34:54 +02:00
|
|
|
}
|