Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
fix(conf): fix disabling additive inheritance (#11813)
Browse files Browse the repository at this point in the history
Co-authored-by: TamazC <103252125+TamazC@users.noreply.github.com>
  • Loading branch information
2 people authored and tuntoja committed Oct 12, 2022
1 parent 0cd6212 commit 690ea3b
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions www/include/configuration/configObject/host/DB-Func.php
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,13 @@ function updateHost($host_id = null, $from_MC = false, $cfg = null)
$ret = $cfg;
}

if (!isset($ret["contact_additive_inheritance"])) {
$ret["contact_additive_inheritance"] = "0";
}
if (!isset($ret["cg_additive_inheritance"])) {
$ret["cg_additive_inheritance"] = "0";
}

isset($ret["nagios_server_id"])
? $server_id = $ret["nagios_server_id"]
: $server_id = $form->getSubmitValue("nagios_server_id");
Expand Down Expand Up @@ -2620,8 +2627,8 @@ function sanitizeFormHostParameters(array $ret): array
$inputValue = filter_var($inputValue, FILTER_SANITIZE_STRING);
$bindParams[':' . $inputName] = [
\PDO::PARAM_STR => ($inputValue === '' || $inputValue === false)
? null
: $inputValue
? null
: $inputValue
];
}
break;
Expand Down Expand Up @@ -2661,38 +2668,34 @@ function sanitizeFormHostParameters(array $ret): array
$inputValue = filter_var(implode(",", array_keys($inputValue)), FILTER_SANITIZE_STRING);
$bindParams[':host_notification_options'] = [
\PDO::PARAM_STR => ($inputValue === '' || $inputValue === false)
? null
: $inputValue
? null
: $inputValue
];
}
break;
case 'contact_additive_inheritance':
case 'cg_additive_inheritance':
$bindParams[':' . $inputName] = [
\PDO::PARAM_INT => (isset($ret[$inputName]) ? 1 : 0)
];
$bindParams[':' . $inputName] = [\PDO::PARAM_INT => $inputValue];
break;
case 'mc_contact_additive_inheritance':
case 'mc_cg_additive_inheritance':
$bindParams[':' . str_replace('mc_', '', $inputName)] = [
\PDO::PARAM_INT => (isset($ret[$inputName]) ? 1 : 0)
];
if (in_array($inputValue[$inputName], ['0', '1'])) {
$bindParams[':' . str_replace('mc_', '', $inputName)] = [
\PDO::PARAM_INT => $inputValue[$inputName]
];
}
break;
case 'host_stalOpts':
if (!empty($inputValue)) {
$inputValue = filter_var(implode(",", array_keys($inputValue)), FILTER_SANITIZE_STRING);
$bindParams[':host_stalking_options'] = [
\PDO::PARAM_STR => ($inputValue === '' || $inputValue === false)
? null
: $inputValue
\PDO::PARAM_STR => ($inputValue === '' || $inputValue === false) ? null : $inputValue
];
}
break;
case 'host_register':
$bindParams[':' . $inputName] = [
\PDO::PARAM_STR => in_array($inputValue, ['0', '1', '2', '3'])
? $inputValue
: null
\PDO::PARAM_STR => in_array($inputValue, ['0', '1', '2', '3']) ? $inputValue : null
];
break;
case 'host_activate':
Expand Down

0 comments on commit 690ea3b

Please sign in to comment.