Fixed the functions "tags_get_user_module_and_tags" and "tags_get_all_user_agents"
This commit is contained in:
parent
7357216155
commit
6d59a78fc9
|
@ -1729,36 +1729,39 @@ function tags_get_user_module_and_tags ($id_user = false, $access = 'AR', $stric
|
||||||
|
|
||||||
$acl_column = get_acl_column($access);
|
$acl_column = get_acl_column($access);
|
||||||
|
|
||||||
$query = sprintf("SELECT tags, id_grupo
|
$sql = sprintf("SELECT tags, id_grupo
|
||||||
FROM tusuario_perfil, tperfil
|
FROM tusuario_perfil, tperfil
|
||||||
WHERE tperfil.id_perfil = tusuario_perfil.id_perfil AND
|
WHERE tperfil.id_perfil = tusuario_perfil.id_perfil AND
|
||||||
tusuario_perfil.id_usuario = '%s' AND
|
tusuario_perfil.id_usuario = '%s' AND
|
||||||
tperfil.%s = 1
|
tperfil.%s = 1
|
||||||
ORDER BY id_grupo", $id_user, $acl_column);
|
ORDER BY id_grupo", $id_user, $acl_column);
|
||||||
$tags_and_groups = db_get_all_rows_sql($query);
|
$tags_and_groups = db_get_all_rows_sql($sql);
|
||||||
|
|
||||||
if ($tags_and_groups == false) {
|
if ($tags_and_groups === false)
|
||||||
$tags_and_groups = array();
|
$tags_and_groups = array();
|
||||||
}
|
|
||||||
|
|
||||||
$acltags = array();
|
$acltags = array();
|
||||||
|
|
||||||
if ((count($tags_and_groups) == 1) && ($tags_and_groups[0]['id_grupo'] == 0) && ($tags_and_groups[0]['tags'] == '')){ //user with all groups without tags
|
// Change the 'All' group with all groups
|
||||||
$all_groups = groups_get_all();
|
$all_group_ids = array();
|
||||||
|
$all_groups = groups_get_all();
|
||||||
|
if (!empty($all_groups))
|
||||||
|
$all_group_ids = array_keys($all_groups);
|
||||||
|
|
||||||
foreach ($all_groups as $id => $name) {
|
$tags_and_groups_aux = array();
|
||||||
$acltags[$id] = '';
|
foreach ($tags_and_groups as $data) {
|
||||||
}
|
// All group
|
||||||
} else {
|
if ($data['id_grupo'] == 0) {
|
||||||
// Change the 'All' group with all groups
|
// All group with empty tags. All groups without tags permission!
|
||||||
$all_group_ids = array();
|
if (empty($data['tags'])) {
|
||||||
$all_groups = groups_get_all();
|
foreach ($all_group_ids as $group_id) {
|
||||||
if (!empty($all_groups))
|
$acltags[$group_id] = '';
|
||||||
$all_group_ids = array_keys($all_groups);
|
}
|
||||||
|
|
||||||
$tags_and_groups_aux = array();
|
return $acltags; // End of the function
|
||||||
foreach ($tags_and_groups as $data) {
|
}
|
||||||
if ($data['id_grupo'] == 0) {
|
// Create a new element for every group with the tags
|
||||||
|
else {
|
||||||
foreach ($all_group_ids as $group_id) {
|
foreach ($all_group_ids as $group_id) {
|
||||||
$tags_and_groups_aux[] = array(
|
$tags_and_groups_aux[] = array(
|
||||||
'id_grupo' => $group_id,
|
'id_grupo' => $group_id,
|
||||||
|
@ -1766,29 +1769,62 @@ function tags_get_user_module_and_tags ($id_user = false, $access = 'AR', $stric
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$tags_and_groups_aux[] = $data;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$tags_and_groups = $tags_and_groups_aux;
|
// Specific group
|
||||||
unset($tags_and_groups_aux);
|
else {
|
||||||
|
$tags_and_groups_aux[] = $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$tags_and_groups = $tags_and_groups_aux;
|
||||||
|
unset($tags_and_groups_aux);
|
||||||
|
|
||||||
foreach ($tags_and_groups as $group_tag) {
|
function __add_acltags (&$acltags, $group_id, $tags_str) {
|
||||||
$acltags[$group_tag['id_grupo']] = $group_tag['tags'];
|
if (!isset($acltags[$group_id])) {
|
||||||
$propagate = db_get_value('propagate', 'tgrupo', 'id_grupo', $group_tag['id_grupo']);
|
// Add the new element
|
||||||
|
$acltags[$group_id] = $tags_str;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Add the tags. The empty tags have priority cause mean more permissions
|
||||||
|
$existing_tags = $acltags[$group_id];
|
||||||
|
|
||||||
if ($propagate) {
|
if (!empty($existing_tags)) {
|
||||||
$sql = "SELECT id_grupo FROM tgrupo WHERE parent = " .$group_tag['id_grupo'];
|
$existing_tags_array = explode(",", $existing_tags);
|
||||||
$children = db_get_all_rows_sql($sql);
|
|
||||||
|
|
||||||
if ($children == false) {
|
// Store the empty tags
|
||||||
$children = array();
|
if (empty($tags_str)) {
|
||||||
|
$acltags[$group_id] = '';
|
||||||
}
|
}
|
||||||
foreach ($children as $group) {
|
// Merge the old and new tabs
|
||||||
$acltags[$group['id_grupo']] = $group_tag['tags'];
|
else {
|
||||||
|
$new_tags_array = explode(",", $tags_str);
|
||||||
|
|
||||||
|
$final_tags_array = array_merge($existing_tags_array, $new_tags_array);
|
||||||
|
$final_tags_str = implode(",", $final_tags_array);
|
||||||
|
|
||||||
|
if (! empty($final_tags_str))
|
||||||
|
$acltags[$group_id] = $final_tags_str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Propagation
|
||||||
|
$propagate = (bool) db_get_value('propagate', 'tgrupo', 'id_grupo', $group_tag['id_grupo']);
|
||||||
|
if ($propagate) {
|
||||||
|
$sql = "SELECT id_grupo FROM tgrupo WHERE parent = $group_id";
|
||||||
|
$children = db_get_all_rows_sql($sql);
|
||||||
|
|
||||||
|
if ($children === false)
|
||||||
|
$children = array();
|
||||||
|
|
||||||
|
foreach ($children as $children_group) {
|
||||||
|
// Add the tags to the children (recursive)
|
||||||
|
__add_acltags($acltags, $children_group['id_grupo'], $tags_str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($tags_and_groups as $group_tag) {
|
||||||
|
__add_acltags($acltags, $group_tag['id_grupo'], $group_tag['tags']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $acltags;
|
return $acltags;
|
||||||
|
@ -1848,7 +1884,7 @@ function tags_get_all_user_agents ($id_tag = false, $id_user = false, $groups_an
|
||||||
if (empty($id_tag)) {
|
if (empty($id_tag)) {
|
||||||
$tag_filter = '';
|
$tag_filter = '';
|
||||||
} else {
|
} else {
|
||||||
$tag_filter = " AND ttag_module.id_tag = " . $id_tag;
|
$tag_filter = " AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag = $id_tag) ";
|
||||||
}
|
}
|
||||||
if (empty($id_user)) {
|
if (empty($id_user)) {
|
||||||
$id_user = $config['id_user'];
|
$id_user = $config['id_user'];
|
||||||
|
@ -1960,9 +1996,8 @@ function tags_get_all_user_agents ($id_tag = false, $id_user = false, $groups_an
|
||||||
}
|
}
|
||||||
|
|
||||||
$user_agents_sql = "SELECT ".$select_fields ."
|
$user_agents_sql = "SELECT ".$select_fields ."
|
||||||
FROM tagente, tagente_modulo, ttag_module
|
FROM tagente, tagente_modulo
|
||||||
WHERE tagente.id_agente = tagente_modulo.id_agente
|
WHERE tagente.id_agente = tagente_modulo.id_agente
|
||||||
AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo
|
|
||||||
". $tag_filter .
|
". $tag_filter .
|
||||||
$groups_clause . $search_sql . $void_agents .
|
$groups_clause . $search_sql . $void_agents .
|
||||||
$status_sql .
|
$status_sql .
|
||||||
|
|
Loading…
Reference in New Issue