[icinga-checkins] icinga.org: icingaweb2/bugfix/disable-comment-persisent-for-icinga2-11100: Use isIcinga2() in command forms where needed

git at icinga.org git at icinga.org
Thu Feb 25 17:52:57 CET 2016


Module: icingaweb2
Branch: bugfix/disable-comment-persisent-for-icinga2-11100
Commit: 5f8b994d5f11ec5f5e05e8db7c007f80594b42d0
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=5f8b994d5f11ec5f5e05e8db7c007f80594b42d0

Author: Eric Lippmann <eric.lippmann at netways.de>
Date:   Thu Feb 25 17:51:37 2016 +0100

Use isIcinga2() in command forms where needed

---

 .../forms/Command/Object/ProcessCheckResultCommandForm.php |    2 +-
 .../Command/Object/ScheduleHostDowntimeCommandForm.php     |    2 +-
 .../Command/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 db45449..5692785 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 424823c..05d1451 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 74d9e07..cc76327 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();
-    }
 }



More information about the icinga-checkins mailing list