From f74507aa9f9bd329d6c407d40fd5d95ba3dbb7ab Mon Sep 17 00:00:00 2001 From: Marcin Haba Date: Sun, 8 Oct 2017 18:11:30 +0200 Subject: [PATCH] baculum: Fix reading and writing schedule resource --- .../protected/API/Class/BaculaSetting.php | 9 ++++++- .../Web/Portlets/DirectiveSchedule.php | 26 +++++++++++++++---- .../Web/Portlets/DirectiveSchedule.tpl | 10 ------- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/gui/baculum/protected/API/Class/BaculaSetting.php b/gui/baculum/protected/API/Class/BaculaSetting.php index c74cf58c37..48ccaa9798 100644 --- a/gui/baculum/protected/API/Class/BaculaSetting.php +++ b/gui/baculum/protected/API/Class/BaculaSetting.php @@ -232,7 +232,14 @@ class BaculaSetting extends APIModule { if (count($directive_value[$i]['Hour']) === 24) { $hourly = 'hourly'; } - $minute = sprintf('%02d', $directive_value[$i]['Minute']); + $minute = '00'; + /** + * Check if Minute key exists because of bug about missing Minute + * @see http://bugs.bacula.org/view.php?id=2318 + */ + if (array_key_exists('Minute', $directive_value[$i])) { + $minute = sprintf('%02d', $directive_value[$i]['Minute']); + } $day = count($directive_value[$i]['Day']) === 31 ? '' : 'on ' . implode(',', $directive_value[$i]['Day']); $month = Params::getMonthsConfig($directive_value[$i]['Month']); $week = Params::getWeeksConfig($directive_value[$i]['WeekOfMonth']); diff --git a/gui/baculum/protected/Web/Portlets/DirectiveSchedule.php b/gui/baculum/protected/Web/Portlets/DirectiveSchedule.php index 2c1be5558f..6d1d97a761 100644 --- a/gui/baculum/protected/Web/Portlets/DirectiveSchedule.php +++ b/gui/baculum/protected/Web/Portlets/DirectiveSchedule.php @@ -79,7 +79,6 @@ class DirectiveSchedule extends DirectiveListTemplate { 'WdayRangeTo', 'TimeHourAt', 'TimeMinAt', - 'TimeHourHourly', 'TimeMinHourly' ); @@ -274,13 +273,30 @@ class DirectiveSchedule extends DirectiveListTemplate { $minute = null; if ($load_values) { $hour = $directives->Hour[0]; // @TODO: Check for many hour values; - $minute = $directives->Minute; + /** + * Check if Minute property exists because of bug about missing Minute + * @see http://bugs.bacula.org/view.php?id=2318 + */ + $minute = property_exists($directives, 'Minute') ? $directives->Minute : 0; } $this->directives['time'] = array( 'hour' => $hour, 'minute' => $minute ); - $this->TimeAt->Checked = true; + if ($load_values) { + if (count($directives->Hour) == 24) { + $this->TimeHourly->Checked = true; + $this->TimeMinHourly->setDirectiveValue($minute); + } elseif (count($directives->Hour) == 1) { + $this->TimeAt->Checked = true; + $this->TimeHourAt->setDirectiveValue($hour); + $this->TimeMinAt->setDirectiveValue($minute); + } else { + $this->TimeDisable->Checked = true; + } + } else { + $this->TimeDisable->Checked = true; + } } public function getDirectiveValue() { @@ -346,9 +362,9 @@ class DirectiveSchedule extends DirectiveListTemplate { $minute = sprintf('%02d', $this->TimeMinAt->getDirectiveValue()); $directive_values[] = "at {$hour}:{$minute}"; } elseif ($this->TimeHourly->Checked === true) { - $hour = $this->TimeHourHourly->getDirectiveValue(); + $hour = '00'; $minute = sprintf('%02d', $this->TimeMinHourly->getDirectiveValue()); - $directive_values[] = "at {$hour}:{$minute}"; + $directive_values[] = "hourly at {$hour}:{$minute}"; } $directive_value = array('Run' => implode(' ', $directive_values)); diff --git a/gui/baculum/protected/Web/Portlets/DirectiveSchedule.tpl b/gui/baculum/protected/Web/Portlets/DirectiveSchedule.tpl index 0d239993fc..f409430afa 100644 --- a/gui/baculum/protected/Web/Portlets/DirectiveSchedule.tpl +++ b/gui/baculum/protected/Web/Portlets/DirectiveSchedule.tpl @@ -217,30 +217,20 @@
-