diff --git a/library/Director/Web/Table/IcingaHostAppliedServicesTable.php b/library/Director/Web/Table/IcingaHostAppliedServicesTable.php index fc7bf64d..170f817d 100644 --- a/library/Director/Web/Table/IcingaHostAppliedServicesTable.php +++ b/library/Director/Web/Table/IcingaHostAppliedServicesTable.php @@ -74,6 +74,10 @@ class IcingaHostAppliedServicesTable extends SimpleQueryBasedTable ], $attributes); } + /** + * @return \Icinga\Data\SimpleQuery + * @throws \Icinga\Exception\IcingaException + */ public function prepareQuery() { $services = []; @@ -94,6 +98,10 @@ class IcingaHostAppliedServicesTable extends SimpleQueryBasedTable ]); } + /*** + * @return array + * @throws \Icinga\Exception\IcingaException + */ protected function getAllApplyRules() { if ($this->allApplyRules === null) { @@ -106,6 +114,10 @@ class IcingaHostAppliedServicesTable extends SimpleQueryBasedTable return $this->allApplyRules; } + /** + * @return array + * @throws \Icinga\Exception\IcingaException + */ protected function fetchAllApplyRules() { $db = $this->db; @@ -119,7 +131,7 @@ class IcingaHostAppliedServicesTable extends SimpleQueryBasedTable ] )->joinLeft( ['hsb' => 'icinga_host_service_blacklist'], - 's.id = hsb.service_id', + $db->quoteInto('s.id = hsb.service_id AND hsb.host_id = ?', $this->host->get('id')), [] )->group('s.id')->where('object_type = ? AND assign_filter IS NOT NULL', 'apply'); diff --git a/library/Director/Web/Table/IcingaServiceSetServiceTable.php b/library/Director/Web/Table/IcingaServiceSetServiceTable.php index 43b8d6a0..ccdf6448 100644 --- a/library/Director/Web/Table/IcingaServiceSetServiceTable.php +++ b/library/Director/Web/Table/IcingaServiceSetServiceTable.php @@ -185,7 +185,8 @@ class IcingaServiceSetServiceTable extends ZfQueryBasedTable */ public function prepareQuery() { - $query = $this->db()->select()->from( + $db = $this->db(); + $query = $db->select()->from( ['s' => 'icinga_service'], [ 'id' => 's.id', @@ -208,7 +209,10 @@ class IcingaServiceSetServiceTable extends ZfQueryBasedTable if ($this->affectedHost) { $query->joinLeft( ['hsb' => 'icinga_host_service_blacklist'], - 's.id = hsb.service_id', + $db->quoteInto( + 's.id = hsb.service_id AND hsb.host_id = ?', + $this->affectedHost->get('id') + ), [] )->group('s.id')->columns([ 'blacklisted' => "CASE WHEN hsb.service_id IS NULL THEN 'n' ELSE 'y' END",