From 3e02d5aff85babc3ffbfcf52313f2108e313aa23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 13:46:43 +0200 Subject: Adding upstream version 2.12.1. Signed-off-by: Daniel Baumann --- .../application/controllers/CommentController.php | 91 ++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 modules/monitoring/application/controllers/CommentController.php (limited to 'modules/monitoring/application/controllers/CommentController.php') diff --git a/modules/monitoring/application/controllers/CommentController.php b/modules/monitoring/application/controllers/CommentController.php new file mode 100644 index 0000000..e50473f --- /dev/null +++ b/modules/monitoring/application/controllers/CommentController.php @@ -0,0 +1,91 @@ +params->getRequired('comment_id'); + + $query = $this->backend->select()->from('comment', array( + 'id' => 'comment_internal_id', + 'objecttype' => 'object_type', + 'comment' => 'comment_data', + 'author' => 'comment_author_name', + 'timestamp' => 'comment_timestamp', + 'type' => 'comment_type', + 'persistent' => 'comment_is_persistent', + 'expiration' => 'comment_expiration', + 'name' => 'comment_name', + 'host_name', + 'service_description', + 'host_display_name', + 'service_display_name' + ))->where('comment_internal_id', $commentId); + $this->applyRestriction('monitoring/filter/objects', $query); + + if (false === $this->comment = $query->fetchRow()) { + $this->httpNotFound($this->translate('Comment not found')); + } + + $this->getTabs()->add( + 'comment', + array( + 'icon' => 'comment-empty', + 'label' => $this->translate('Comment'), + 'title' => $this->translate('Display detailed information about a comment.'), + 'url' =>'monitoring/comments/show' + ) + )->activate('comment')->extend(new DashboardAction())->extend(new MenuAction()); + + if (Hook::has('ticket')) { + $this->view->tickets = Hook::first('ticket'); + } + } + + /** + * Display comment detail view + */ + public function showAction() + { + $this->view->comment = $this->comment; + $this->view->title = $this->translate('Comments'); + + if ($this->hasPermission('monitoring/command/comment/delete')) { + $listUrl = Url::fromPath('monitoring/list/comments') + ->setQueryString('comment_type=comment|comment_type=ack'); + $form = new DeleteCommentCommandForm(); + $form + ->populate(array( + 'comment_id' => $this->comment->id, + 'comment_is_service' => isset($this->comment->service_description), + 'comment_name' => $this->comment->name, + 'redirect' => $listUrl + )) + ->handleRequest(); + $this->view->delCommentForm = $form; + } + } +} -- cgit v1.2.3