]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/protected/Common/Class/Params.php
baculum: Fix saving boolean values in schedule Run directive
[bacula/bacula] / gui / baculum / protected / Common / Class / Params.php
1 <?php
2 /*
3  * Bacula(R) - The Network Backup Solution
4  * Baculum   - Bacula web interface
5  *
6  * Copyright (C) 2013-2017 Kern Sibbald
7  *
8  * The main author of Baculum is Marcin Haba.
9  * The original author of Bacula is Kern Sibbald, with contributions
10  * from many others, a complete list can be found in the file AUTHORS.
11  *
12  * You may use this file and others of this release according to the
13  * license defined in the LICENSE file, which includes the Affero General
14  * Public License, v3.0 ("AGPLv3") and some additional permissions and
15  * terms pursuant to its AGPLv3 Section 7.
16  *
17  * This notice must be preserved when any source code is
18  * conveyed and/or propagated.
19  *
20  * Bacula(R) is a registered trademark of Kern Sibbald.
21  */
22
23 Prado::using('Application.Common.Class.CommonModule');
24 Prado::using('Application.Common.Class.Params');
25
26 class Params extends CommonModule {
27
28         public static $months = array(
29                 'jan' => 'January',
30                 'feb' => 'February',
31                 'mar' => 'March',
32                 'apr' => 'April',
33                 'may' => 'May',
34                 'jun' => 'June',
35                 'jul' => 'July',
36                 'aug' => 'August',
37                 'sep' => 'September',
38                 'oct' => 'October',
39                 'nov' => 'November',
40                 'dec' => 'December'
41         );
42
43         public static $weeks = array(
44                 '1st' => 'first',
45                 '2nd' => 'second',
46                 '3rd' => 'third',
47                 '4th' => 'fourth',
48                 '5th' => 'fifth'
49         );
50         public static $wdays = array(
51                 'sun' => 'Sunday',
52                 'mon' => 'Monday',
53                 'tue' => 'Tuesday',
54                 'wed' => 'Wednesday',
55                 'thu' => 'Thursday',
56                 'fri' => 'Friday',
57                 'sat' => 'Saturday'
58         );
59
60         public function getMonthsConfig(array $months_cfg) {
61                 $month = '';
62                 $month_count = count($months_cfg);
63                 $months = array_keys(Params::$months);
64                 if ($month_count < 12) {
65                         if ($month_count > 1) {
66                                 $month_start = $months_cfg[0];
67                                 $month_end = $months_cfg[$month_count-1];
68                                 $month .= $months[$month_start] . '-' . $months[$month_end];
69                         } else {
70                                 $month .= $months[$months_cfg[0]];
71                         }
72                 }
73                 return $month;
74         }
75
76         public function getWeeksConfig(array $weeks_cfg) {
77                 $week = '';
78                 $week_count = count($weeks_cfg);
79                 $weeks = array_keys(Params::$weeks);
80                 if ($week_count < 5) {
81                         if ($week_count > 1) {
82                                 $week_start = $weeks_cfg[0];
83                                 $week_end = $weeks_cfg[$week_count-1];
84                                 $week .= $weeks[$week_start] . '-' . $weeks[$week_end];
85                         } else {
86                                 $week .= $weeks[$weeks_cfg[0]];
87                         }
88                 }
89                 return $week;
90         }
91
92         public function getWdaysConfig(array $wdays_cfg) {
93                 $wday = '';
94                 $wday_count = count($wdays_cfg);
95                 $wdays = array_keys(Params::$wdays);
96                 if ($wday_count < 7) {
97                         if ($wday_count > 1) {
98                                 $wday_start = $wdays_cfg[0];
99                                 $wday_end = $wdays_cfg[$wday_count-1];
100                                 $wday .= $wdays[$wday_start] . '-' . $wdays[$wday_end];
101                         } else {
102                                 $wday .= $wdays[$wdays_cfg[0]];
103                         }
104                 }
105                 return $wday;
106         }
107
108         /**
109          * Get Bacula config boolean value.
110          *
111          * @param boolean $value value
112          * @return string bacula config boolean value
113          */
114         public static function getBoolValue($value) {
115                 return ($value ? 'yes' : 'no');
116         }
117 }
118 ?>