diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index b59feaa6a8..b44c54cd1b 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -1578,4 +1578,30 @@ function groups_get_tree(&$groups, $parent = false) { return $return; } + +function groups_get_all_hierarchy_group ($id_group, $hierarchy = array(), $debug = false) { + global $config; + + $hierarchy[] = $id_group; + $parent = db_get_value('parent','tgrupo','id_grupo',$id_group); + + if ($parent !== 0) { + $propagate = db_get_value('propagate','tgrupo','id_grupo',$parent); + + if ($propagate == 1) { + //$childrens_ids_parent = array($parent); + $hierarchy[] = $parent; + $childrens = groups_get_childrens($parent); + if (!empty($childrens)) { + foreach ($childrens as $child) { + //$childrens_ids_parent[] = (int)$child['id_grupo']; + $hierarchy[] = (int)$child['id_grupo']; + } + } + + $hierarchy = groups_get_all_hierarchy_group ($parent, $hierarchy); + } + } + return $hierarchy; +} ?> diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index c09f94b4a2..3593c4eb46 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -1229,17 +1229,20 @@ function tags_checks_event_acl($id_user, $id_group, $access, $tags = array(), $c if($id_user === false) { $id_user = $config['id_user']; } - + $tags_user = tags_get_acl_tags($id_user, $id_group, $access, 'data', '', '', false, $childrens_ids); // If there are wrong parameters or fail ACL check, return false if($tags_user === ERR_WRONG_PARAMETERS || $tags_user === ERR_ACL) { - return false; + //return false; + $return = false; } // If there are not tags restrictions or tags passed, return true - if(empty($tags_user) || empty($tags)) { + //if(empty($tags_user) || empty($tags)) { + if(empty($tags_user)) { return true; + //$return = true; } $tags_user_ids = array(); @@ -1252,9 +1255,38 @@ function tags_checks_event_acl($id_user, $id_group, $access, $tags = array(), $c $tag_id = tags_get_id($tag); if (in_array($tag_id, $tags_user_ids)) { //check tag return true; + //$return = true; } } } + //return false; + $return = false; + + if ($return == false) { + + $parent = db_get_value('parent','tgrupo','id_grupo',$id_group); + + if ($parent !== 0) { + $propagate = db_get_value('propagate','tgrupo','id_grupo',$parent); + + if ($propagate == 1) { + + $childrens_ids_parent = array($parent); + + $childrens = groups_get_childrens($parent); + + if (!empty($childrens)) { + foreach ($childrens as $child) { + $childrens_ids_parent[] = (int)$child['id_grupo']; + } + } + //$acl_parent = tags_check_acl_event($id_user, $parent, $access, $tags,$p); + $acl_parent = tags_checks_event_acl($id_user, $parent, $access, $tags, $childrens_ids_parent); + return $acl_parent; + } + } + } + return false; } ?> diff --git a/pandora_console/operation/events/events.build_query.php b/pandora_console/operation/events/events.build_query.php index 386b9d7f31..21242cd366 100755 --- a/pandora_console/operation/events/events.build_query.php +++ b/pandora_console/operation/events/events.build_query.php @@ -202,7 +202,13 @@ else { $group_array = array_keys($groups); } -$tags_acls_condition = tags_get_acl_tags($id_user, $group_array, 'ER', 'event_condition', 'AND', '', $meta); +//$tags_acls_condition = tags_get_acl_tags($id_user, $group_array, 'ER', 'event_condition', 'AND', '', $meta); +if ($id_group == 0) { + $hierarchy = array_keys($groups); +} else { + $hierarchy = groups_get_all_hierarchy_group ($id_group, array(), true); +} +$tags_acls_condition = tags_get_acl_tags($id_user, $group_array, 'ER', 'event_condition', 'AND', '', $meta, $hierarchy, true); if (($tags_acls_condition != ERR_WRONG_PARAMETERS) && ($tags_acls_condition != ERR_ACL)&& ($tags_acls_condition != -110000)) { $sql_post .= $tags_acls_condition;