Fixed several bugs in events.

This commit is contained in:
Vanessa Gil 2014-11-25 16:58:20 +01:00
parent a70fc62af0
commit af1b7c1f64
3 changed files with 68 additions and 4 deletions

View File

@ -1578,4 +1578,30 @@ function groups_get_tree(&$groups, $parent = false) {
return $return; 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;
}
?> ?>

View File

@ -1234,12 +1234,15 @@ function tags_checks_event_acl($id_user, $id_group, $access, $tags = array(), $c
// If there are wrong parameters or fail ACL check, return false // If there are wrong parameters or fail ACL check, return false
if($tags_user === ERR_WRONG_PARAMETERS || $tags_user === ERR_ACL) { 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 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;
//$return = true;
} }
$tags_user_ids = array(); $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); $tag_id = tags_get_id($tag);
if (in_array($tag_id, $tags_user_ids)) { //check tag if (in_array($tag_id, $tags_user_ids)) { //check tag
return true; 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; return false;
} }
?> ?>

View File

@ -202,7 +202,13 @@ else {
$group_array = array_keys($groups); $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)) { if (($tags_acls_condition != ERR_WRONG_PARAMETERS) && ($tags_acls_condition != ERR_ACL)&& ($tags_acls_condition != -110000)) {
$sql_post .= $tags_acls_condition; $sql_post .= $tags_acls_condition;