blob: ebd89da7e78bcf62523181c098a39632b5274a4e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
<?php
namespace Icinga\Module\Director\Web\Table;
use Zend_Db_Select as ZfSelect;
class ObjectsTableCommand extends ObjectsTable implements FilterableByUsage
{
// TODO: Notifications separately?
protected $searchColumns = [
'o.object_name',
'o.command',
];
protected $columns = [
'uuid' => 'o.uuid',
'object_name' => 'o.object_name',
'object_type' => 'o.object_type',
'disabled' => 'o.disabled',
'command' => 'o.command',
];
protected $showColumns = [
'object_name' => 'Command',
'command' => 'Command line'
];
private $objectType;
public function setType($type)
{
$this->getQuery()->where('object_type = ?', $type);
return $this;
}
public function showOnlyUsed()
{
$this->getQuery()->where(
'('
. 'EXISTS (SELECT check_command_id FROM icinga_host WHERE check_command_id = o.id)'
. ' OR EXISTS (SELECT check_command_id FROM icinga_service WHERE check_command_id = o.id)'
. ' OR EXISTS (SELECT event_command_id FROM icinga_host WHERE event_command_id = o.id)'
. ' OR EXISTS (SELECT event_command_id FROM icinga_service WHERE event_command_id = o.id)'
. ' OR EXISTS (SELECT command_id FROM icinga_notification WHERE command_id = o.id)'
. ')'
);
}
public function showOnlyUnUsed()
{
$this->getQuery()->where(
'('
. 'NOT EXISTS (SELECT check_command_id FROM icinga_host WHERE check_command_id = o.id)'
. ' AND NOT EXISTS (SELECT check_command_id FROM icinga_service WHERE check_command_id = o.id)'
. ' AND NOT EXISTS (SELECT event_command_id FROM icinga_host WHERE event_command_id = o.id)'
. ' AND NOT EXISTS (SELECT event_command_id FROM icinga_service WHERE event_command_id = o.id)'
. ' AND NOT EXISTS (SELECT command_id FROM icinga_notification WHERE command_id = o.id)'
. ')'
);
}
protected function applyObjectTypeFilter(ZfSelect $query, ZfSelect $right = null)
{
return $query;
}
}
|