#11612 Fix template

This commit is contained in:
miguel angel rasteu 2023-06-19 12:28:57 +02:00
parent ad45202484
commit ceb0ec9f16

View File

@ -322,6 +322,13 @@ function update_template($step)
if ($step == 1) { if ($step == 1) {
$name = (string) get_parameter('name'); $name = (string) get_parameter('name');
$name = trim(io_safe_output($name));
if (strlen($name) === 0) {
ui_print_warning_message(__('You can\'t named a template with spaces'));
return false;
}
$name = io_safe_input($name);
$description = (string) get_parameter('description'); $description = (string) get_parameter('description');
$wizard_level = (string) get_parameter('wizard_level'); $wizard_level = (string) get_parameter('wizard_level');
$priority = (int) get_parameter('priority'); $priority = (int) get_parameter('priority');
@ -487,6 +494,13 @@ $wizard_level = 'nowizard';
if ($create_template) { if ($create_template) {
$name = (string) get_parameter('name'); $name = (string) get_parameter('name');
$name = trim(io_safe_output($name));
if (strlen($name) === 0) {
ui_print_warning_message(__('You can\'t named a template with spaces'));
}
$name = io_safe_input($name);
$description = (string) get_parameter('description'); $description = (string) get_parameter('description');
$type = (string) get_parameter('type', 'critical'); $type = (string) get_parameter('type', 'critical');
$value = (string) get_parameter('value'); $value = (string) get_parameter('value');
@ -515,10 +529,11 @@ if ($create_template) {
$values['field3_recovery'] = ' '; $values['field3_recovery'] = ' ';
} }
if (!$name_check) { if ($name_check === false) {
$result = alerts_create_alert_template($name, $type, $values); $result = alerts_create_alert_template($name, $type, $values);
} else { } else {
$result = ''; ui_print_warning_message(__('Another template with the same name already exists'));
$result = false;
} }
if ($result) { if ($result) {