From cb95f53dba97f3874a4d2ed886f370d0a3d27c45 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 9 Apr 2015 12:49:06 +0200 Subject: [PATCH] CommentQuery: Fetch and display object names with their initial collation i.e. `host_name' instead of `comment_host' alias `host' and `service_description' instead of `comment_service' alias `service'. refs #8613 --- .../application/controllers/ListController.php | 4 ++-- .../views/scripts/list/comments.phtml | 17 +++++++++++------ .../Backend/Ido/Query/CommentQuery.php | 8 +++----- .../library/Monitoring/DataView/Comment.php | 4 ++-- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 8a9dc5fa4..cf5821cdc 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -474,8 +474,8 @@ class Monitoring_ListController extends Controller 'type' => 'comment_type', 'persistent' => 'comment_is_persistent', 'expiration' => 'comment_expiration', - 'host' => 'comment_host', - 'service' => 'comment_service', + 'host_name', + 'service_description', 'host_display_name', 'service_display_name' )); diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 12668eefd..cdbe28244 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -52,11 +52,14 @@ objecttype === 'service'): ?> icon('service', $this->translate('Service')); ?> link()->service( - $comment->service, $comment->service_display_name, $comment->host, $comment->host_display_name - ) ?> + $comment->service_description, + $comment->service_display_name, + $comment->host_name, + $comment->host_display_name + ); ?> icon('host', $this->translate('Host')); ?> - link()->host($comment->host, $comment->host_display_name) ?> + link()->host($comment->host_name, $comment->host_display_name); ?>
icon('comment', $this->translate('Comment')); ?> author) @@ -81,11 +84,13 @@ $delCommentForm = clone $delCommentForm; $delCommentForm->populate(array('comment_id' => $comment->id, 'redirect' => $this->url)); if ($comment->objecttype === 'host') { - $delCommentForm->setAction($this->url('monitoring/host/delete-comment', array('host_name' => $comment->host))); + $delCommentForm->setAction( + $this->url('monitoring/host/delete-comment', array('host_name' => $comment->host_name)) + ); } else { $delCommentForm->setAction($this->url('monitoring/service/delete-comment', array( - 'host_name' => $comment->host, - 'service_description' => $comment->service + 'host_name' => $comment->host_name, + 'service_description' => $comment->service_description ))); } echo $delCommentForm; diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentQuery.php index 1348371d3..91800ef78 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentQuery.php @@ -17,13 +17,11 @@ class CommentQuery extends IdoQuery 'comment_type' => "CASE cm.entry_type WHEN 1 THEN 'comment' WHEN 2 THEN 'downtime' WHEN 3 THEN 'flapping' WHEN 4 THEN 'ack' END", 'comment_is_persistent' => 'cm.is_persistent', 'comment_expiration' => 'CASE cm.expires WHEN 1 THEN UNIX_TIMESTAMP(cm.expiration_time) ELSE NULL END', - 'comment_host' => 'CASE WHEN ho.name1 IS NULL THEN so.name1 ELSE ho.name1 END COLLATE latin1_general_ci', - 'host' => 'CASE WHEN ho.name1 IS NULL THEN so.name1 ELSE ho.name1 END COLLATE latin1_general_ci', // #7278, #7279 - 'comment_service' => 'so.name2 COLLATE latin1_general_ci', - 'service' => 'so.name2 COLLATE latin1_general_ci', // #7278, #7279 'comment_objecttype' => "CASE WHEN ho.object_id IS NOT NULL THEN 'host' ELSE CASE WHEN so.object_id IS NOT NULL THEN 'service' ELSE NULL END END", - 'service_description' => 'so.name2', + 'host' => 'CASE WHEN ho.name1 IS NULL THEN so.name1 ELSE ho.name1 END COLLATE latin1_general_ci', 'host_name' => 'CASE WHEN ho.name1 IS NULL THEN so.name1 ELSE ho.name1 END', + 'service' => 'so.name2 COLLATE latin1_general_ci', + 'service_description' => 'so.name2', 'service_host_name' => 'so.name1' ), 'hosts' => array( diff --git a/modules/monitoring/library/Monitoring/DataView/Comment.php b/modules/monitoring/library/Monitoring/DataView/Comment.php index 5172690bb..c74deeb89 100644 --- a/modules/monitoring/library/Monitoring/DataView/Comment.php +++ b/modules/monitoring/library/Monitoring/DataView/Comment.php @@ -22,10 +22,10 @@ class Comment extends DataView 'comment_type', 'comment_is_persistent', 'comment_expiration', - 'comment_host', - 'comment_service', 'host', 'service', + 'host_name', + 'service_description', 'host_display_name', 'service_display_name' );