Disable persistent comment checkbox if backend is Icinga 2

refs #11100
This commit is contained in:
Eric Lippmann 2016-02-25 17:51:02 +01:00
parent 863bf08864
commit 02eea2ad11
6 changed files with 21 additions and 22 deletions

View File

@ -151,7 +151,6 @@ class HostController extends MonitoredObjectController
$this->assertPermission('monitoring/command/downtime/schedule'); $this->assertPermission('monitoring/command/downtime/schedule');
$form = new ScheduleHostDowntimeCommandForm(); $form = new ScheduleHostDowntimeCommandForm();
$form->setBackend($this->backend);
$form->setTitle($this->translate('Schedule Host Downtime')); $form->setTitle($this->translate('Schedule Host Downtime'));
$this->handleCommandForm($form); $this->handleCommandForm($form);
} }
@ -164,7 +163,6 @@ class HostController extends MonitoredObjectController
$this->assertPermission('monitoring/command/process-check-result'); $this->assertPermission('monitoring/command/process-check-result');
$form = new ProcessCheckResultCommandForm(); $form = new ProcessCheckResultCommandForm();
$form->setBackend($this->backend);
$form->setTitle($this->translate('Submit Passive Host Check Result')); $form->setTitle($this->translate('Submit Passive Host Check Result'));
$this->handleCommandForm($form); $this->handleCommandForm($form);
} }

View File

@ -69,6 +69,7 @@ class HostsController extends Controller
protected function handleCommandForm(ObjectsCommandForm $form) protected function handleCommandForm(ObjectsCommandForm $form)
{ {
$form $form
->setBackend($this->backend)
->setObjects($this->hostList) ->setObjects($this->hostList)
->setRedirectUrl(Url::fromPath('monitoring/hosts/show')->setParams($this->params)) ->setRedirectUrl(Url::fromPath('monitoring/hosts/show')->setParams($this->params))
->handleRequest(); ->handleRequest();
@ -194,7 +195,6 @@ class HostsController extends Controller
$this->assertPermission('monitoring/command/downtime/schedule'); $this->assertPermission('monitoring/command/downtime/schedule');
$form = new ScheduleHostDowntimeCommandForm(); $form = new ScheduleHostDowntimeCommandForm();
$form->setBackend($this->backend);
$form->setTitle($this->translate('Schedule Host Downtimes')); $form->setTitle($this->translate('Schedule Host Downtimes'));
$this->handleCommandForm($form); $this->handleCommandForm($form);
} }
@ -207,7 +207,6 @@ class HostsController extends Controller
$this->assertPermission('monitoring/command/process-check-result'); $this->assertPermission('monitoring/command/process-check-result');
$form = new ProcessCheckResultCommandForm(); $form = new ProcessCheckResultCommandForm();
$form->setBackend($this->backend);
$form->setTitle($this->translate('Submit Passive Host Check Results')); $form->setTitle($this->translate('Submit Passive Host Check Results'));
$this->handleCommandForm($form); $this->handleCommandForm($form);
} }

View File

@ -121,7 +121,6 @@ class ServiceController extends MonitoredObjectController
$this->assertPermission('monitoring/command/process-check-result'); $this->assertPermission('monitoring/command/process-check-result');
$form = new ProcessCheckResultCommandForm(); $form = new ProcessCheckResultCommandForm();
$form->setBackend($this->backend);
$form->setTitle($this->translate('Submit Passive Service Check Result')); $form->setTitle($this->translate('Submit Passive Service Check Result'));
$this->handleCommandForm($form); $this->handleCommandForm($form);
} }

View File

@ -75,6 +75,7 @@ class ServicesController extends Controller
protected function handleCommandForm(ObjectsCommandForm $form) protected function handleCommandForm(ObjectsCommandForm $form)
{ {
$form $form
->setBackend($this->backend)
->setObjects($this->serviceList) ->setObjects($this->serviceList)
->setRedirectUrl(Url::fromPath('monitoring/services/show')->setParams($this->params)) ->setRedirectUrl(Url::fromPath('monitoring/services/show')->setParams($this->params))
->handleRequest(); ->handleRequest();
@ -209,7 +210,6 @@ class ServicesController extends Controller
$this->assertPermission('monitoring/command/process-check-result'); $this->assertPermission('monitoring/command/process-check-result');
$form = new ProcessCheckResultCommandForm(); $form = new ProcessCheckResultCommandForm();
$form->setBackend($this->backend);
$form->setTitle($this->translate('Submit Passive Service Check Results')); $form->setTitle($this->translate('Submit Passive Service Check Results'));
$this->handleCommandForm($form); $this->handleCommandForm($form);
} }

View File

@ -34,8 +34,7 @@ class AddCommentCommandForm extends ObjectsCommandForm
*/ */
public function createElements(array $formData = array()) public function createElements(array $formData = array())
{ {
$this->addElements(array( $this->addElement(
array(
'textarea', 'textarea',
'comment', 'comment',
array( array(
@ -47,8 +46,9 @@ class AddCommentCommandForm extends ObjectsCommandForm
. ' what you are doing.' . ' what you are doing.'
) )
) )
), );
array( if (! $this->getBackend()->isIcinga2()) {
$this->addElement(
'checkbox', 'checkbox',
'persistent', 'persistent',
array( array(
@ -59,8 +59,8 @@ class AddCommentCommandForm extends ObjectsCommandForm
. ' restarted.' . ' restarted.'
) )
) )
) );
)); }
return $this; return $this;
} }
@ -76,7 +76,9 @@ class AddCommentCommandForm extends ObjectsCommandForm
$comment->setObject($object); $comment->setObject($object);
$comment->setComment($this->getElement('comment')->getValue()); $comment->setComment($this->getElement('comment')->getValue());
$comment->setAuthor($this->request->getUser()->getUsername()); $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); $this->getTransport($this->request)->send($comment);
} }
Notification::success($this->translatePlural( Notification::success($this->translatePlural(

View File

@ -122,6 +122,7 @@ abstract class MonitoredObjectController extends Controller
protected function handleCommandForm(ObjectsCommandForm $form) protected function handleCommandForm(ObjectsCommandForm $form)
{ {
$form $form
->setBackend($this->backend)
->setObjects($this->object) ->setObjects($this->object)
->setRedirectUrl(Url::fromPath($this->commandRedirectUrl)->setParams($this->params)) ->setRedirectUrl(Url::fromPath($this->commandRedirectUrl)->setParams($this->params))
->handleRequest(); ->handleRequest();