diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index 55b57cd52..19c1b7bef 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -108,13 +108,15 @@ class Monitoring_ShowController extends Controller public function contactAction() { - $contact = $this->getParam('contact'); - if (! $contact) { + $contactName = $this->getParam('contact'); + + if (! $contactName) { throw new Zend_Controller_Action_Exception( $this->translate('The parameter `contact\' is required'), 404 ); } + $query = $this->backend->select()->from('contact', array( 'contact_name', 'contact_id', @@ -135,9 +137,22 @@ class Monitoring_ShowController extends Controller 'contact_notify_host_flapping', 'contact_notify_host_downtime', )); - $query->where('contact_name', $contact); - $this->view->contacts = $query->paginate(); - $this->view->contact_name = $contact; + + $query->where('contact_name', $contactName); + + $contact = $query->getQuery()->fetchRow(); + + if ($contact) { + $commands = $this->backend->select()->from('command', array( + 'command_line', + 'command_name' + ))->where('contact_id', $contact->contact_id); + + $this->view->commands = $commands->paginate(); + } + + $this->view->contact = $contact; + $this->view->contactName = $contactName; } /** diff --git a/modules/monitoring/application/views/scripts/show/contact.phtml b/modules/monitoring/application/views/scripts/show/contact.phtml index a7b691eb4..fff03a106 100644 --- a/modules/monitoring/application/views/scripts/show/contact.phtml +++ b/modules/monitoring/application/views/scripts/show/contact.phtml @@ -2,7 +2,7 @@ $contactHelper = $this->getHelper('ContactFlags'); ?>
- + @@ -45,12 +45,15 @@ $contactHelper = $this->getHelper('ContactFlags');
- + +

translate('Commands'); ?>:

+ + + + translate('No such contact'); ?>: +
diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommandQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommandQuery.php new file mode 100644 index 000000000..664cb3576 --- /dev/null +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommandQuery.php @@ -0,0 +1,60 @@ + array( + 'command_id' => 'c.command_id', + 'command_instance_id' => 'c.instance_id', + 'command_config_type' => 'c.config_type', + 'command_line' => 'c.command_line', + 'command_name' => 'co.name1' + ), + + 'contacts' => array( + 'contact_id' => 'con.contact_id', + 'contact_alias' => 'con.contact_alias' + ) + ); + + /** + * Fetch basic information about commands + */ + protected function joinBaseTables() + { + $this->select->from( + array('c' => $this->prefix . 'commands'), + array() + )->join( + array('co' => $this->prefix . 'objects'), + 'co.object_id = c.object_id', + array() + ); + + $this->joinedVirtualTables = array('commands' => true); + } + + /** + * Join contacts + */ + protected function joinContacts() + { + $this->select->join( + array('cnc' => $this->prefix . 'contact_notificationcommands'), + 'cnc.command_object_id = co.object_id' + )->join( + array('con' => $this->prefix . 'contacts'), + 'con.contact_id = cnc.contact_id' + ); + } +} \ No newline at end of file diff --git a/modules/monitoring/library/Monitoring/DataView/Command.php b/modules/monitoring/library/Monitoring/DataView/Command.php new file mode 100644 index 000000000..a21c48ee0 --- /dev/null +++ b/modules/monitoring/library/Monitoring/DataView/Command.php @@ -0,0 +1,28 @@ +