]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Fix schedule single day value setting
authorMarcin Haba <marcin.haba@bacula.pl>
Mon, 6 Aug 2018 16:41:34 +0000 (18:41 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Mon, 6 Aug 2018 16:41:34 +0000 (18:41 +0200)
gui/baculum/protected/API/Class/BaculaSetting.php
gui/baculum/protected/Common/Class/Params.php

index 68683d1cfc37d6ee55aec02a7a2b0df51a83bd14..b314dbd9cf4b3c141527be5ff66ccf8b0d67be9b 100644 (file)
@@ -266,7 +266,7 @@ class BaculaSetting extends APIModule {
                                                        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']);
+                                                       $day = Params::getDaysConfig($directive_value[$i]['Day']);
                                                        $month = Params::getMonthsConfig($directive_value[$i]['Month']);
                                                        $week = Params::getWeeksConfig($directive_value[$i]['WeekOfMonth']);
                                                        $wday = Params::getWdaysConfig($directive_value[$i]['DayOfWeek']);
index 67bf60c02a79492b4a5cc27612fea7ce95101a10..b5e1a06c97a1b5e29e89fcabb8dd0ab0bdde47e9 100644 (file)
@@ -105,6 +105,31 @@ class Params extends CommonModule {
                return $wday;
        }
 
+       /**
+        * Get day value in config form.
+        *
+        * @param array $days_cfg days array (ex. array(0,1,2,3,4))
+        * @return string days config value
+        */
+       public function getDaysConfig(array $days_cfg) {
+               $days = '';
+               if (count($days_cfg) < 31) {
+                       $days_map = array_map(array('Params', 'getDayByNo') , $days_cfg);
+                       $days = 'on ' . implode(',', $days_map);
+               }
+               return $days;
+       }
+
+       /**
+        * Simple method to prepare day config value by day number.
+        *
+        * @static
+        * @return integer single day config value
+        */
+       private static function getDayByNo($day_no) {
+               return ++$day_no;
+       }
+
        /**
         * Get Bacula config boolean value.
         *