Use isIcinga2() in command forms where needed

This commit is contained in:
Eric Lippmann 2016-02-25 17:51:37 +01:00
parent 02eea2ad11
commit 5f8b994d5f
3 changed files with 3 additions and 13 deletions

View File

@ -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');
}

View File

@ -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',

View File

@ -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();
}
}