Private GIT

Skip to content
Snippets Groups Projects
Commit 1a25390d authored by Kevin Duret's avatar Kevin Duret
Browse files

fix acl on host categories (inheritance)

parent 6a8284fc
No related branches found
No related tags found
No related merge requests found
......@@ -87,9 +87,8 @@ function getFilteredPollers($host, $acl_group_id, $res_id)
*/
function getFilteredHostCategories($host, $acl_group_id, $res_id)
{
global $pearDB, $hostCache, $hostTemplateCache;
global $pearDB, $hostTemplateCache;
$hostTmp = $host;
$request = "SELECT host_host_id " .
"FROM acl_resources_hc_relations, acl_res_group_relations, acl_resources, hostcategories_relation " .
"WHERE acl_resources_hc_relations.acl_res_id = acl_res_group_relations.acl_res_id " .
......@@ -99,23 +98,39 @@ function getFilteredHostCategories($host, $acl_group_id, $res_id)
"AND hostcategories_relation.hostcategories_hc_id = acl_resources_hc_relations.hc_id " .
"AND acl_res_activate = '1'";
$DBRESULT = $pearDB->query($request);
if ($DBRESULT->numRows()) {
$host = array();
if (!$DBRESULT->numRows()) {
return $host;
}
$treatedHosts = array();
$linkedHosts = array();
while ($row = $DBRESULT->fetchRow()) {
if (isset($hostTemplateCache[$row['host_host_id']])) {
// is a template
foreach ($hostTemplateCache[$row['host_host_id']] as $hId) {
if (isset($hostTmp[$hId])) {
$host[$hId] = $hostCache[$hId];
$linkedHosts[] = $row['host_host_id'];
}
$filteredHosts = array();
while ($linkedHostId = array_pop($linkedHosts)) {
$treatedHosts[] = $linkedHostId;
if (isset($host[$linkedHostId])) { // host
$filteredHosts[$linkedHostId] = $host[$linkedHostId];
} elseif (isset($hostTemplateCache[$linkedHostId])) { // host template
foreach ($hostTemplateCache[$linkedHostId] as $hostId) {
if (isset($host[$hostId])) {
$filteredHosts[$hostId] = $host[$hostId];
}
if (isset($hostTemplateCache[$hostId])) {
foreach ($hostTemplateCache[$hostId] as $hostId2) {
if (!in_array($hostId2, $linkedHosts)) {
$linkedHosts[] = $hostId2;
}
} elseif (isset($hostTmp[$row['host_host_id']])) {
// is not a template
$host[$row['host_host_id']] = $hostCache[$row['host_host_id']];
}
}
return $host;
}
}
}
return $filteredHosts;
}
/*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment