diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 3bb874fc6e..4984feaa9a 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2012-06-12 Dario Rodriguez + + * operation/tree.php: Fixed some errors with tree view + for policies. + + MERGED FROM 4.0.2 + 2012-06-12 Juan Manuel Ramon * include/functions_forecast.php diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index 1caca4b38a..3e6c6db402 100644 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -275,13 +275,28 @@ if (is_ajax ()) AND ((%s id_grupo IN (%s)))', $id, $extra_sql, $groups_sql); break; case 'policies': - if ($id == 0) - $queryWhere = 'id_agente NOT IN (SELECT id_agent FROM tpolicy_agents)'; - else - $queryWhere = sprintf(' id_agente IN (SELECT id_agent FROM tpolicy_agents WHERE id_policy = %s)',$id); + + $sql = ""; - $sql = sprintf('SELECT * FROM tagente - WHERE %s AND ( %s id_grupo IN (%s))', $queryWhere, $extra_sql, $groups_sql); + if ($id == 0) { + $queryWhere = 'id_agente NOT IN (SELECT id_agent FROM tpolicy_agents)'; + + $sql = sprintf('SELECT DISTINCT tagente.id_agente as id_agente, tagente.nombre as nombre FROM tagente, tagente_modulo, tagente_estado WHERE + tagente_estado.id_agente = tagente.id_agente AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND + tagente_modulo.id_policy_module = 0 AND tagente_estado.utimestamp != 0 AND + tagente.id_agente IN (SELECT id_agente FROM tagente WHERE %s AND ( %s id_grupo IN (%s)))', + $queryWhere, $extra_sql, $groups_sql); + + } else { + $queryWhere = sprintf('id_agente IN (SELECT id_agent FROM tpolicy_agents WHERE id_policy = %s)',$id); + + $sql = sprintf('SELECT DISTINCT tagente.id_agente as id_agente, tagente.nombre as nombre FROM tagente, tagente_modulo, tagente_estado, tpolicy_modules WHERE + tagente_estado.id_agente = tagente.id_agente AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tpolicy_modules.id = tagente_modulo.id_policy_module AND + tpolicy_modules.id_policy = %s AND tagente_modulo.id_policy_module != 0 AND tagente_estado.utimestamp != 0 AND + tagente.id_agente IN (SELECT id_agente FROM tagente WHERE %s AND ( %s id_grupo IN (%s)))', + $id, $queryWhere, $extra_sql, $groups_sql); + } + break; case 'module': //Replace separator token "articapandora_32_pandoraartica_" for " " @@ -304,9 +319,10 @@ if (is_ajax ()) break; } - $sql .= ' AND disabled = 0'. $search_sql; - + $sql .= ' AND tagente.disabled = 0'. $search_sql; + $countRows = db_get_num_rows($sql); + } if ($countRows === 0) { echo "