Skip to content

Commit

Permalink
Merge branch 'bugfix/disable-downtimes-for-child-hosts-w-icinga2-10774'
Browse files Browse the repository at this point in the history
refs #10744
  • Loading branch information
lippserd committed Dec 21, 2015
2 parents 9f8ee4f + 627680d commit 7bafab2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
Expand Up @@ -153,6 +153,7 @@ public function scheduleDowntimeAction()
$this->assertPermission('monitoring/command/downtime/schedule');

$form = new ScheduleHostDowntimeCommandForm();
$form->setBackend($this->backend);
$form->setTitle($this->translate('Schedule Host Downtime'));
$this->handleCommandForm($form);
}
Expand Down
Expand Up @@ -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(
Expand All @@ -47,8 +49,9 @@ public function createElements(array $formData = array())
),
'value' => 0
)
)
));
);
}

return $this;
}

Expand All @@ -60,7 +63,11 @@ public function onSuccess()
{
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();
Expand Down

0 comments on commit 7bafab2

Please sign in to comment.