diff --git a/www/include/configuration/configObject/host_categories/DB-Func.php b/www/include/configuration/configObject/host_categories/DB-Func.php index bca897bcc8c..43a10f3a2ac 100644 --- a/www/include/configuration/configObject/host_categories/DB-Func.php +++ b/www/include/configuration/configObject/host_categories/DB-Func.php @@ -148,6 +148,7 @@ function multipleHostCategoriesInDB($hostcategories = array(), $nbrDup = array() for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; $rq = null; + $level = false; foreach ($row as $key2 => $value2) { (isset($key2) && $key2 == "hc_name") ? ($hc_name = $value2 = $value2 . "_" . $i) : null; $val @@ -156,6 +157,9 @@ function multipleHostCategoriesInDB($hostcategories = array(), $nbrDup = array() if ($key2 != "hc_id") { $fields[$key2] = $value2; } + if ($key2 == "level" && $value2 != "") { + $level = true; + } } $fields["hc_name"] = $hc_name; if (testHostCategorieExistence($hc_name)) { @@ -163,7 +167,7 @@ function multipleHostCategoriesInDB($hostcategories = array(), $nbrDup = array() $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(hc_id) FROM hostcategories"); $maxId = $DBRESULT->fetchRow(); - if (isset($maxId["MAX(hc_id)"])) { + if (isset($maxId["MAX(hc_id)"]) && !$level) { $hcAcl[$maxId["MAX(hc_id)"]] = $key; $query = "SELECT DISTINCT hgr.host_host_id FROM hostcategories_relation hgr " . "WHERE hgr.hostcategories_hc_id = '" . $key . "'";