diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index 65e0e70fe..bb98b2a8f 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -151,7 +151,6 @@ class HostController extends MonitoredObjectController $this->assertPermission('monitoring/command/downtime/schedule'); $form = new ScheduleHostDowntimeCommandForm(); - $form->setBackend($this->backend); $form->setTitle($this->translate('Schedule Host Downtime')); $this->handleCommandForm($form); } @@ -164,7 +163,6 @@ class HostController extends MonitoredObjectController $this->assertPermission('monitoring/command/process-check-result'); $form = new ProcessCheckResultCommandForm(); - $form->setBackend($this->backend); $form->setTitle($this->translate('Submit Passive Host Check Result')); $this->handleCommandForm($form); } diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 793df1ec8..12017657c 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -69,6 +69,7 @@ class HostsController extends Controller protected function handleCommandForm(ObjectsCommandForm $form) { $form + ->setBackend($this->backend) ->setObjects($this->hostList) ->setRedirectUrl(Url::fromPath('monitoring/hosts/show')->setParams($this->params)) ->handleRequest(); @@ -194,7 +195,6 @@ class HostsController extends Controller $this->assertPermission('monitoring/command/downtime/schedule'); $form = new ScheduleHostDowntimeCommandForm(); - $form->setBackend($this->backend); $form->setTitle($this->translate('Schedule Host Downtimes')); $this->handleCommandForm($form); } @@ -207,7 +207,6 @@ class HostsController extends Controller $this->assertPermission('monitoring/command/process-check-result'); $form = new ProcessCheckResultCommandForm(); - $form->setBackend($this->backend); $form->setTitle($this->translate('Submit Passive Host Check Results')); $this->handleCommandForm($form); } diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php index 0018407bb..4d049149a 100644 --- a/modules/monitoring/application/controllers/ServiceController.php +++ b/modules/monitoring/application/controllers/ServiceController.php @@ -121,7 +121,6 @@ class ServiceController extends MonitoredObjectController $this->assertPermission('monitoring/command/process-check-result'); $form = new ProcessCheckResultCommandForm(); - $form->setBackend($this->backend); $form->setTitle($this->translate('Submit Passive Service Check Result')); $this->handleCommandForm($form); } diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index 9d4c9a4c8..53312ae48 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -75,6 +75,7 @@ class ServicesController extends Controller protected function handleCommandForm(ObjectsCommandForm $form) { $form + ->setBackend($this->backend) ->setObjects($this->serviceList) ->setRedirectUrl(Url::fromPath('monitoring/services/show')->setParams($this->params)) ->handleRequest(); @@ -209,7 +210,6 @@ class ServicesController extends Controller $this->assertPermission('monitoring/command/process-check-result'); $form = new ProcessCheckResultCommandForm(); - $form->setBackend($this->backend); $form->setTitle($this->translate('Submit Passive Service Check Results')); $this->handleCommandForm($form); } diff --git a/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php b/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php index a04029c66..4d6124e0c 100644 --- a/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php @@ -34,21 +34,21 @@ class AddCommentCommandForm extends ObjectsCommandForm */ public function createElements(array $formData = array()) { - $this->addElements(array( + $this->addElement( + 'textarea', + 'comment', array( - 'textarea', - 'comment', - array( - 'required' => true, - 'label' => $this->translate('Comment'), - 'description' => $this->translate( - 'If you work with other administrators, you may find it useful to share information about the' - . ' the host or service that is having problems. Make sure you enter a brief description of' - . ' what you are doing.' - ) + 'required' => true, + 'label' => $this->translate('Comment'), + 'description' => $this->translate( + 'If you work with other administrators, you may find it useful to share information about the' + . ' the host or service that is having problems. Make sure you enter a brief description of' + . ' what you are doing.' ) - ), - array( + ) + ); + if (! $this->getBackend()->isIcinga2()) { + $this->addElement( 'checkbox', 'persistent', array( @@ -59,8 +59,8 @@ class AddCommentCommandForm extends ObjectsCommandForm . ' restarted.' ) ) - ) - )); + ); + } return $this; } @@ -76,7 +76,9 @@ class AddCommentCommandForm extends ObjectsCommandForm $comment->setObject($object); $comment->setComment($this->getElement('comment')->getValue()); $comment->setAuthor($this->request->getUser()->getUsername()); - $comment->setPersistent($this->getElement('persistent')->isChecked()); + if (($persistent = $this->getElement('persistent')) !== null) { + $comment->setPersistent($persistent->isChecked()); + } $this->getTransport($this->request)->send($comment); } Notification::success($this->translatePlural( diff --git a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php index 2d4d54ffa..f7a0b8179 100644 --- a/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php +++ b/modules/monitoring/library/Monitoring/Web/Controller/MonitoredObjectController.php @@ -122,6 +122,7 @@ abstract class MonitoredObjectController extends Controller protected function handleCommandForm(ObjectsCommandForm $form) { $form + ->setBackend($this->backend) ->setObjects($this->object) ->setRedirectUrl(Url::fromPath($this->commandRedirectUrl)->setParams($this->params)) ->handleRequest();