From 4f944749baae1fa73b2c41f5354619434418ce6a Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 28 Sep 2015 19:16:13 +0200 Subject: [PATCH] Allow filtering for contactgroups in contact list refs #5543 --- .../Backend/Ido/Query/ContactQuery.php | 25 +++++++++++++++++++ .../library/Monitoring/DataView/Contact.php | 5 +++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ContactQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ContactQuery.php index bd156e1761..4926a3fd38 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ContactQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ContactQuery.php @@ -20,6 +20,11 @@ class ContactQuery extends IdoQuery 'instances' => array( 'instance_name' => 'i.instance_name' ), + 'contactgroups' => array( + 'contactgroup' => 'cgo.name1 COLLATE latin1_general_ci', + 'contactgroup_name' => 'cgo.name1', + 'contactgroup_alias' => 'cg.alias COLLATE latin1_general_ci' + ), 'contacts' => array( 'contact_id' => 'c.contact_id', 'contact' => 'co.name1 COLLATE latin1_general_ci', @@ -186,6 +191,26 @@ protected function joinServices() ); } + /** + * Join contacts + */ + protected function joinContactgroups() + { + $this->select->joinLeft( + array('cgm' => $this->prefix . 'contactgroup_members'), + 'co.object_id = cgm.contact_object_id', + array() + )->joinLeft( + array('cg' => $this->prefix . 'contactgroups'), + 'cgm.contactgroup_id = cg.contactgroup_id', + array() + )->joinLeft( + array('cgo' => $this->prefix . 'objects'), + 'cg.contactgroup_object_id = cgo.object_id AND cgo.is_active = 1 AND cgo.objecttype_id = 11', + array() + ); + } + /** * Join instances */ diff --git a/modules/monitoring/library/Monitoring/DataView/Contact.php b/modules/monitoring/library/Monitoring/DataView/Contact.php index 5add208cd0..64500f9a90 100644 --- a/modules/monitoring/library/Monitoring/DataView/Contact.php +++ b/modules/monitoring/library/Monitoring/DataView/Contact.php @@ -33,7 +33,10 @@ public function getColumns() 'contact_notify_host_flapping', 'contact_notify_host_downtime', 'contact_notify_host_timeperiod', - 'contact_notify_service_timeperiod' + 'contact_notify_service_timeperiod', + 'contactgroup', + 'contactgroup_name', + 'contactgroup_alias' ); }