From 053d0298a156af72649474deb661b6a0012defce Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Wed, 20 Jan 2016 12:47:26 +0100 Subject: [PATCH] Fixed search in alert templates, when DB is Oracle. Tiquet: #3231 --- pandora_console/include/functions_alerts.php | 41 +++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 74c920e327..beb5e5816c 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -649,7 +649,46 @@ 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) { - return @db_get_all_rows_filter ('talert_templates', $filter, $fields); + global $config; + + if (isset($filter['offset'])) { + $offset = $filter['offset']; + unset($filter['offset']); + } + + if (isset($filter['limit'])) { + $limit = $filter['limit']; + unset($filter['limit']); + } + + $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 = array(); + if (isset($offset) && isset($limit)) { + $set['limit'] = $limit; + $set['offset'] = $offset; + } + + $alert_templates = oracle_recode_query ($templates_sql, $set, 'AND', false); + break; + } + return $alert_templates; } /**