minor fix

This commit is contained in:
alejandro.campos@artica.es 2022-08-17 13:31:12 +02:00
parent ded2fb08ff
commit 9f28e6f7fb
1 changed files with 84 additions and 69 deletions

View File

@ -275,12 +275,11 @@ if ($create_downtime || $update_downtime) {
);
} else {
$sql = '';
if ($type_execution === 'cron') {
$error_cron_from = false;
$error_cron_to = false;
$error_field = '';
if ($type_execution === 'cron') {
// Validate 'from' cron values.
$hour_from = io_safe_output(trim($hour_from));
if (preg_match('/^((?:([0-1]?[0-9]|2[0-3])|\*)\s*(?:(?:[\/-]([0-1]?[0-9]|2[0-3])))?\s*)$/', $hour_from, $matches) !== 1) {
@ -451,22 +450,6 @@ if ($create_downtime || $update_downtime) {
}
}
if ($error_cron_from === true) {
ui_print_error_message(
__('Downtime start cron expression is not correct').': '.$error_field
);
}
if ($error_cron_to === true) {
ui_print_error_message(
__('Downtime stop cron expression is not correct').': '.$error_field
);
}
if ($error_cron_to === true || $error_cron_from) {
return;
}
$cron_interval_from = io_safe_output($minute_from.' '.$hour_from.' '.$mday_from.' '.$month_from.' '.$wday_from);
$cron_interval_to = io_safe_output($minute_to.' '.$hour_to.' '.$mday_to.' '.$month_to.' '.$wday_to);
}
@ -490,6 +473,21 @@ if ($create_downtime || $update_downtime) {
return;
}
if ($error_cron_to === true || $error_cron_from === true) {
if ($error_cron_from === true) {
ui_print_error_message(
__('Downtime start cron expression is not correct').': '.$error_field
);
}
if ($error_cron_to === true) {
ui_print_error_message(
__('Downtime stop cron expression is not correct').': '.$error_field
);
}
$result = false;
} else {
if (trim(io_safe_output($name)) != '') {
if (!$check) {
$values = [
@ -537,6 +535,7 @@ if ($create_downtime || $update_downtime) {
__('Scheduled downtime must have a name')
);
}
}
} else if ($update_downtime) {
$old_downtime = db_get_row('tplanned_downtime', 'id', $id_downtime);
@ -609,6 +608,21 @@ if ($create_downtime || $update_downtime) {
}
}
if ($error_cron_to === true || $error_cron_from === true) {
if ($error_cron_from === true) {
ui_print_error_message(
__('Downtime start cron expression is not correct').': '.$error_field
);
}
if ($error_cron_to === true) {
ui_print_error_message(
__('Downtime stop cron expression is not correct').': '.$error_field
);
}
$result = false;
} else {
if ($is_running) {
$result = false;
} else {
@ -621,6 +635,7 @@ if ($create_downtime || $update_downtime) {
}
}
}
}
if ($result === false) {
if ($create_downtime) {