]> git.sur5r.net Git - bacula/bacula/commitdiff
baculum: Fix reading and writing schedule resource
authorMarcin Haba <marcin.haba@bacula.pl>
Sun, 8 Oct 2017 16:11:30 +0000 (18:11 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Sun, 8 Oct 2017 16:11:30 +0000 (18:11 +0200)
gui/baculum/protected/API/Class/BaculaSetting.php
gui/baculum/protected/Web/Portlets/DirectiveSchedule.php
gui/baculum/protected/Web/Portlets/DirectiveSchedule.tpl

index c74cf58c377e4fad6c873f2c669eaeb60a30ff31..48ccaa9798fc2602adc72e3793356ad6b07e51c7 100644 (file)
@@ -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']);
index 2c1be5558f1a996dc45e9bdcd0d666297130b2fe..6d1d97a761eca3ed33a2e2f14852148bd9b71f6a 100644 (file)
@@ -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));
index 0d239993fc50a5203d3e011de3864c32083848a6..f409430afa40e37103277c285643102101760c6d 100644 (file)
        <div id="day<%=$this->TimeAt->ClientID%>" class="day<%=$this->TimeAt->ClientID%>" style="display: <%=$this->TimeAt->Checked ? 'block' : 'none'%>">
                <com:Application.Web.Portlets.DirectiveText
                        ID="TimeHourAt"
-                       DirectiveValue="<%=$this->directives['time']['hour']%>"
                        Label="<%[ Hour ]%>"
                        InConfig="true"
                        Show="true"
                />
                <com:Application.Web.Portlets.DirectiveText
                        ID="TimeMinAt"
-                       DirectiveValue="<%=$this->directives['time']['minute']%>"
                        Label="<%[ Minute ]%>"
                        InConfig="true"
                        Show="true"
                />
        </div>
        <div id="day_range<%=$this->TimeAt->ClientID%>" class="day<%=$this->TimeAt->ClientID%>" style="display: <%=$this->TimeHourly->Checked ? 'block' : 'none'%>">
-               <com:Application.Web.Portlets.DirectiveText
-                       ID="TimeHourHourly"
-                       DirectiveValue="0"
-                       Label="<%[ Hour ]%>"
-                       InConfig="true"
-                       Show="true"
-               />
                <com:Application.Web.Portlets.DirectiveText
                        ID="TimeMinHourly"
-                       DirectiveValue="<%=$this->directives['time']['minute']%>"
                        Label="<%[ Minute ]%>"
                        InConfig="true"
                        Show="true"