mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-24 06:14:25 +02:00
monitoring: Reduce complexity of the CommentController
This commit is contained in:
parent
9cf56410e9
commit
6ff7882fc0
@ -16,7 +16,7 @@ class CommentController extends Controller
|
|||||||
/**
|
/**
|
||||||
* The fetched comment
|
* The fetched comment
|
||||||
*
|
*
|
||||||
* @var stdClass
|
* @var object
|
||||||
*/
|
*/
|
||||||
protected $comment;
|
protected $comment;
|
||||||
|
|
||||||
@ -43,19 +43,18 @@ class CommentController extends Controller
|
|||||||
))->where('comment_internal_id', $commentId);
|
))->where('comment_internal_id', $commentId);
|
||||||
$this->applyRestriction('monitoring/filter/objects', $query);
|
$this->applyRestriction('monitoring/filter/objects', $query);
|
||||||
|
|
||||||
$this->comment = $query->getQuery()->fetchRow();
|
if (false === $this->comment = $query->getQuery()->fetchRow()) {
|
||||||
if ($this->comment === false) {
|
|
||||||
$this->httpNotFound($this->translate('Comment not found'));
|
$this->httpNotFound($this->translate('Comment not found'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getTabs()->add(
|
$this->getTabs()->add(
|
||||||
'comment',
|
'comment',
|
||||||
array(
|
array(
|
||||||
|
'icon' => 'comment',
|
||||||
|
'label' => $this->translate('Comment'),
|
||||||
'title' => $this->translate(
|
'title' => $this->translate(
|
||||||
'Display detailed information about a comment.'
|
'Display detailed information about a comment.'
|
||||||
),
|
),
|
||||||
'icon' => 'comment',
|
|
||||||
'label' => $this->translate('Comment'),
|
|
||||||
'url' =>'monitoring/comments/show'
|
'url' =>'monitoring/comments/show'
|
||||||
)
|
)
|
||||||
)->activate('comment')->extend(new DashboardAction());
|
)->activate('comment')->extend(new DashboardAction());
|
||||||
@ -66,37 +65,19 @@ class CommentController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function showAction()
|
public function showAction()
|
||||||
{
|
{
|
||||||
$listCommentsLink = Url::fromPath('monitoring/list/comments')
|
|
||||||
->setQueryString('comment_type=(comment|ack)');
|
|
||||||
|
|
||||||
$this->view->comment = $this->comment;
|
$this->view->comment = $this->comment;
|
||||||
|
|
||||||
if ($this->hasPermission('monitoring/command/comment/delete')) {
|
if ($this->hasPermission('monitoring/command/comment/delete')) {
|
||||||
$this->view->delCommentForm = $this->createDelCommentForm();
|
$listUrl = Url::fromPath('monitoring/list/comments')->setQueryString('comment_type=(comment|ack)');
|
||||||
$this->view->delCommentForm->populate(
|
$form = new DeleteCommentCommandForm();
|
||||||
array(
|
$form
|
||||||
'redirect' => $listCommentsLink,
|
->populate(array(
|
||||||
'comment_id' => $this->comment->id,
|
'redirect' => $listUrl,
|
||||||
'comment_is_service' => isset($this->comment->service_description)
|
'comment_id' => $this->comment->id,
|
||||||
)
|
'comment_is_service' => isset($this->comment->service_description)
|
||||||
);
|
))
|
||||||
|
->handleRequest();
|
||||||
|
$this->view->delCommentForm = $form;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a command form to delete a single comment
|
|
||||||
*
|
|
||||||
* @return DeleteCommentsCommandForm
|
|
||||||
*/
|
|
||||||
private function createDelCommentForm()
|
|
||||||
{
|
|
||||||
$this->assertPermission('monitoring/command/comment/delete');
|
|
||||||
|
|
||||||
$delCommentForm = new DeleteCommentCommandForm();
|
|
||||||
$delCommentForm->setAction(
|
|
||||||
Url::fromPath('monitoring/comment/show')
|
|
||||||
->setParam('comment_id', $this->comment->id)
|
|
||||||
);
|
|
||||||
$delCommentForm->handleRequest();
|
|
||||||
return $delCommentForm;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user