[Tags performance] Fixed select_modules_for_agent_group function (failed with several secondary groups).

This commit is contained in:
Fermin 2018-10-08 12:33:40 +02:00
parent a72b9b0515
commit d2b8939804
1 changed files with 20 additions and 17 deletions

View File

@ -2473,7 +2473,7 @@ function select_modules_for_agent_group(
$id_group, $id_agents, $selection, $return = true
) {
global $config;
$agents = implode(",", $id_agents);
$agents = (empty($id_agents)) ? array() : implode(",", $id_agents);
$filter_agent_group = "";
$filter_group = "";
@ -2499,7 +2499,7 @@ function select_modules_for_agent_group(
}
if (!$selection && $agents != null) {
$number_agents = count($id_agents);
$selection_filter = "HAVING COUNT(tagente_modulo.id_agente_modulo) = $number_agents";
$selection_filter = "HAVING COUNT(id_agente_modulo) = $number_agents";
}
if (tags_has_user_acl_tags(false)){
@ -2511,7 +2511,9 @@ function select_modules_for_agent_group(
ON ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo";
}
$sql = "SELECT DISTINCT(tagente_modulo.id_agente_modulo), tagente_modulo.nombre
$sql = "SELECT * FROM
(
SELECT DISTINCT(tagente_modulo.id_agente_modulo), tagente_modulo.nombre
FROM tagente_modulo
$sql_tags_inner
INNER JOIN tagente
@ -2524,7 +2526,8 @@ function select_modules_for_agent_group(
$filter_group
$filter_agent
$sql_conditions_tags
GROUP BY tagente_modulo.nombre
) x
GROUP BY nombre
$selection_filter";
$modules = db_get_all_rows_sql($sql);