From 904b50580319b68cc431f3039549a34527c28c69 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 16 Jan 2023 16:31:13 +0100 Subject: [PATCH] #9473 total_modules all and id --- pandora_console/include/functions_api.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index d141160f9b..e0961cb238 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -12471,9 +12471,26 @@ function api_get_total_modules($id_group, $trash1, $trash2, $returnType) return; } - $partial = tactical_status_modules_agents($config['id_user'], false, 'AR'); + if ($id_group) { + $groups_clause = '1 = 1'; + if (!users_is_admin($config['id_user'])) { + $user_groups = implode(',', array_keys(users_get_groups())); + $groups_clause = "(ta.id_grupo IN ($user_groups) OR tasg.id_group IN ($user_groups))"; + } - $total = (int) $partial['_monitor_total_']; + $sql = "SELECT COUNT(DISTINCT(id_agente_modulo)) + FROM tagente_modulo tam, tagente ta + LEFT JOIN tagent_secondary_group tasg + ON ta.id_agente = tasg.id_agent + WHERE tam.id_agente = ta.id_agente AND id_module_group = $id_group + AND delete_pending = 0 AND $groups_clause"; + + $total = db_get_value_sql($sql); + } else { + $partial = tactical_status_modules_agents($config['id_user'], false, 'AR'); + + $total = (int) $partial['_monitor_total_']; + } $data = [ 'type' => 'string',