diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 689afd3a38..c1671a6f98 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2011-09-16 Juan Manuel Ramon + + * include/functions_agents.php: Avoid bad syntax sql query + in agents_get_modules_data_count() function when an agent doesn't + have modules. + 2011-09-16 Juan Manuel Ramon * include/help/en/help_export_server.php diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 8d5eb0a204..68fc86adc6 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1191,14 +1191,16 @@ function agents_get_modules_data_count ($id_agent = 0) { $count["total"] = 0; $query[0] = "SELECT COUNT(*) FROM tagente_datos"; - + foreach ($id_agent as $agent_id) { //Init value $count[$agent_id] = 0; - $modules = array_keys (agents_get_modules ($agent_id)); - foreach ($query as $sql) { + $modules = array_keys (agents_get_modules ($agent_id)); + foreach ($query as $sql) { //Add up each table's data - $count[$agent_id] += (int) db_get_sql ($sql." WHERE id_agente_modulo IN (".implode (",", $modules).")", 0, true); + //Avoid the count over empty array + if (!empty($modules)) + $count[$agent_id] += (int) db_get_sql ($sql." WHERE id_agente_modulo IN (".implode (",", $modules).")", 0, true); } //Add total agent count to total count $count["total"] += $count[$agent_id];