From a13c2a24a9d5e9671023ba2453f64d0d8d076025 Mon Sep 17 00:00:00 2001 From: "edu.corral" Date: Wed, 21 Sep 2022 09:46:31 +0200 Subject: [PATCH] ent 9485 metaconsole alert filter --- .../godmode/alerts/alert_templates.php | 2 +- pandora_console/include/functions_alerts.php | 35 ++++++------------- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/pandora_console/godmode/alerts/alert_templates.php b/pandora_console/godmode/alerts/alert_templates.php index 17f281571c..c0374c210b 100644 --- a/pandora_console/godmode/alerts/alert_templates.php +++ b/pandora_console/godmode/alerts/alert_templates.php @@ -358,7 +358,7 @@ if (!is_user_admin($config['id_user'])) { $filter['id_group'] = array_keys(users_get_groups(false, 'LM')); } -$total_templates = alerts_get_alert_templates($filter, ['COUNT(*) AS total']); +$total_templates = alerts_get_alert_templates($filter, ['COUNT(*) AS total'], true); $total_templates = $total_templates[0]['total']; $templates = alerts_get_alert_templates( diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 4b5fec001e..a3b0bcb2fb 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -795,7 +795,7 @@ function alerts_delete_alert_template($id_alert_template) * * @return mixed Array with selected alert templates or false if something goes wrong. */ -function alerts_get_alert_templates($filter=false, $fields=false) +function alerts_get_alert_templates($filter=false, $fields=false, $total=false) { global $config; @@ -811,32 +811,17 @@ function alerts_get_alert_templates($filter=false, $fields=false) $templates_sql = @db_get_all_rows_filter('talert_templates', $filter, $fields, 'AND', false, true); - switch ($config['dbtype']) { - case 'mysql': - case 'postgresql': - $limit_sql = ''; - if (isset($offset) && isset($limit)) { - $limit_sql = " LIMIT $offset, $limit "; - } else { - $limit_sql = ''; - } - - $sql = sprintf('%s %s', $templates_sql, $limit_sql); - - $alert_templates = db_get_all_rows_sql($sql); - break; - - case 'oracle': - $set = []; - if (isset($offset) && isset($limit)) { - $set['limit'] = $limit; - $set['offset'] = $offset; - } - - $alert_templates = oracle_recode_query($templates_sql, $set, 'AND', false); - break; + $limit_sql = ''; + if (isset($offset) && isset($limit) && $total === false) { + $limit_sql = " LIMIT $offset, $limit "; + } else { + $limit_sql = ''; } + $sql = sprintf('%s %s', $templates_sql, $limit_sql); + + $alert_templates = db_get_all_rows_sql($sql); + return $alert_templates; }