fixed error acl

This commit is contained in:
daniel 2018-02-12 12:38:28 +01:00
parent bfdcf168bc
commit fabe14b7ea
1 changed files with 6 additions and 9 deletions

View File

@ -140,6 +140,9 @@ function users_get_groups_for_select($id_user, $privilege = "AR", $returnAllGro
} }
function get_group_ancestors($group_id, $groups) { function get_group_ancestors($group_id, $groups) {
if($group_id == 0) {
return 0;
}
if (!isset($groups[$group_id])) { if (!isset($groups[$group_id])) {
return null; return null;
@ -151,17 +154,13 @@ function get_group_ancestors($group_id, $groups) {
return $group_id; return $group_id;
} }
if ($parent == 0) {
return 0;
}
$r = get_group_ancestors($parent, $groups); $r = get_group_ancestors($parent, $groups);
if (is_array($r)) { if (is_array($r)) {
$r = array_merge(array($parent), $r); $r = array_merge(array($group_id), $r);
} }
else { else {
$r = array($parent, $r); $r = array($group_id, $r);
} }
return $r; return $r;
@ -300,8 +299,7 @@ function users_get_groups ($id_user = false, $privilege = "AR", $returnAllGroup
} }
foreach ($groups as $group) { foreach ($groups as $group) {
$parents = get_group_ancestors($group["id_grupo"],$groups); $parents = get_group_ancestors($group["parent"],$groups);
if (is_array($parents)) { if (is_array($parents)) {
foreach ($parents as $parent) { foreach ($parents as $parent) {
if ( (isset($forest_acl[$parent])) && ($groups[$parent]["propagate"] == 1)) { if ( (isset($forest_acl[$parent])) && ($groups[$parent]["propagate"] == 1)) {
@ -325,7 +323,6 @@ function users_get_groups ($id_user = false, $privilege = "AR", $returnAllGroup
} }
} }
} }
// Update the group cache. // Update the group cache.
$group_cache[$id_user] = $forest_acl; $group_cache[$id_user] = $forest_acl;
} }