diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index 6f0fe720a..b8516b32f 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -153,6 +153,7 @@ 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); } diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php index 830b6cab0..9528b9ed0 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php @@ -20,19 +20,21 @@ class ScheduleHostDowntimeCommandForm extends ScheduleServiceDowntimeCommandForm public function createElements(array $formData = array()) { parent::createElements($formData); - $this->addElements(array( - array( - 'checkbox', - 'all_services', - array( - 'description' => $this->translate( - 'Schedule downtime for all services on the hosts and the hosts themselves.' - ), - 'label' => $this->translate('All Services'), - 'value' => false - ) - ), + + $this->addElement( + 'checkbox', + 'all_services', array( + 'description' => $this->translate( + 'Schedule downtime for all services on the hosts and the hosts themselves.' + ), + 'label' => $this->translate('All Services'), + 'value' => false + ) + ); + + if (substr($this->getBackend()->getProgramVersion(), 0, 2) !== 'v2') { + $this->addElement( 'select', 'child_hosts', array( @@ -47,8 +49,9 @@ class ScheduleHostDowntimeCommandForm extends ScheduleServiceDowntimeCommandForm ), 'value' => 0 ) - ) - )); + ); + } + return $this; } @@ -60,7 +63,11 @@ class ScheduleHostDowntimeCommandForm extends ScheduleServiceDowntimeCommandForm { foreach ($this->objects as $object) { /** @var \Icinga\Module\Monitoring\Object\Host $object */ - $childHosts = (int) $this->getElement('child_hosts')->getValue(); + if (($childHostsEl = $this->getElement('child_hosts')) !== null) { + $childHosts = (int) $childHostsEl->getValue(); + } else { + $childHosts = 0; + } $allServices = $this->getElement('all_services')->isChecked(); if ($childHosts === 0) { $hostDowntime = new ScheduleHostDowntimeCommand();