diff --git a/modules/monitoring/application/controllers/CommentController.php b/modules/monitoring/application/controllers/CommentController.php index 4237d598b..7ab331adc 100644 --- a/modules/monitoring/application/controllers/CommentController.php +++ b/modules/monitoring/application/controllers/CommentController.php @@ -27,7 +27,7 @@ class Monitoring_CommentController extends Controller $this->comment = $this->backend->select()->from('comment', array( 'id' => 'comment_internal_id', - 'objecttype' => 'comment_objecttype', + 'objecttype' => 'object_type', 'comment' => 'comment_data', 'author' => 'comment_author_name', 'timestamp' => 'comment_timestamp', diff --git a/modules/monitoring/application/controllers/CommentsController.php b/modules/monitoring/application/controllers/CommentsController.php index e1092b033..9b31755cc 100644 --- a/modules/monitoring/application/controllers/CommentsController.php +++ b/modules/monitoring/application/controllers/CommentsController.php @@ -32,7 +32,7 @@ class Monitoring_CommentsController extends Controller )); $this->comments = $this->backend->select()->from('comment', array( 'id' => 'comment_internal_id', - 'objecttype' => 'comment_objecttype', + 'objecttype' => 'object_type', 'comment' => 'comment_data', 'author' => 'comment_author_name', 'timestamp' => 'comment_timestamp', @@ -44,11 +44,11 @@ class Monitoring_CommentsController extends Controller 'host_display_name', 'service_display_name' ))->addFilter($this->filter)->getQuery()->fetchAll(); - + if (false === $this->comments) { throw new Zend_Controller_Action_Exception($this->translate('Comment not found')); } - + $this->getTabs()->add( 'comments', array( diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 2e4e34390..1a3733a7a 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -431,7 +431,7 @@ class Monitoring_ListController extends Controller $query = $this->backend->select()->from('comment', array( 'id' => 'comment_internal_id', - 'objecttype' => 'comment_objecttype', + 'objecttype' => 'object_type', 'comment' => 'comment_data', 'author' => 'comment_author_name', 'timestamp' => 'comment_timestamp', diff --git a/modules/monitoring/library/Monitoring/Object/HostList.php b/modules/monitoring/library/Monitoring/Object/HostList.php index 31f360d03..cbbafdecf 100644 --- a/modules/monitoring/library/Monitoring/Object/HostList.php +++ b/modules/monitoring/library/Monitoring/Object/HostList.php @@ -87,6 +87,19 @@ class HostList extends ObjectList return FilterOr::matchAny($filterExpression); } + /** + * Get the comments + * + * @return \Icinga\Module\Monitoring\DataView\Hostcomment + */ + public function getComments() + { + return $this->backend + ->select() + ->from('hostcomment', array('host_name')) + ->applyFilter(clone $this->filter); + } + /** * Get the scheduled downtimes * diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php index fdf64fc51..626b5cd3d 100644 --- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php +++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php @@ -253,7 +253,7 @@ abstract class MonitoredObject implements Filterable 'type' => 'comment_type', )) ->where('comment_type', array('comment', 'ack')) - ->where('comment_objecttype', $this->type); + ->where('object_type', $this->type); if ($this->type === self::TYPE_SERVICE) { $comments ->where('service_host_name', $this->host_name) diff --git a/modules/monitoring/library/Monitoring/Object/ServiceList.php b/modules/monitoring/library/Monitoring/Object/ServiceList.php index b06cffc89..f4cc38598 100644 --- a/modules/monitoring/library/Monitoring/Object/ServiceList.php +++ b/modules/monitoring/library/Monitoring/Object/ServiceList.php @@ -135,6 +135,19 @@ class ServiceList extends ObjectList return FilterOr::matchAny($filterExpression); } + /** + * Get the comments + * + * @return \Icinga\Module\Monitoring\DataView\Hostcomment + */ + public function getComments() + { + return $this->backend + ->select() + ->from('servicecomment', array('host_name', 'service_description')) + ->applyFilter(clone $this->filter); + } + /** * Get the scheduled downtimes *