From 5f8b994d5f11ec5f5e05e8db7c007f80594b42d0 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 25 Feb 2016 17:51:37 +0100 Subject: [PATCH] Use isIcinga2() in command forms where needed --- .../Command/Object/ProcessCheckResultCommandForm.php | 2 +- .../Object/ScheduleHostDowntimeCommandForm.php | 2 +- .../Object/ToggleObjectFeaturesCommandForm.php | 12 +----------- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php b/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php index db45449cb..569278567 100644 --- a/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php @@ -124,7 +124,7 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm ProcessCheckResultCommand::HOST_DOWN => $this->translate('DOWN', 'icinga.state') ); - if (substr($this->getBackend()->getProgramVersion(), 0, 2) !== 'v2') { + if (! $this->getBackend()->isIcinga2()) { $options[ProcessCheckResultCommand::HOST_UNREACHABLE] = $this->translate('UNREACHABLE', 'icinga.state'); } diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php index 424823cca..05d1451d9 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php @@ -33,7 +33,7 @@ class ScheduleHostDowntimeCommandForm extends ScheduleServiceDowntimeCommandForm ) ); - if (substr($this->getBackend()->getProgramVersion(), 0, 2) !== 'v2') { + if (! $this->getBackend()->isIcinga2()) { $this->addElement( 'select', 'child_hosts', diff --git a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php index 74d9e073b..cc76327b5 100644 --- a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php @@ -59,7 +59,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm 'permission' => 'monitoring/command/feature/object/flap-detection' ) ); - if (preg_match('~^[vr]2\.\d+\.\d+.*$~', $this->getIcingaVersion())) { + if ($this->getBackend()->isIcinga2()) { unset($features[ToggleObjectFeatureCommand::FEATURE_OBSESSING]); } $this->features = $features; @@ -176,14 +176,4 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm return true; } - - /** - * Fetch and return the program version of the current instance - * - * @return string - */ - protected function getIcingaVersion() - { - return $this->getBackend()->select()->from('programstatus', array('program_version'))->fetchOne(); - } }