From cb6b8531dfb5c1f5ed16f47de923afc9a7b01b18 Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Tue, 23 Apr 2019 16:23:32 +0200 Subject: [PATCH] Visual Console Refactor: minor fix Former-commit-id: c055042c1cf3b4181a146857f159d656b9c5ed3f --- .../models/VisualConsole/Items/Group.php | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php b/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php index b06a145cf7..da1c5a4d48 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php @@ -226,20 +226,30 @@ final class Group extends Item ); } else { if (\is_metaconsole()) { + $groupFilter = $groupId; if ($groupId === 0) { - $groupId = \implode(',', \array_keys(\users_get_groups())); + $groupFilter = implode( + ',', + array_keys(\users_get_groups()) + ); } - $sql = 'SELECT SUM(fired_count) AS fired, - SUM(critical_count) AS critical, - SUM(warning_count) AS warning, - SUM(unknown_count) AS unknown + $sql = sprintf( + 'SELECT + SUM(fired_count) AS fired, + SUM(critical_count) AS critical, + SUM(warning_count) AS warning, + SUM(unknown_count) AS unknown FROM tmetaconsole_agent LEFT JOIN tmetaconsole_agent_secondary_group tasg - ON id_agente = tasg.id_agent - WHERE id_grupo IN ('.$groupId.') OR tasg.id_group IN ('.$groupId.')'; + ON id_agente = tasg.id_agent + WHERE id_grupo IN (%s) + OR tasg.id_group IN (%s)', + $groupFilter, + $groupFilter + ); - $countStatus = db_get_row_sql($sql); + $countStatus = \db_get_row_sql($sql); if ($countStatus['fired'] > 0) { $status = AGENT_STATUS_ALERT_FIRED;