From e5ec0cb35aa58f231d4c1ede36404d058c02176d Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Tue, 7 Mar 2017 16:30:40 +0100 Subject: [PATCH] Kill pink unicorns --- .../godmode/agentes/configurar_agente.php | 1 - pandora_console/include/functions_agents.php | 4 +- .../operation/agentes/ver_agente.php | 54 +++++++++---------- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 2ed4073fa4..bc09729e15 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -196,7 +196,6 @@ if ($create_agent) { if($alias_as_name){ $sql = 'SELECT nombre FROM tagente WHERE nombre = "' . $alias . '"'; $exists_alias = db_get_row_sql($sql); - html_debug_print($exists_alias, true); $nombre_agente = $alias; } diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 67ea583eec..c32c44d859 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -2524,7 +2524,9 @@ function agents_get_agent_custom_field ($agent_id, $custom_field_name) { return db_get_value_sql($sql); } -function select_modules_for_agent_group($id_group, $id_agents, $selection, $return=true){ +function select_modules_for_agent_group($id_group, $id_agents, + $selection, $return = true) { + $agents = implode(",", $id_agents); $filter_group = ""; diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 1114e2699f..024f54f922 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -490,35 +490,33 @@ if (is_ajax ()) { asort($result); } else { - - if(implode(',', $idAgents) < 0){ - - - $sql = 'SELECT DISTINCT(nombre) FROM tagente_modulo -WHERE nombre IN ( -SELECT nombre -FROM tagente_modulo -GROUP BY nombre -HAVING count(nombre) = (SELECT count(nombre) FROM tagente_modulo))'; - } - else{ - $sql = 'SELECT DISTINCT(nombre) - FROM tagente_modulo t1 - WHERE ' . $filter . ' - AND t1.delete_pending = 0 - AND t1.id_agente IN (' . implode(',', $idAgents) . ')'; - - if ($selection_mode == 'common') { - $sql .= ' AND ( - SELECT count(nombre) - FROM tagente_modulo t2 - WHERE t2.delete_pending = 0 - AND t1.nombre = t2.nombre - AND t2.id_agente IN (' . implode(',', $idAgents) . ')) = (' . count($idAgents) . ')'; - }elseif ($selection_mode == 'unknown'){ - $sql .= 'AND t1.id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_estado where estado = 3 OR estado = 4)'; + if(implode(',', $idAgents) < 0) { + $sql = 'SELECT DISTINCT(nombre) FROM tagente_modulo + WHERE nombre IN ( + SELECT nombre + FROM tagente_modulo + GROUP BY nombre + HAVING count(nombre) = (SELECT count(nombre) FROM tagente_modulo))'; + } + else { + $sql = 'SELECT DISTINCT(nombre) + FROM tagente_modulo t1 + WHERE ' . $filter . ' + AND t1.delete_pending = 0 + AND t1.id_agente IN (' . implode(',', $idAgents) . ')'; + + if ($selection_mode == 'common') { + $sql .= ' AND ( + SELECT count(nombre) + FROM tagente_modulo t2 + WHERE t2.delete_pending = 0 + AND t1.nombre = t2.nombre + AND t2.id_agente IN (' . implode(',', $idAgents) . ')) = (' . count($idAgents) . ')'; + } + elseif ($selection_mode == 'unknown') { + $sql .= 'AND t1.id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_estado where estado = 3 OR estado = 4)'; + } } - } $sql .= ' ORDER BY nombre'; $nameModules = db_get_all_rows_sql($sql);