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');
$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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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(

View File

@ -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();