From e42548fc80488aba0ebb5ea9cfccc3be7002277d Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 23 Sep 2015 13:02:43 +0200 Subject: [PATCH] MonitoredObject: Allow to fetch servicegroups for host objects refs #5600 --- .../library/Monitoring/Object/MonitoredObject.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php index 76e666d89..d4823892c 100644 --- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php +++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php @@ -565,12 +565,15 @@ abstract class MonitoredObject implements Filterable */ public function fetchServicegroups() { - $this->servicegroups = $this->backend->select() + $query = $this->backend->select() ->from('servicegroup', array('servicegroup_name', 'servicegroup_alias')) - ->where('host_name', $this->host_name) - ->where('service_description', $this->service_description) - ->applyFilter($this->getFilter()) - ->fetchPairs(); + ->where('host_name', $this->host_name); + + if ($this->type === self::TYPE_SERVICE) { + $query->where('service_description', $this->service_description); + } + + $this->servicegroups = $query->applyFilter($this->getFilter())->fetchPairs(); return $this; }