From ec7c645d1b23c45b0c6ae2240b726bded4091e6a Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 9 Oct 2018 11:45:55 +0200 Subject: [PATCH] [Tags performance] Fixed problems when there is not using secondary groups --- pandora_console/include/functions_tags.php | 63 +--------------------- 1 file changed, 1 insertion(+), 62 deletions(-) diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index 0bdf707646..da783465c7 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -734,7 +734,7 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') { if($has_secondary){ $agent_condition = sprintf('((tagente.id_grupo = %d OR tasg.id_group = %d) %s)',$group_id,$group_id,$tag_join); } else { - $agent_condition = sprintf('((tagente.id_grupo = %d %s)',$group_id,$tag_join); + $agent_condition = sprintf('((tagente.id_grupo = %d %s))',$group_id,$tag_join); } $group_conditions[] = $agent_condition; } else { @@ -757,67 +757,6 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') { return $condition; } -// The old function will be keeped to serve as reference of the changes done -/** - * Transform the acl_groups data into a SQL condition - * - * @param mixed acl_groups data calculated in tags_get_acl_tags function - * - * @return string SQL condition for tagente_module - */ -function tags_get_acl_tags_module_condition_old($acltags, $modules_table = '') { - if (!empty($modules_table)) - $modules_table .= '.'; - - $condition = ''; - $group_conditions = array(); - - // The acltags array contains the groups with the acl propagation applied - // after the changes done into the 'tags_get_user_groups_and_tags' function. - foreach ($acltags as $group_id => $group_tags) { - $tag_join = ''; - if (!empty($group_tags)) { - $tag_join = sprintf('INNER JOIN ttag_module ttmc - ON tamc.id_agente_modulo = ttmc.id_agente_modulo - AND ttmc.id_tag IN (%s)', - is_array($group_tags) ? implode(',', $group_tags) : $group_tags); - } - // FIXME: Not properly way to increse performance - if(enterprise_hook('agents_is_using_secondary_groups')){ - $agent_condition = sprintf('SELECT tamc.id_agente_modulo - FROM tagente_modulo tamc - %s - INNER JOIN tagente tac - ON tamc.id_agente = tac.id_agente - LEFT JOIN tagent_secondary_group tasg - ON tasg.id_agent = tac.id_agente - WHERE (tac.id_grupo = %d OR tasg.id_group = %d)', - $tag_join, $group_id, $group_id); - } - else{ - $agent_condition = sprintf('SELECT tamc.id_agente_modulo - FROM tagente_modulo tamc - %s - INNER JOIN tagente tac - ON tamc.id_agente = tac.id_agente - AND tac.id_grupo = %d', - $tag_join, $group_id); - } - - $sql_condition = sprintf('(%sid_agente_modulo IN (%s))', $modules_table, $agent_condition); - - $group_conditions[] = $sql_condition; - - $i++; - } - - if (!empty($group_conditions)) - $condition = implode(' OR ', $group_conditions); - $condition = !empty($condition) ? "($condition)" : ''; - - return $condition; -} - /** * Transform the acl_groups data into a SQL condition *