From 18f382e85e51e54cc9506a4e9d6fc94685216085 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Tue, 4 Aug 2015 13:30:46 +0200 Subject: [PATCH] ProcessCheckResultCommandForm: Use getHostMultiOptions method refs #9672 --- .../Object/ProcessCheckResultCommandForm.php | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php b/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php index ec80a539f..6b566bbd6 100644 --- a/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ProcessCheckResultCommandForm.php @@ -52,11 +52,7 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm 'required' => true, 'label' => $this->translate('Status'), 'description' => $this->translate('The state this check result should report'), - 'multiOptions' => $object->getType() === $object::TYPE_HOST ? array( - ProcessCheckResultCommand::HOST_UP => $this->translate('UP', 'icinga.state'), - ProcessCheckResultCommand::HOST_DOWN => $this->translate('DOWN', 'icinga.state'), - ProcessCheckResultCommand::HOST_UNREACHABLE => $this->translate('UNREACHABLE', 'icinga.state') - ) : array( + 'multiOptions' => $object->getType() === $object::TYPE_HOST ? $this->getHostMultiOptions() : array( ProcessCheckResultCommand::SERVICE_OK => $this->translate('OK', 'icinga.state'), ProcessCheckResultCommand::SERVICE_WARNING => $this->translate('WARNING', 'icinga.state'), ProcessCheckResultCommand::SERVICE_CRITICAL => $this->translate('CRITICAL', 'icinga.state'), @@ -115,4 +111,23 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm return true; } + + /** + * Returns the available host options based on the program version + * + * @return array + */ + protected function getHostMultiOptions() + { + $options = array( + ProcessCheckResultCommand::HOST_UP => $this->translate('UP', 'icinga.state'), + ProcessCheckResultCommand::HOST_DOWN => $this->translate('DOWN', 'icinga.state') + ); + + if (! preg_match('~^v2\.\d+\.\d+.*$~', $this->getBackend()->getProgramVersion())) { + $options[ProcessCheckResultCommand::HOST_UNREACHABLE] = $this->translate('UNREACHABLE', 'icinga.state'); + } + + return $options; + } }