diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicecommenthistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicecommenthistoryQuery.php index 39ffbfc10..e2256d259 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicecommenthistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicecommenthistoryQuery.php @@ -23,6 +23,11 @@ class ServicecommenthistoryQuery extends IdoQuery */ protected $groupOrigin = array('hostgroups', 'servicegroups', 'services'); + protected $subQueryTargets = array( + 'hostgroups' => 'hostgroup', + 'servicegroups' => 'servicegroup' + ); + /** * {@inheritdoc} */ @@ -169,4 +174,19 @@ class ServicecommenthistoryQuery extends IdoQuery array() ); } + + protected function joinSubQuery(IdoQuery $query, $name) + { + if ($name === 'hostgroup') { + $query->joinVirtualTable('services'); + + return ['so.object_id', 'so.object_id']; + } elseif ($name === 'servicegroup') { + $query->joinVirtualTable('members'); + + return ['sgm.service_object_id', 'so.object_id']; + } + + return parent::joinSubQuery($query, $name); + } }