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; } /**