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 { } else {
$sql = ''; $sql = '';
if ($type_execution === 'cron') {
$error_cron_from = false; $error_cron_from = false;
$error_cron_to = false; $error_cron_to = false;
$error_field = ''; $error_field = '';
if ($type_execution === 'cron') {
// Validate 'from' cron values. // Validate 'from' cron values.
$hour_from = io_safe_output(trim($hour_from)); $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) { 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_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); $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; 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 (trim(io_safe_output($name)) != '') {
if (!$check) { if (!$check) {
$values = [ $values = [
@ -537,6 +535,7 @@ if ($create_downtime || $update_downtime) {
__('Scheduled downtime must have a name') __('Scheduled downtime must have a name')
); );
} }
}
} else if ($update_downtime) { } else if ($update_downtime) {
$old_downtime = db_get_row('tplanned_downtime', 'id', $id_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) { if ($is_running) {
$result = false; $result = false;
} else { } else {
@ -621,6 +635,7 @@ if ($create_downtime || $update_downtime) {
} }
} }
} }
}
if ($result === false) { if ($result === false) {
if ($create_downtime) { if ($create_downtime) {