From 5e84ff4ac4244168dae753148df727fab3692fb0 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Wed, 27 Aug 2014 16:36:52 +0200 Subject: [PATCH] Show/Contact: Add notification history to view refs #4804 --- .../application/controllers/ShowController.php | 15 +++++++++++++++ .../application/views/scripts/show/contact.phtml | 3 +++ .../Monitoring/Backend/Ido/Query/ContactQuery.php | 1 + .../Backend/Ido/Query/NotificationQuery.php | 3 ++- .../library/Monitoring/DataView/Contact.php | 1 + 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index 19c1b7bef..1ad0f29dd 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -123,6 +123,7 @@ class Monitoring_ShowController extends Controller 'contact_alias', 'contact_email', 'contact_pager', + 'contact_object_id', 'contact_notify_service_timeperiod', 'contact_notify_service_recovery', 'contact_notify_service_warning', @@ -149,6 +150,20 @@ class Monitoring_ShowController extends Controller ))->where('contact_id', $contact->contact_id); $this->view->commands = $commands->paginate(); + + $notifications = $this->backend->select()->from('notification', array( + 'host', + 'service', + 'notification_output', + 'notification_contact', + 'notification_start_time', + 'notification_state' + )); + + $notifications->where('contact_object_id', $contact->contact_object_id); + + $this->view->compact = true; + $this->view->notifications = $notifications->paginate(); } $this->view->contact = $contact; diff --git a/modules/monitoring/application/views/scripts/show/contact.phtml b/modules/monitoring/application/views/scripts/show/contact.phtml index fff03a106..45d751fd5 100644 --- a/modules/monitoring/application/views/scripts/show/contact.phtml +++ b/modules/monitoring/application/views/scripts/show/contact.phtml @@ -53,6 +53,9 @@ $contactHelper = $this->getHelper('ContactFlags'); +

translate('Notifications'); ?>:

+ render('list/notifications.phtml') ?> + translate('No such contact'); ?>: diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ContactQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ContactQuery.php index a868d5479..89fa37fcd 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ContactQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ContactQuery.php @@ -13,6 +13,7 @@ class ContactQuery extends IdoQuery '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', diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php index 68a37d83c..882600240 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php @@ -25,7 +25,8 @@ class NotificationQuery extends IdoQuery 'service' => 'o.name2' ), 'contact' => array( - 'notification_contact' => 'c_o.name1' + 'notification_contact' => 'c_o.name1', + 'contact_object_id' => 'c_o.object_id' ), 'command' => array( 'notification_command' => 'cmd_o.name1' diff --git a/modules/monitoring/library/Monitoring/DataView/Contact.php b/modules/monitoring/library/Monitoring/DataView/Contact.php index 7d24d1255..9f78a3b6a 100644 --- a/modules/monitoring/library/Monitoring/DataView/Contact.php +++ b/modules/monitoring/library/Monitoring/DataView/Contact.php @@ -38,6 +38,7 @@ class Contact extends DataView 'contact_notify_host_unreachable', 'contact_notify_host_flapping', 'contact_notify_host_downtime', + 'contact_object_id', 'host_object_id', 'host_name', 'service_object_id',