From b35dd4ddfee5789b0363b07e2c3209b34cec7f6a Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 14:03:09 +0200 Subject: [PATCH 01/11] Separate forms for deleting single and multiple comments refs #8624 --- .../controllers/CommentController.php | 15 +-- .../controllers/CommentsController.php | 4 +- .../controllers/DowntimeController.php | 15 +-- .../controllers/ListController.php | 4 +- .../Object/DeleteCommentCommandForm.php | 50 +++++----- .../Object/DeleteCommentsCommandForm.php | 92 +++++++++++++++++++ .../Object/DeleteDowntimeCommandForm.php | 29 +++--- .../views/scripts/comment/show.phtml | 4 +- .../scripts/show/components/downtime.phtml | 7 +- .../Command/Object/DeleteCommentCommand.php | 43 +++++++-- .../IcingaCommandFileCommandRenderer.php | 7 +- .../Controller/MonitoredObjectController.php | 6 +- 12 files changed, 201 insertions(+), 75 deletions(-) create mode 100644 modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php diff --git a/modules/monitoring/application/controllers/CommentController.php b/modules/monitoring/application/controllers/CommentController.php index b5b374c12..1c7f3e36d 100644 --- a/modules/monitoring/application/controllers/CommentController.php +++ b/modules/monitoring/application/controllers/CommentController.php @@ -67,6 +67,13 @@ class Monitoring_CommentController extends Controller $this->view->comment = $this->comment; if ($this->hasPermission('monitoring/command/comment/delete')) { $this->view->delCommentForm = $this->createDelCommentForm(); + $this->view->delCommentForm->populate( + array( + 'redirect' => Url::fromPath('monitoring/list/comments'), + 'comment_id' => $this->comment->id, + 'comment_is_service' => isset($this->comment->service_description) + ) + ); } } @@ -82,7 +89,7 @@ class Monitoring_CommentController extends Controller /** * Create a command form to delete a single comment * - * @return DeleteCommentCommandForm + * @return DeleteCommentsCommandForm */ private function createDelCommentForm() { @@ -93,12 +100,6 @@ class Monitoring_CommentController extends Controller Url::fromPath('monitoring/comment/show') ->setParam('comment_id', $this->comment->id) ); - $delCommentForm->populate( - array( - 'redirect' => Url::fromPath('monitoring/list/comments'), - 'comment_id' => $this->comment->id - ) - ); $delCommentForm->handleRequest(); return $delCommentForm; } diff --git a/modules/monitoring/application/controllers/CommentsController.php b/modules/monitoring/application/controllers/CommentsController.php index 2e8656085..106dd4650 100644 --- a/modules/monitoring/application/controllers/CommentsController.php +++ b/modules/monitoring/application/controllers/CommentsController.php @@ -2,7 +2,7 @@ /* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ use Icinga\Module\Monitoring\Controller; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentsCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; use Icinga\Data\Filter\Filter; @@ -84,7 +84,7 @@ class Monitoring_CommentsController extends Controller $this->view->comments = $this->comments; $this->view->listAllLink = Url::fromPath('monitoring/list/comments') ->setQueryString($this->filter->toQueryString()); - $delCommentForm = new DeleteCommentCommandForm(); + $delCommentForm = new DeleteCommentsCommandForm(); $delCommentForm->setTitle($this->view->translate('Remove all Comments')); $delCommentForm->addDescription(sprintf( $this->translate('Confirm removal of %d comments.'), diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index 20eebc6ca..1fed470fe 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -5,6 +5,7 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; +use Icinga\Module\Monitoring\Command\Object\DeleteDowntimeCommand; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; @@ -102,6 +103,13 @@ class Monitoring_DowntimeController extends Controller ->setParam('service', $this->downtime->service_description); if ($this->hasPermission('monitoring/command/downtime/delete')) { $this->view->delDowntimeForm = $this->createDelDowntimeForm(); + $this->view->delDowntimeForm->populate( + array( + 'redirect' => Url::fromPath('monitoring/list/downtimes'), + 'downtime_id' => $this->downtime->id, + 'downtime_is_service' => $this->isService + ) + ); } } @@ -122,18 +130,11 @@ class Monitoring_DowntimeController extends Controller private function createDelDowntimeForm() { $this->assertPermission('monitoring/command/downtime/delete'); - $delDowntimeForm = new DeleteDowntimeCommandForm(); $delDowntimeForm->setAction( Url::fromPath('monitoring/downtime/show') ->setParam('downtime_id', $this->downtime->id) ); - $delDowntimeForm->populate( - array( - 'redirect' => Url::fromPath('monitoring/list/downtimes'), - 'downtime_id' => $this->downtime->id - ) - ); $delDowntimeForm->handleRequest(); return $delDowntimeForm; } diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index e6147c31b..53b0e1edd 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -3,7 +3,7 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Backend; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentsCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; @@ -501,7 +501,7 @@ class Monitoring_ListController extends Controller ); if ($this->Auth()->hasPermission('monitoring/command/comment/delete')) { - $this->view->delCommentForm = new DeleteCommentCommandForm(); + $this->view->delCommentForm = new DeleteCommentsCommandForm(); } } diff --git a/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php index 93b928b86..1c8144475 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteCommentCommandForm.php @@ -4,12 +4,13 @@ namespace Icinga\Module\Monitoring\Forms\Command\Object; use Icinga\Module\Monitoring\Command\Object\DeleteCommentCommand; +use Icinga\Module\Monitoring\Forms\Command\CommandForm; use Icinga\Web\Notification; /** * Form for deleting host or service comments */ -class DeleteCommentCommandForm extends ObjectsCommandForm +class DeleteCommentCommandForm extends CommandForm { /** * (non-PHPDoc) @@ -26,23 +27,34 @@ class DeleteCommentCommandForm extends ObjectsCommandForm */ public function createElements(array $formData = array()) { - $this->addElements(array( + $this->addElements( array( - 'hidden', - 'comment_id', array( - 'required' => true, - 'decorators' => array('ViewHelper') - ) - ), - array( - 'hidden', - 'redirect', + 'hidden', + 'comment_id', + array( + 'required' => true, + 'validators' => array('NotEmpty'), + 'decorators' => array('ViewHelper') + ) + ), array( - 'decorators' => array('ViewHelper') + 'hidden', + 'comment_is_service', + array( + 'filters' => array('Boolean'), + 'decorators' => array('ViewHelper') + ) + ), + array( + 'hidden', + 'redirect', + array( + 'decorators' => array('ViewHelper') + ) ) ) - )); + ); return $this; } @@ -74,14 +86,10 @@ class DeleteCommentCommandForm extends ObjectsCommandForm */ public function onSuccess() { - foreach ($this->objects as $object) { - /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ - $delComment = new DeleteCommentCommand(); - $delComment - ->setObject($object) - ->setCommentId($this->getElement('comment_id')->getValue()); - $this->getTransport($this->request)->send($delComment); - } + $cmd = new DeleteCommentCommand(); + $cmd->setIsService($this->getElement('comment_is_service')->getValue()) + ->setCommentId($this->getElement('comment_id')->getValue()); + $this->getTransport($this->request)->send($cmd); $redirect = $this->getElement('redirect')->getValue(); if (! empty($redirect)) { $this->setRedirectUrl($redirect); diff --git a/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php new file mode 100644 index 000000000..119020411 --- /dev/null +++ b/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php @@ -0,0 +1,92 @@ +setAttrib('class', 'inline'); + } + + /** + * (non-PHPDoc) + * @see \Icinga\Web\Form::createElements() For the method documentation. + */ + public function createElements(array $formData = array()) + { + $this->addElements(array( + array( + 'hidden', + 'comment_id', + array( + 'required' => true, + 'decorators' => array('ViewHelper') + ) + ), + array( + 'hidden', + 'redirect', + array( + 'decorators' => array('ViewHelper') + ) + ) + )); + return $this; + } + + /** + * (non-PHPDoc) + * @see \Icinga\Web\Form::addSubmitButton() For the method documentation. + */ + public function addSubmitButton() + { + $this->addElement( + 'button', + 'btn_submit', + array( + 'ignore' => true, + 'escape' => false, + 'type' => 'submit', + 'class' => 'link-like', + 'label' => $this->getView()->icon('trash'), + 'title' => $this->translate('Delete this comment'), + 'decorators' => array('ViewHelper') + ) + ); + return $this; + } + + /** + * (non-PHPDoc) + * @see \Icinga\Web\Form::onSuccess() For the method documentation. + */ + public function onSuccess() + { + foreach ($this->objects as $object) { + /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ + $delComment = new DeleteCommentCommand(); + $delComment + ->setObject($object) + ->setCommentId($this->getElement('comment_id')->getValue()); + $this->getTransport($this->request)->send($delComment); + } + $redirect = $this->getElement('redirect')->getValue(); + if (! empty($redirect)) { + $this->setRedirectUrl($redirect); + } + Notification::success($this->translate('Deleting comment..')); + return true; + } +} diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php index 070451e7f..1d959caab 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php @@ -33,6 +33,16 @@ class DeleteDowntimeCommandForm extends CommandForm 'hidden', 'downtime_id', array( + 'required' => true, + 'validators' => array('NotEmpty'), + 'decorators' => array('ViewHelper') + ) + ), + array( + 'hidden', + 'downtime_is_service', + array( + 'filters' => array('Boolean'), 'decorators' => array('ViewHelper') ) ), @@ -76,20 +86,11 @@ class DeleteDowntimeCommandForm extends CommandForm */ public function onSuccess() { - $id = $this->getElement('downtime_id')->getValue(); - - // Presence of downtime id, only delete this specific downtime - $firstDowntime = $this->downtimes[0]; - - $delDowntime = new DeleteDowntimeCommand(); - $delDowntime->setDowntimeId($id); - $delDowntime->setDowntimeType( - isset($firstDowntime->service_description) ? - DeleteDowntimeCommand::DOWNTIME_TYPE_SERVICE : - DeleteDowntimeCommand::DOWNTIME_TYPE_HOST - ); - $this->getTransport($this->request)->send($delDowntime); - + $cmd = new DeleteDowntimeCommand(); + $cmd->setDowntimeId($this->getElement('downtime_id')->getValue()); + $cmd->setIsService($this->getElement('downtime_is_service')->getValue()); + $this->getTransport($this->request)->send($cmd); + $redirect = $this->getElement('redirect')->getValue(); if (! empty($redirect)) { $this->setRedirectUrl($redirect); diff --git a/modules/monitoring/application/views/scripts/comment/show.phtml b/modules/monitoring/application/views/scripts/comment/show.phtml index 88a25a57b..9010021c3 100644 --- a/modules/monitoring/application/views/scripts/comment/show.phtml +++ b/modules/monitoring/application/views/scripts/comment/show.phtml @@ -16,12 +16,12 @@ comment->objecttype === 'service'): ?> translate('Service') ?> - icon('service', $this->translate('Service')); ?> + icon('service', $this->translate('Service')); ?> link()->service( $this->comment->service_description, $this->comment->service_display_name, $this->comment->host_name, - $this->comment->host_display_names + $this->comment->host_display_name ); ?> diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml index bfb9bbf45..a10863054 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -65,7 +65,12 @@ foreach ($object->downtimes as $downtime) { populate(array('downtime_id' => $downtime->id)); + $delDowntimeForm->populate( + array( + 'downtime_id' => $downtime->id, + 'downtime_is_service' => $object->getType() === $object::TYPE_SERVICE + ) + ); echo $delDowntimeForm; } ?> translate('Downtime'); ?> diff --git a/modules/monitoring/library/Monitoring/Command/Object/DeleteCommentCommand.php b/modules/monitoring/library/Monitoring/Command/Object/DeleteCommentCommand.php index 00ba63a78..75f2ffb8e 100644 --- a/modules/monitoring/library/Monitoring/Command/Object/DeleteCommentCommand.php +++ b/modules/monitoring/library/Monitoring/Command/Object/DeleteCommentCommand.php @@ -3,20 +3,13 @@ namespace Icinga\Module\Monitoring\Command\Object; +use Icinga\Module\Monitoring\Command\IcingaCommand; + /** * Delete a host or service comment */ -class DeleteCommentCommand extends ObjectCommand +class DeleteCommentCommand extends IcingaCommand { - /** - * (non-PHPDoc) - * @see \Icinga\Module\Monitoring\Command\Object\ObjectCommand::$allowedObjects For the property documentation. - */ - protected $allowedObjects = array( - self::TYPE_HOST, - self::TYPE_SERVICE - ); - /** * ID of the comment that is to be deleted * @@ -24,6 +17,13 @@ class DeleteCommentCommand extends ObjectCommand */ protected $commentId; + /** + * The type of the comment, either 'host' or 'service' + * + * @var boolean + */ + protected $isService = false; + /** * Set the ID of the comment that is to be deleted * @@ -46,4 +46,27 @@ class DeleteCommentCommand extends ObjectCommand { return $this->commentId; } + + /** + * Whether the command affects a service comment + * + * @return boolean + */ + public function getIsService() + { + return $this->isService; + } + + /** + * Set whether the command affects a service + * + * @param boolean $value The value, defaults to true + * + * @return this fluent interface + */ + public function setIsService($value = true) + { + $this->isService = (bool) $value; + return $this; + } } diff --git a/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php b/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php index 83fbd4364..19d7574ca 100644 --- a/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php +++ b/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php @@ -323,14 +323,9 @@ class IcingaCommandFileCommandRenderer implements IcingaCommandRendererInterface public function renderDeleteComment(DeleteCommentCommand $command) { - if ($command->getObject()->getType() === $command::TYPE_HOST) { - $commandString = 'DEL_HOST_COMMENT'; - } else { - $commandString = 'DEL_SVC_COMMENT'; - } return sprintf( '%s;%u', - $commandString, + $command->getIsService() ? 'DEL_SVC_COMMENT' : 'DEL_HOST_COMMENT', $command->getCommentId() ); } diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 94d9f6399..3629a4182 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -5,7 +5,7 @@ namespace Icinga\Module\Monitoring\Web\Controller; use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Forms\Command\Object\CheckNowCommandForm; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentsCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ObjectsCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandForm; @@ -81,7 +81,7 @@ abstract class MonitoredObjectController extends Controller ->handleRequest(); $this->view->toggleFeaturesForm = $toggleFeaturesForm; if (! empty($this->object->comments) && $auth->hasPermission('monitoring/command/comment/delete')) { - $delCommentForm = new DeleteCommentCommandForm(); + $delCommentForm = new DeleteCommentsCommandForm(); $delCommentForm ->setObjects($this->object) ->handleRequest(); @@ -142,7 +142,7 @@ abstract class MonitoredObjectController extends Controller { $this->assertHttpMethod('POST'); $this->assertPermission('monitoring/command/comment/delete'); - $this->handleCommandForm(new DeleteCommentCommandForm()); + $this->handleCommandForm(new DeleteCommentsCommandForm()); } /** From ffd12e325cf59a628c8a19d586c1103d04400f01 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 14:05:16 +0200 Subject: [PATCH 02/11] Improve up downtime command form properties Use a flag instead of a enumeration in delete downtime command form, to remove needless boilerplate. refs #8624 --- .../Object/DeleteDowntimeCommandForm.php | 2 +- .../Command/Object/DeleteDowntimeCommand.php | 34 +++++++------------ .../IcingaCommandFileCommandRenderer.php | 7 +--- 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php index 1d959caab..31ec778fa 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimeCommandForm.php @@ -21,7 +21,7 @@ class DeleteDowntimeCommandForm extends CommandForm $this->setAttrib('class', 'inline'); } - /** + /** * (non-PHPDoc) * @see \Icinga\Web\Form::createElements() For the method documentation. */ diff --git a/modules/monitoring/library/Monitoring/Command/Object/DeleteDowntimeCommand.php b/modules/monitoring/library/Monitoring/Command/Object/DeleteDowntimeCommand.php index 96dc8f755..a2c593f26 100644 --- a/modules/monitoring/library/Monitoring/Command/Object/DeleteDowntimeCommand.php +++ b/modules/monitoring/library/Monitoring/Command/Object/DeleteDowntimeCommand.php @@ -10,46 +10,38 @@ use Icinga\Module\Monitoring\Command\IcingaCommand; */ class DeleteDowntimeCommand extends IcingaCommand { - /** - * Downtime for a host - */ - const DOWNTIME_TYPE_HOST = 'host'; - - /** - * Downtime for a service - */ - const DOWNTIME_TYPE_SERVICE = 'service'; - /** * ID of the downtime that is to be deleted * * @var int */ protected $downtimeId; - + /** + * If the command affects a service downtime * - * @var type + * @var boolean */ - protected $downtimeType = self::DOWNTIME_TYPE_HOST; - + protected $isService = false; + /** - * Set the downtime type, either host or service + * Set if this command affects a service * - * @param string $type the downtime type + * @param type $value */ - public function setDowntimeType($type) + public function setIsService($value = true) { - $this->downtimeType = $type; + $this->isService = (bool) $value; } /** - * + * Return whether the command affects a service + * * @return type */ - public function getDowntimeType() + public function getIsService() { - return $this->downtimeType; + return $this->isService; } /** diff --git a/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php b/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php index 19d7574ca..f6a35dcc2 100644 --- a/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php +++ b/modules/monitoring/library/Monitoring/Command/Renderer/IcingaCommandFileCommandRenderer.php @@ -332,14 +332,9 @@ class IcingaCommandFileCommandRenderer implements IcingaCommandRendererInterface public function renderDeleteDowntime(DeleteDowntimeCommand $command) { - if ($command->getDowntimeType() === 'host') { - $commandString = 'DEL_HOST_DOWNTIME'; - } else { - $commandString = 'DEL_SVC_DOWNTIME'; - } return sprintf( '%s;%u', - $commandString, + $command->getIsService() ? 'DEL_SVC_DOWNTIME' : 'DEL_HOST_DOWNTIME', $command->getDowntimeId() ); } From 4463f16f04972f4eae8eb7fb9a62cf8de015dfd3 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 15:11:54 +0200 Subject: [PATCH 03/11] Add abbillity to remove multiple comments by id refs #8624 --- .../controllers/CommentsController.php | 4 +- .../Object/DeleteCommentsCommandForm.php | 47 +++++++++++-------- .../Object/DeleteDowntimesCommandForm.php | 8 +--- .../views/scripts/list/comments.phtml | 8 +++- .../views/scripts/list/downtimes.phtml | 7 ++- .../Controller/MonitoredObjectController.php | 8 ++-- 6 files changed, 48 insertions(+), 34 deletions(-) diff --git a/modules/monitoring/application/controllers/CommentsController.php b/modules/monitoring/application/controllers/CommentsController.php index 106dd4650..9521af7c9 100644 --- a/modules/monitoring/application/controllers/CommentsController.php +++ b/modules/monitoring/application/controllers/CommentsController.php @@ -90,8 +90,8 @@ class Monitoring_CommentsController extends Controller $this->translate('Confirm removal of %d comments.'), count($this->comments) )); - $delCommentForm->setObjects($this->comments) - ->setRedirectUrl(Url::fromPath('monitoring/list/downtimes')) + $delCommentForm->setComments($this->comments) + ->setRedirectUrl(Url::fromPath('monitoring/list/comments')) ->handleRequest(); $this->view->delCommentForm = $delCommentForm; } diff --git a/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php index 119020411..57f6aae5a 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php @@ -4,13 +4,21 @@ namespace Icinga\Module\Monitoring\Forms\Command\Object; use Icinga\Module\Monitoring\Command\Object\DeleteCommentCommand; +use \Icinga\Module\Monitoring\Forms\Command\CommandForm; use Icinga\Web\Notification; /** * Form for deleting host or service comments */ -class DeleteCommentsCommandForm extends ObjectsCommandForm +class DeleteCommentsCommandForm extends CommandForm { + /** + * The comments deleted on success + * + * @var array + */ + protected $comments; + /** * (non-PHPDoc) * @see \Zend_Form::init() For the method documentation. @@ -27,20 +35,10 @@ class DeleteCommentsCommandForm extends ObjectsCommandForm public function createElements(array $formData = array()) { $this->addElements(array( - array( - 'hidden', - 'comment_id', - array( - 'required' => true, - 'decorators' => array('ViewHelper') - ) - ), array( 'hidden', 'redirect', - array( - 'decorators' => array('ViewHelper') - ) + array('decorators' => array('ViewHelper')) ) )); return $this; @@ -74,13 +72,11 @@ class DeleteCommentsCommandForm extends ObjectsCommandForm */ public function onSuccess() { - foreach ($this->objects as $object) { - /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ - $delComment = new DeleteCommentCommand(); - $delComment - ->setObject($object) - ->setCommentId($this->getElement('comment_id')->getValue()); - $this->getTransport($this->request)->send($delComment); + foreach ($this->comments as $comment) { + $cmd = new DeleteCommentCommand(); + $cmd->setCommentId($comment->id) + ->setIsService(isset($comment->service_description)); + $this->getTransport($this->request)->send($cmd); } $redirect = $this->getElement('redirect')->getValue(); if (! empty($redirect)) { @@ -89,4 +85,17 @@ class DeleteCommentsCommandForm extends ObjectsCommandForm Notification::success($this->translate('Deleting comment..')); return true; } + + /** + * Set the comments to be deleted upon success + * + * @param array $comments + * + * @return this fluent interface + */ + public function setComments(array $comments) + { + $this->comments = $comments; + return $this; + } } diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php index f11ac1128..566ad572c 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php @@ -64,11 +64,7 @@ class DeleteDowntimesCommandForm extends CommandForm foreach ($this->downtimes as $downtime) { $delDowntime = new DeleteDowntimeCommand(); $delDowntime->setDowntimeId($downtime->id); - $delDowntime->setDowntimeType( - isset($downtime->service_description) ? - DeleteDowntimeCommand::DOWNTIME_TYPE_SERVICE : - DeleteDowntimeCommand::DOWNTIME_TYPE_HOST - ); + $delDowntime->setIsService(isset($downtime->service_description)); $this->getTransport($this->request)->send($delDowntime); } $redirect = $this->getElement('redirect')->getValue(); @@ -86,7 +82,7 @@ class DeleteDowntimesCommandForm extends CommandForm * * @return $this */ - public function setDowntimes($downtimes) + public function setDowntimes(array $downtimes) { $this->downtimes = $downtimes; return $this; diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 141c688e7..690095360 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -83,7 +83,13 @@ if (count($comments) === 0) { populate(array('comment_id' => $comment->id, 'redirect' => $this->url)); + $delCommentForm->populate( + array( + 'comment_id' => $comment->id, + 'comment_is_service' => isset($comment->service_description), + 'redirect' => $this->url + ) + ); $delCommentForm->setAction($this->url('monitoring/comment/remove', array('comment_id' => $comment->id))); echo $delCommentForm; ?> diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index 859326b2e..1268a4050 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -128,7 +128,12 @@ if (count($downtimes) === 0) { populate(array('downtime_id' => $downtime->id, 'redirect' => $this->url)); + $delDowntimeForm->populate( + array( + 'downtime_id' => $downtime->id, + 'redirect' => $this->url + ) + ); $delDowntimeForm->setAction($this->url('monitoring/downtime/remove', array('downtime_id' => $downtime->id))); echo $delDowntimeForm; ?> diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 3629a4182..ce565df86 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -5,7 +5,7 @@ namespace Icinga\Module\Monitoring\Web\Controller; use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Forms\Command\Object\CheckNowCommandForm; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentsCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\ObjectsCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandForm; @@ -81,10 +81,8 @@ abstract class MonitoredObjectController extends Controller ->handleRequest(); $this->view->toggleFeaturesForm = $toggleFeaturesForm; if (! empty($this->object->comments) && $auth->hasPermission('monitoring/command/comment/delete')) { - $delCommentForm = new DeleteCommentsCommandForm(); - $delCommentForm - ->setObjects($this->object) - ->handleRequest(); + $delCommentForm = new DeleteCommentCommandForm(); + $delCommentForm->handleRequest(); $this->view->delCommentForm = $delCommentForm; } if (! empty($this->object->downtimes) && $auth->hasPermission('monitoring/command/downtime/delete')) { From b314c074cc277de1102cfbac5f050df886adc73f Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 16:20:59 +0200 Subject: [PATCH 04/11] Fix downtime and comment form redirects refs #8624 --- .../application/controllers/DowntimesController.php | 4 +--- .../monitoring/application/controllers/ListController.php | 6 ++++-- .../application/views/scripts/list/comments.phtml | 4 +--- .../application/views/scripts/list/downtimes.phtml | 3 +-- .../views/scripts/show/components/comments.phtml | 7 ++++++- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index f6dc53cb3..a5d49cd97 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -123,9 +123,7 @@ class Monitoring_DowntimesController extends Controller $this->translate('Confirm removal of %d downtimes.'), count($this->downtimes) )); - $delDowntimeForm->setDowntimes($this->downtimes) - ->setRedirectUrl(Url::fromPath('monitoring/list/downtimes')) - ->handleRequest(); + $delDowntimeForm->setDowntimes($this->downtimes)->handleRequest(); $this->view->delDowntimeForm = $delDowntimeForm; } } \ No newline at end of file diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 53b0e1edd..518bd6528 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -3,7 +3,7 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Backend; -use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentsCommandForm; +use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; use Icinga\Web\Url; use Icinga\Web\Widget\Tabextension\DashboardAction; @@ -295,6 +295,7 @@ class Monitoring_ListController extends Controller if ($this->Auth()->hasPermission('monitoring/command/downtime/delete')) { $this->view->delDowntimeForm = new DeleteDowntimeCommandForm(); + $this->view->delDowntimeForm->handleRequest(); } } @@ -501,7 +502,8 @@ class Monitoring_ListController extends Controller ); if ($this->Auth()->hasPermission('monitoring/command/comment/delete')) { - $this->view->delCommentForm = new DeleteCommentsCommandForm(); + $this->view->delCommentForm = new DeleteCommentCommandForm(); + $this->view->delCommentForm->handleRequest(); } } diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 690095360..f05adff1f 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -86,11 +86,9 @@ if (count($comments) === 0) { $delCommentForm->populate( array( 'comment_id' => $comment->id, - 'comment_is_service' => isset($comment->service_description), - 'redirect' => $this->url + 'comment_is_service' => isset($comment->service_description) ) ); - $delCommentForm->setAction($this->url('monitoring/comment/remove', array('comment_id' => $comment->id))); echo $delCommentForm; ?> diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index 1268a4050..0d35b77cd 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -131,10 +131,9 @@ if (count($downtimes) === 0) { $delDowntimeForm->populate( array( 'downtime_id' => $downtime->id, - 'redirect' => $this->url + 'downtime_is_service' => isset($downtime->service_description) ) ); - $delDowntimeForm->setAction($this->url('monitoring/downtime/remove', array('downtime_id' => $downtime->id))); echo $delDowntimeForm; ?> diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml index 5a4d351c0..478b1e7f3 100644 --- a/modules/monitoring/application/views/scripts/show/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml @@ -48,7 +48,12 @@ foreach ($object->comments as $comment) { populate(array('comment_id' => $comment->id)); + $delCommentForm->populate( + array( + 'comment_id' => $comment->id, + 'comment_is_service' => isset($comment->service_description) + ) + ); echo $delCommentForm; } ?> (translate('Comment'); ?>): ', $commentText); ?> From ac599e642ad07703bb3665623854e83ac176a570 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 16:21:34 +0200 Subject: [PATCH 05/11] Add submit button label to multi comment form refs #8624 --- .../Object/DeleteCommentsCommandForm.php | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php index 57f6aae5a..805002922 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteCommentsCommandForm.php @@ -46,24 +46,11 @@ class DeleteCommentsCommandForm extends CommandForm /** * (non-PHPDoc) - * @see \Icinga\Web\Form::addSubmitButton() For the method documentation. + * @see \Icinga\Web\Form::getSubmitLabel() For the method documentation. */ - public function addSubmitButton() + public function getSubmitLabel() { - $this->addElement( - 'button', - 'btn_submit', - array( - 'ignore' => true, - 'escape' => false, - 'type' => 'submit', - 'class' => 'link-like', - 'label' => $this->getView()->icon('trash'), - 'title' => $this->translate('Delete this comment'), - 'decorators' => array('ViewHelper') - ) - ); - return $this; + return $this->translatePlural('Remove', 'Remove All', count($this->downtimes)); } /** From 7cf2cb034e30192180377e5842c0508f8dc020c5 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 16:22:17 +0200 Subject: [PATCH 06/11] Remove unused and redundant controller actions refs #8624 --- .../application/controllers/CommentController.php | 9 --------- .../Web/Controller/MonitoredObjectController.php | 10 ---------- 2 files changed, 19 deletions(-) diff --git a/modules/monitoring/application/controllers/CommentController.php b/modules/monitoring/application/controllers/CommentController.php index 1c7f3e36d..c97f12558 100644 --- a/modules/monitoring/application/controllers/CommentController.php +++ b/modules/monitoring/application/controllers/CommentController.php @@ -77,15 +77,6 @@ class Monitoring_CommentController extends Controller } } - /** - * Receive DeleteCommentCommandForm post from other controller - */ - public function removeAction() - { - $this->assertHttpMethod('POST'); - $this->createDelCommentForm(); - } - /** * Create a command form to delete a single comment * diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index ce565df86..9c0921b9e 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -133,16 +133,6 @@ abstract class MonitoredObjectController extends Controller */ abstract public function scheduleDowntimeAction(); - /** - * Delete a comment - */ - public function deleteCommentAction() - { - $this->assertHttpMethod('POST'); - $this->assertPermission('monitoring/command/comment/delete'); - $this->handleCommandForm(new DeleteCommentsCommandForm()); - } - /** * Create tabs */ From 1fa550838d8bb63c647d8dd6c773ac58bed64544 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 16:37:35 +0200 Subject: [PATCH 07/11] Coding guidelines and cleanup --- .../monitoring/application/controllers/CommentsController.php | 2 +- .../forms/Command/Object/DeleteDowntimesCommandForm.php | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/controllers/CommentsController.php b/modules/monitoring/application/controllers/CommentsController.php index 9521af7c9..dcd1523e8 100644 --- a/modules/monitoring/application/controllers/CommentsController.php +++ b/modules/monitoring/application/controllers/CommentsController.php @@ -4,7 +4,6 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentsCommandForm; use Icinga\Web\Url; -use Icinga\Web\Widget\Tabextension\DashboardAction; use Icinga\Data\Filter\Filter; /** @@ -81,6 +80,7 @@ class Monitoring_CommentsController extends Controller public function removeAllAction() { $this->assertPermission('monitoring/command/comment/delete'); + $this->view->comments = $this->comments; $this->view->listAllLink = Url::fromPath('monitoring/list/comments') ->setQueryString($this->filter->toQueryString()); diff --git a/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php b/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php index 566ad572c..4a19cac96 100644 --- a/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/DeleteDowntimesCommandForm.php @@ -38,9 +38,7 @@ class DeleteDowntimesCommandForm extends CommandForm array( 'hidden', 'redirect', - array( - 'decorators' => array('ViewHelper') - ) + array('decorators' => array('ViewHelper')) ) )); return $this; From c6c78989a582293904c5742c214b4081e825fd63 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 17:02:34 +0200 Subject: [PATCH 08/11] Fix redirects after deleting a comment refs #8624 --- .../application/controllers/CommentController.php | 5 ++++- .../application/controllers/CommentsController.php | 12 +++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/application/controllers/CommentController.php b/modules/monitoring/application/controllers/CommentController.php index c97f12558..c3fcd18f8 100644 --- a/modules/monitoring/application/controllers/CommentController.php +++ b/modules/monitoring/application/controllers/CommentController.php @@ -64,12 +64,15 @@ class Monitoring_CommentController extends Controller */ public function showAction() { + $listCommentsLink = Url::fromPath('monitoring/list/comments') + ->setQueryString('comment_type=(comment|ack)'); + $this->view->comment = $this->comment; if ($this->hasPermission('monitoring/command/comment/delete')) { $this->view->delCommentForm = $this->createDelCommentForm(); $this->view->delCommentForm->populate( array( - 'redirect' => Url::fromPath('monitoring/list/comments'), + 'redirect' => $listCommentsLink, 'comment_id' => $this->comment->id, 'comment_is_service' => isset($this->comment->service_description) ) diff --git a/modules/monitoring/application/controllers/CommentsController.php b/modules/monitoring/application/controllers/CommentsController.php index dcd1523e8..64eeeb361 100644 --- a/modules/monitoring/application/controllers/CommentsController.php +++ b/modules/monitoring/application/controllers/CommentsController.php @@ -81,9 +81,8 @@ class Monitoring_CommentsController extends Controller { $this->assertPermission('monitoring/command/comment/delete'); - $this->view->comments = $this->comments; - $this->view->listAllLink = Url::fromPath('monitoring/list/comments') - ->setQueryString($this->filter->toQueryString()); + $listCommentsLink = Url::fromPath('monitoring/list/comments') + ->setQueryString('comment_type=(comment|ack)'); $delCommentForm = new DeleteCommentsCommandForm(); $delCommentForm->setTitle($this->view->translate('Remove all Comments')); $delCommentForm->addDescription(sprintf( @@ -91,8 +90,11 @@ class Monitoring_CommentsController extends Controller count($this->comments) )); $delCommentForm->setComments($this->comments) - ->setRedirectUrl(Url::fromPath('monitoring/list/comments')) - ->handleRequest(); + ->setRedirectUrl($listCommentsLink) + ->handleRequest(); $this->view->delCommentForm = $delCommentForm; + $this->view->comments = $this->comments; + $this->view->listAllLink = Url::fromPath('monitoring/list/comments') + ->setQueryString($this->filter->toQueryString()); } } From 83efc3a4a307158bcda000b071312eeea1c66d92 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 17:17:24 +0200 Subject: [PATCH 09/11] Conform to coding guidelines --- .../controllers/DowntimeController.php | 4 ++-- .../views/scripts/comment/show.phtml | 23 +++++++++++-------- .../Controller/MonitoredObjectController.php | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/modules/monitoring/application/controllers/DowntimeController.php b/modules/monitoring/application/controllers/DowntimeController.php index 1fed470fe..c06e0311d 100644 --- a/modules/monitoring/application/controllers/DowntimeController.php +++ b/modules/monitoring/application/controllers/DowntimeController.php @@ -82,7 +82,7 @@ class Monitoring_DowntimeController extends Controller 'label' => $this->translate('Downtime'), 'url' =>'monitoring/downtimes/show' ) - )->activate('downtime')->extend(new DashboardAction()); + )->activate('downtime')->extend(new DashboardAction()); } /** @@ -92,7 +92,7 @@ class Monitoring_DowntimeController extends Controller { $this->view->downtime = $this->downtime; $this->view->isService = $this->isService; - $this->view->stateName = isset($this->downtime->service_description) ? + $this->view->stateName = isset($this->downtime->service_description) ? Service::getStateText($this->downtime->service_state) : Host::getStateText($this->downtime->host_state); $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes'); diff --git a/modules/monitoring/application/views/scripts/comment/show.phtml b/modules/monitoring/application/views/scripts/comment/show.phtml index 9010021c3..8216a9c70 100644 --- a/modules/monitoring/application/views/scripts/comment/show.phtml +++ b/modules/monitoring/application/views/scripts/comment/show.phtml @@ -18,11 +18,12 @@ icon('service', $this->translate('Service')); ?> link()->service( - $this->comment->service_description, - $this->comment->service_display_name, - $this->comment->host_name, - $this->comment->host_display_name - ); ?> + $this->comment->service_description, + $this->comment->service_display_name, + $this->comment->host_name, + $this->comment->host_display_name + ); + ?> translate('Host') ?> @@ -31,7 +32,8 @@ link()->host( $this->comment->host_name, $this->comment->host_display_name - ); ?> + ); + ?> @@ -55,10 +57,11 @@ translate('Expires') ?> comment->expiration ? sprintf( - $this->translate('This comment expires on %s at %s.'), - date('d.m.y', $this->comment->expiration), - date('H:i', $this->comment->expiration) - ) : $this->translate('This comment does not expire.'); ?> + $this->translate('This comment expires on %s at %s.'), + date('d.m.y', $this->comment->expiration), + date('H:i', $this->comment->expiration) + ) : $this->translate('This comment does not expire.'); + ?> diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 9c0921b9e..9d27b1268 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -62,7 +62,7 @@ abstract class MonitoredObjectController extends Controller ->handleRequest(); $this->view->checkNowForm = $checkNowForm; } - if ( ! in_array((int) $this->object->state, array(0, 99))) { + if (! in_array((int) $this->object->state, array(0, 99))) { if ((bool) $this->object->acknowledged) { if ($auth->hasPermission('monitoring/command/remove-acknowledgement')) { $removeAckForm = new RemoveAcknowledgementCommandForm(); From fff2d5c816cdd12d7aca63123d5d0b4e16ff3922 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 17:29:46 +0200 Subject: [PATCH 10/11] Use consistent controller names refs #8624 --- .../monitoring/application/controllers/CommentsController.php | 4 ++-- .../application/controllers/DowntimesController.php | 4 ++-- .../scripts/comments/{remove-all.phtml => delete-all.phtml} | 0 .../scripts/downtimes/{remove-all.phtml => delete-all.phtml} | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename modules/monitoring/application/views/scripts/comments/{remove-all.phtml => delete-all.phtml} (100%) rename modules/monitoring/application/views/scripts/downtimes/{remove-all.phtml => delete-all.phtml} (100%) diff --git a/modules/monitoring/application/controllers/CommentsController.php b/modules/monitoring/application/controllers/CommentsController.php index 64eeeb361..e9a885dbe 100644 --- a/modules/monitoring/application/controllers/CommentsController.php +++ b/modules/monitoring/application/controllers/CommentsController.php @@ -70,14 +70,14 @@ class Monitoring_CommentsController extends Controller $this->view->comments = $this->comments; $this->view->listAllLink = Url::fromPath('monitoring/list/comments') ->setQueryString($this->filter->toQueryString()); - $this->view->removeAllLink = Url::fromPath('monitoring/comments/remove-all') + $this->view->removeAllLink = Url::fromPath('monitoring/comments/delete-all') ->setParams($this->params); } /** * Display the form for removing a comment list */ - public function removeAllAction() + public function deleteAllAction() { $this->assertPermission('monitoring/command/comment/delete'); diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index a5d49cd97..dfd5a6758 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -104,14 +104,14 @@ class Monitoring_DowntimesController extends Controller $this->view->downtimes = $this->downtimes; $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes') ->setQueryString($this->filter->toQueryString()); - $this->view->removeAllLink = Url::fromPath('monitoring/downtimes/remove-all') + $this->view->removeAllLink = Url::fromPath('monitoring/downtimes/delete-all') ->setParams($this->params); } /** * Display the form for removing a downtime list */ - public function removeAllAction() + public function deleteAllAction() { $this->assertPermission('monitoring/command/downtime/delete'); $this->view->downtimes = $this->downtimes; diff --git a/modules/monitoring/application/views/scripts/comments/remove-all.phtml b/modules/monitoring/application/views/scripts/comments/delete-all.phtml similarity index 100% rename from modules/monitoring/application/views/scripts/comments/remove-all.phtml rename to modules/monitoring/application/views/scripts/comments/delete-all.phtml diff --git a/modules/monitoring/application/views/scripts/downtimes/remove-all.phtml b/modules/monitoring/application/views/scripts/downtimes/delete-all.phtml similarity index 100% rename from modules/monitoring/application/views/scripts/downtimes/remove-all.phtml rename to modules/monitoring/application/views/scripts/downtimes/delete-all.phtml From 8c5f2662ea9d99485283e973ee095a251b2f07c7 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 7 May 2015 17:33:38 +0200 Subject: [PATCH 11/11] Fix redirects in downtime multi view refs #8624 --- .../monitoring/application/controllers/DowntimesController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index dfd5a6758..49424ed3a 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -123,6 +123,7 @@ class Monitoring_DowntimesController extends Controller $this->translate('Confirm removal of %d downtimes.'), count($this->downtimes) )); + $delDowntimeForm->setRedirectUrl(Url::fromPath('monitoring/list/downtimes')); $delDowntimeForm->setDowntimes($this->downtimes)->handleRequest(); $this->view->delDowntimeForm = $delDowntimeForm; }