diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:31 +0000 |
commit | f66ab8dae2f3d0418759f81a3a64dc9517a62449 (patch) | |
tree | fbff2135e7013f196b891bbde54618eb050e4aaf /library/Director/Web/Table/ObjectsTableCommand.php | |
parent | Initial commit. (diff) | |
download | icingaweb2-module-director-f66ab8dae2f3d0418759f81a3a64dc9517a62449.tar.xz icingaweb2-module-director-f66ab8dae2f3d0418759f81a3a64dc9517a62449.zip |
Adding upstream version 1.10.2.upstream/1.10.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | library/Director/Web/Table/ObjectsTableCommand.php | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/library/Director/Web/Table/ObjectsTableCommand.php b/library/Director/Web/Table/ObjectsTableCommand.php new file mode 100644 index 0000000..ebd89da --- /dev/null +++ b/library/Director/Web/Table/ObjectsTableCommand.php @@ -0,0 +1,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; + } +} |