diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php
index efde0a749..d1fba8a72 100644
--- a/modules/monitoring/application/controllers/ListController.php
+++ b/modules/monitoring/application/controllers/ListController.php
@@ -342,6 +342,9 @@ class ListController extends Controller
$this->view->orientation = $orientation;
}
+ /**
+ * List contact groups
+ */
public function contactgroupsAction()
{
$this->addTitleTab(
@@ -350,39 +353,22 @@ class ListController extends Controller
$this->translate('List contact groups')
);
- $query = $this->backend->select()->from('contactgroup', array(
+ $contactGroups = $this->backend->select()->from('contactgroup', array(
'contactgroup_name',
'contactgroup_alias',
- 'contact_name',
- 'contact_alias',
- 'contact_email',
- 'contact_pager'
+ 'contact_count'
));
- $this->applyRestriction('monitoring/filter/objects', $query);
- $this->filterQuery($query);
+ $this->applyRestriction('monitoring/filter/objects', $contactGroups);
+ $this->filterQuery($contactGroups);
+ $this->setupPaginationControl($contactGroups);
+ $this->setupLimitControl();
$this->setupSortControl(array(
'contactgroup_name' => $this->translate('Contactgroup Name'),
'contactgroup_alias' => $this->translate('Contactgroup Alias')
- ), $query);
+ ), $contactGroups);
- // Fetch and prepare all contact groups:
- $contactgroups = $query->getQuery()->fetchAll();
- $groupData = array();
- foreach ($contactgroups as $c) {
- if (!array_key_exists($c->contactgroup_name, $groupData)) {
- $groupData[$c->contactgroup_name] = array(
- 'alias' => $c->contactgroup_alias,
- 'contacts' => array()
- );
- }
- if (isset ($c->contact_name)) {
- $groupData[$c->contactgroup_name]['contacts'][] = $c;
- }
- }
-
- // TODO: Find a better naming
- $this->view->groupData = $groupData;
+ $this->view->contactGroups = $contactGroups;
}
/**
diff --git a/modules/monitoring/application/views/scripts/list/contactgroups.phtml b/modules/monitoring/application/views/scripts/list/contactgroups.phtml
index eea6302b1..7deb4e6fb 100644
--- a/modules/monitoring/application/views/scripts/list/contactgroups.phtml
+++ b/modules/monitoring/application/views/scripts/list/contactgroups.phtml
@@ -12,42 +12,39 @@ if (! $this->compact): ?>
-translate('No contactgroups found matching the filter') . '
';
- return;
-}
-?>
-
+hasResult()): ?>
+ = $this->translate('No contact groups found matching the filter') ?>
+
+
+
-
- |
- = $this->translate('Contact Group ') ?> |
- = $this->translate('Alias') ?> |
-
+
+ |
+ = $this->translate('Contact Group ') ?> |
+ = $this->translate('Alias') ?> |
+
-
- $groupInfo): ?>
-
- |
- = count($groupInfo['contacts']) ?>
- |
+
+
+ |
+ = $contactGroup->contact_count ?>
+ |
+
+ = $this->qlink(
+ $contactGroup->contactgroup_name,
+ 'monitoring/list/contacts',
+ array('contactgroup_name' => $contactGroup->contactgroup_name),
+ array('title' => sprintf(
+ $this->translate('Show detailed information about %s'),
+ $contactGroup->contactgroup_name
+ ))
+ ) ?>
+ |
- = $this->qlink(
- $groupName,
- 'monitoring/list/contacts',
- array('contactgroup_name' => $groupName),
- array('title' => sprintf(
- $this->translate('Show detailed information about %s'),
- $groupName
- ))
- ) ?>
- |
-
-
- = $groupInfo['alias'] ?>
-
+ contactgroup_name !== $contactGroup->contactgroup_alias): ?>
+ = $contactGroup->contactgroup_alias ?>
+
|
diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ContactgroupQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ContactgroupQuery.php
index f0afc0768..c861d1fc9 100644
--- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ContactgroupQuery.php
+++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ContactgroupQuery.php
@@ -16,12 +16,12 @@ class ContactgroupQuery extends IdoQuery
/**
* {@inheritdoc}
*/
- protected $groupBase = array('contactgroups' => array('cg.contactgroup_id', 'cgo.object_id'));
+ protected $groupBase = array('contactgroups' => array('cg.contactgroup_id'));
/**
* {@inheritdoc}
*/
- protected $groupOrigin = array('contacts', 'hosts', 'services');
+ protected $groupOrigin = array('hosts', 'members', 'services');
/**
* {@inheritdoc}
@@ -32,28 +32,8 @@ class ContactgroupQuery extends IdoQuery
'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',
- 'contact_name' => 'co.name1',
- 'contact_alias' => 'c.alias COLLATE latin1_general_ci',
- 'contact_email' => 'c.email_address COLLATE latin1_general_ci',
- 'contact_pager' => 'c.pager_address',
- 'contact_object_id' => 'c.contact_object_id',
- 'contact_has_host_notfications' => 'c.host_notifications_enabled',
- 'contact_has_service_notfications' => 'c.service_notifications_enabled',
- 'contact_can_submit_commands' => 'c.can_submit_commands',
- 'contact_notify_service_recovery' => 'c.notify_service_recovery',
- 'contact_notify_service_warning' => 'c.notify_service_warning',
- 'contact_notify_service_critical' => 'c.notify_service_critical',
- 'contact_notify_service_unknown' => 'c.notify_service_unknown',
- 'contact_notify_service_flapping' => 'c.notify_service_flapping',
- 'contact_notify_service_downtime' => 'c.notify_service_recovery',
- 'contact_notify_host_recovery' => 'c.notify_host_recovery',
- 'contact_notify_host_down' => 'c.notify_host_down',
- 'contact_notify_host_unreachable' => 'c.notify_host_unreachable',
- 'contact_notify_host_flapping' => 'c.notify_host_flapping',
- 'contact_notify_host_downtime' => 'c.notify_host_downtime'
+ 'members' => array(
+ 'contact_count' => 'COUNT(cgm.contactgroup_member_id)'
),
'hostgroups' => array(
'hostgroup' => 'hgo.name1 COLLATE latin1_general_ci',
@@ -99,22 +79,18 @@ class ContactgroupQuery extends IdoQuery
}
/**
- * Join contacts
+ * Join contact group members
*/
- protected function joinContacts()
+ protected function joinMembers()
{
$this->select->joinLeft(
array('cgm' => $this->prefix . 'contactgroup_members'),
'cgm.contactgroup_id = cg.contactgroup_id',
array()
- )->joinLeft(
+ )->join(
array('co' => $this->prefix . 'objects'),
'co.object_id = cgm.contact_object_id AND co.is_active = 1 AND co.objecttype_id = 10',
array()
- )->joinLeft(
- array('c' => $this->prefix . 'contacts'),
- 'c.contact_object_id = co.object_id',
- array()
);
}
diff --git a/modules/monitoring/library/Monitoring/DataView/Contactgroup.php b/modules/monitoring/library/Monitoring/DataView/Contactgroup.php
index cb12b0e2f..84eecd101 100644
--- a/modules/monitoring/library/Monitoring/DataView/Contactgroup.php
+++ b/modules/monitoring/library/Monitoring/DataView/Contactgroup.php
@@ -11,31 +11,9 @@ class Contactgroup extends DataView
public function getColumns()
{
return array(
- 'instance_name',
'contactgroup_name',
'contactgroup_alias',
- 'contact_object_id',
- 'contact_id',
- 'contact_name',
- 'contact_alias',
- 'contact_email',
- 'contact_pager',
- 'contact_has_host_notfications',
- 'contact_has_service_notfications',
- 'contact_can_submit_commands',
- 'contact_notify_service_recovery',
- 'contact_notify_service_warning',
- 'contact_notify_service_critical',
- 'contact_notify_service_unknown',
- 'contact_notify_service_flapping',
- 'contact_notify_service_downtime',
- 'contact_notify_host_recovery',
- 'contact_notify_host_down',
- 'contact_notify_host_unreachable',
- 'contact_notify_host_flapping',
- 'contact_notify_host_downtime',
- 'contact_notify_host_timeperiod',
- 'contact_notify_service_timeperiod'
+ 'contact_count'
);
}
@@ -60,9 +38,10 @@ class Contactgroup extends DataView
public function getStaticFilterColumns()
{
return array(
- 'contactgroup', 'contact',
+ 'contactgroup',
'host', 'host_name', 'host_display_name', 'host_alias',
'hostgroup', 'hostgroup_alias', 'hostgroup_name',
+ 'instance_name',
'service', 'service_description', 'service_display_name',
'servicegroup', 'servicegroup_alias', 'servicegroup_name'
);