Allow filtering for contactgroups in contact list

refs #5543
This commit is contained in:
Matthias Jentsch 2015-09-28 19:16:13 +02:00 committed by Eric Lippmann
parent 27e1611831
commit 65a2b539f1
2 changed files with 29 additions and 1 deletions

View File

@ -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 @@ class ContactQuery extends IdoQuery
);
}
/**
* 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
*/

View File

@ -33,7 +33,10 @@ class Contact extends DataView
'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'
);
}