mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 09:15:15 +02:00
Fixed problems with tags in tree view, tiquet: 2260
This commit is contained in:
parent
660e6d98a6
commit
0e013e2bcc
@ -669,88 +669,43 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR',
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((string)$id_group === "0") {
|
if ($id_group == 0) {
|
||||||
$id_group = array_keys(users_get_groups($id_user, $access, false));
|
// Don't filter
|
||||||
|
$id_group = array();
|
||||||
if (empty($id_group)) {
|
|
||||||
return ERR_WRONG_PARAMETERS;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
elseif (empty($id_group)) {
|
elseif (empty($id_group)) {
|
||||||
return ERR_WRONG_PARAMETERS;
|
return ERR_WRONG_PARAMETERS;
|
||||||
}
|
}
|
||||||
elseif (!is_array($id_group)) {
|
elseif (!is_array($id_group)) {
|
||||||
$id_group = (array) $id_group;
|
$id_group = array($id_group);
|
||||||
}
|
|
||||||
|
|
||||||
if ($id_group[0] != 0) {
|
|
||||||
$id_group = groups_get_all_hierarchy_group ($id_group[0]);
|
|
||||||
}
|
}
|
||||||
|
$groups = $id_group;
|
||||||
|
|
||||||
$acl_column = get_acl_column($access);
|
$acl_column = get_acl_column($access);
|
||||||
|
|
||||||
if (empty($acl_column)) {
|
if (empty($acl_column)) {
|
||||||
return ERR_WRONG_PARAMETERS;
|
return ERR_WRONG_PARAMETERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tags = tags_get_user_module_and_tags($id_user, $access);
|
$acltags = tags_get_user_module_and_tags($id_user, $access);
|
||||||
|
|
||||||
// If not profiles returned, the user havent acl permissions
|
|
||||||
if (empty($tags)) {
|
|
||||||
return ERR_ACL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Array to store groups where there arent tags restriction
|
// Delete the groups without tag restrictions from the acl tags array if $force_group_and_tag == false
|
||||||
$non_restriction_groups = array();
|
// Delete the groups that aren't in the received groups id
|
||||||
|
$acltags_aux = array();
|
||||||
$acltags = array();
|
foreach ($acltags as $group_id => $tags) {
|
||||||
foreach ($tags as $tagsone) {
|
if (!empty($groups) && array_search($group_id, $groups) === false) {
|
||||||
if ($force_group_and_tag) {
|
unset($acltags[$group_id]);
|
||||||
if (empty($tagsone['tags'])) {
|
|
||||||
// Do none
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (empty($tagsone['tags'])) {
|
if (!empty($tags))
|
||||||
// If there arent tags restriction in all groups (group 0), return no condition
|
$tags = explode(",", $tags);
|
||||||
if ($tagsone['id_grupo'] == 0) {
|
$acltags_aux[$group_id] = $tags;
|
||||||
switch ($return_mode) {
|
|
||||||
case 'data':
|
|
||||||
return array();
|
|
||||||
break;
|
|
||||||
case 'event_condition':
|
|
||||||
case 'module_condition':
|
|
||||||
return "";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$non_restriction_groups[] = $tagsone['id_grupo'];
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$tags_array = explode(',',$tagsone['tags']);
|
|
||||||
if ($force_group_and_tag) {
|
|
||||||
if (empty($tagsone['tags'])) {
|
|
||||||
$tags_array = array();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($acltags[$tagsone['id_grupo']])) {
|
|
||||||
$acltags[$tagsone['id_grupo']] = $tags_array;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$acltags[$tagsone['id_grupo']] = array_unique(array_merge($acltags[$tagsone['id_grupo']], $tags_array));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete the groups without tag restrictions from the acl tags array
|
|
||||||
foreach ($non_restriction_groups as $nrgroup) {
|
|
||||||
if (isset($acltags[$nrgroup])) {
|
|
||||||
unset($acltags[$nrgroup]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Clean the possible empty elements
|
||||||
|
if (!$force_group_and_tag)
|
||||||
|
$acltags_aux = array_filter($acltags_aux);
|
||||||
|
$acltags = $acltags_aux;
|
||||||
|
|
||||||
switch ($return_mode) {
|
switch ($return_mode) {
|
||||||
case 'data':
|
case 'data':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user