Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/notification-command-inherited-fields-missing refs #2286 #2764

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
42 changes: 24 additions & 18 deletions library/Director/Web/Form/IcingaObjectFieldLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,28 +420,34 @@ protected function mergeFields($listOfFields)
protected function prepareObjectFields($object)
{
$fields = $this->loadResolvedFieldsForObject($object);
$relation = null;
if ($object->hasRelation('check_command')) {
try {
/** @var IcingaCommand $command */
$command = $object->getResolvedRelated('check_command');
} catch (Exception $e) {
// Ignore failures
$command = null;
}

if ($command) {
$cmdLoader = new static($command);
$cmdFields = $cmdLoader->getFields();
foreach ($cmdFields as $varname => $field) {
if (! array_key_exists($varname, $fields)) {
$fields[$varname] = $field;
}
#for checks
$relation = "check_command";
} elseif ($object->hasRelation('command')) {
#for notifications
$relation = "command";
}

try {
/** @var IcingaCommand $command */
$command = $object->getResolvedRelated($relation);
} catch (Exception $e) {
// Ignore failures
$command = null;
}

if ($command) {
$cmdLoader = new static($command);
$cmdFields = $cmdLoader->getFields();
foreach ($cmdFields as $varname => $field) {
if (!array_key_exists($varname, $fields)) {
$fields[$varname] = $field;
}
}

// TODO -> filters!
}


// TODO -> filters!
return $fields;
}

Expand Down
Loading