1 | <?php |
||
2 | /* |
||
3 | * SPDX-License-Identifier: AGPL-3.0-only |
||
4 | * SPDX-FileCopyrightText: Copyright 2007-2016 Zarafa Deutschland GmbH |
||
5 | * SPDX-FileCopyrightText: Copyright 2020-2022 grommunio GmbH |
||
6 | * |
||
7 | * WBXML task recurrence entities that can be parsed directly (as a stream) |
||
8 | * from WBXML. It is automatically decoded according to $mapping and the Sync |
||
9 | * WBXML mappings. |
||
10 | */ |
||
11 | |||
12 | // Exactly the same as SyncRecurrence, but then with SYNC_POOMTASKS_* |
||
13 | class SyncTaskRecurrence extends SyncObject { |
||
14 | public $start; |
||
15 | public $type; |
||
16 | public $until; |
||
17 | public $occurrences; |
||
18 | public $interval; |
||
19 | public $dayofweek; |
||
20 | public $dayofmonth; |
||
21 | public $weekofmonth; |
||
22 | public $monthofyear; |
||
23 | public $regenerate; |
||
24 | public $deadoccur; |
||
25 | public $calendartype; |
||
26 | public $firstdayofweek; |
||
27 | |||
28 | public function __construct() { |
||
29 | $mapping = [ |
||
30 | SYNC_POOMTASKS_START => [self::STREAMER_VAR => "start", |
||
31 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE, |
||
32 | self::STREAMER_RONOTIFY => true, ], |
||
33 | |||
34 | // Recurrence type |
||
35 | // 0 = Recurs daily |
||
36 | // 1 = Recurs weekly |
||
37 | // 2 = Recurs monthly |
||
38 | // 3 = Recurs monthly on the nth day |
||
39 | // 5 = Recurs yearly |
||
40 | // 6 = Recurs yearly on the nth day |
||
41 | SYNC_POOMTASKS_TYPE => [ |
||
42 | self::STREAMER_VAR => "type", |
||
43 | self::STREAMER_CHECKS => [ |
||
44 | self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETZERO, |
||
45 | self::STREAMER_CHECK_ONEVALUEOF => [0, 1, 2, 3, 5, 6], |
||
46 | ], |
||
47 | self::STREAMER_RONOTIFY => true, |
||
48 | ], |
||
49 | SYNC_POOMTASKS_UNTIL => [ |
||
50 | self::STREAMER_VAR => "until", |
||
51 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE, |
||
52 | self::STREAMER_RONOTIFY => true, |
||
53 | ], |
||
54 | SYNC_POOMTASKS_OCCURRENCES => [ |
||
55 | self::STREAMER_VAR => "occurrences", |
||
56 | self::STREAMER_CHECKS => [ |
||
57 | self::STREAMER_CHECK_CMPHIGHER => 0, |
||
58 | self::STREAMER_CHECK_CMPLOWER => 1000, |
||
59 | ], |
||
60 | self::STREAMER_RONOTIFY => true, |
||
61 | ], |
||
62 | SYNC_POOMTASKS_INTERVAL => [ |
||
63 | self::STREAMER_VAR => "interval", |
||
64 | self::STREAMER_CHECKS => [ |
||
65 | self::STREAMER_CHECK_CMPHIGHER => 0, |
||
66 | self::STREAMER_CHECK_CMPLOWER => 1000, |
||
67 | ], |
||
68 | self::STREAMER_RONOTIFY => true, |
||
69 | ], |
||
70 | // TODO: check iOS5 sends deadoccur inside of the recurrence |
||
71 | SYNC_POOMTASKS_DEADOCCUR => [ |
||
72 | self::STREAMER_VAR => "deadoccur", |
||
73 | self::STREAMER_RONOTIFY => true, |
||
74 | ], |
||
75 | SYNC_POOMTASKS_REGENERATE => [ |
||
76 | self::STREAMER_VAR => "regenerate", |
||
77 | self::STREAMER_RONOTIFY => true, |
||
78 | ], |
||
79 | // DayOfWeek values |
||
80 | // 1 = Sunday |
||
81 | // 2 = Monday |
||
82 | // 4 = Tuesday |
||
83 | // 8 = Wednesday |
||
84 | // 16 = Thursday |
||
85 | // 32 = Friday |
||
86 | // 62 = Weekdays // TODO check: value set by WA with daily weekday recurrence |
||
87 | // 64 = Saturday |
||
88 | // 127 = The last day of the month. Value valid only in monthly or yearly recurrences. |
||
89 | SYNC_POOMTASKS_DAYOFWEEK => [ |
||
90 | self::STREAMER_VAR => "dayofweek", |
||
91 | self::STREAMER_CHECKS => [ |
||
92 | self::STREAMER_CHECK_CMPHIGHER => 0, |
||
93 | self::STREAMER_CHECK_CMPLOWER => 128, |
||
94 | ], |
||
95 | self::STREAMER_RONOTIFY => true, |
||
96 | ], |
||
97 | // DayOfMonth values |
||
98 | // 1-31 representing the day |
||
99 | SYNC_POOMTASKS_DAYOFMONTH => [ |
||
100 | self::STREAMER_VAR => "dayofmonth", |
||
101 | self::STREAMER_CHECKS => [ |
||
102 | self::STREAMER_CHECK_CMPHIGHER => 0, |
||
103 | self::STREAMER_CHECK_CMPLOWER => 32, |
||
104 | ], |
||
105 | self::STREAMER_RONOTIFY => true, |
||
106 | ], |
||
107 | // WeekOfMonth |
||
108 | // 1-4 = Y st/nd/rd/th week of month |
||
109 | // 5 = last week of month |
||
110 | SYNC_POOMTASKS_WEEKOFMONTH => [ |
||
111 | self::STREAMER_VAR => "weekofmonth", |
||
112 | self::STREAMER_CHECKS => [self::STREAMER_CHECK_ONEVALUEOF => [1, 2, 3, 4, 5]], |
||
113 | self::STREAMER_RONOTIFY => true, |
||
114 | ], |
||
115 | // MonthOfYear |
||
116 | // 1-12 representing the month |
||
117 | SYNC_POOMTASKS_MONTHOFYEAR => [ |
||
118 | self::STREAMER_VAR => "monthofyear", |
||
119 | self::STREAMER_CHECKS => [self::STREAMER_CHECK_ONEVALUEOF => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]], |
||
120 | self::STREAMER_RONOTIFY => true, |
||
121 | ], |
||
122 | ]; |
||
123 | |||
124 | if (Request::GetProtocolVersion() >= 14.0) { |
||
125 | $mapping[SYNC_POOMTASKS_CALENDARTYPE] = [ |
||
126 | self::STREAMER_VAR => "calendartype", |
||
127 | self::STREAMER_RONOTIFY => true, |
||
128 | ]; |
||
129 | } |
||
130 | |||
131 | if (Request::GetProtocolVersion() >= 14.1) { |
||
132 | // First day of the calendar week for recurrence. |
||
133 | // FirstDayOfWeek values: |
||
134 | // 0 = Sunday |
||
135 | // 1 = Monday |
||
136 | // 2 = Tuesday |
||
137 | // 3 = Wednesday |
||
138 | // 4 = Thursday |
||
139 | // 5 = Friday |
||
140 | // 6 = Saturday |
||
141 | $mapping[SYNC_POOMTASKS_FIRSTDAYOFWEEK] = [ |
||
142 | self::STREAMER_VAR => "firstdayofweek", |
||
143 | self::STREAMER_CHECKS => [self::STREAMER_CHECK_ONEVALUEOF => [0, 1, 2, 3, 4, 5, 6]], |
||
144 | self::STREAMER_RONOTIFY => true, |
||
145 | ]; |
||
146 | } |
||
147 | |||
148 | parent::__construct($mapping); |
||
149 | } |
||
150 | |||
151 | /** |
||
152 | * Method checks if the object has the minimum of required parameters |
||
153 | * and fulfills semantic dependencies. |
||
154 | * |
||
155 | * This overloads the general check() with special checks to be executed |
||
156 | * |
||
157 | * @param bool $logAsDebug (opt) default is false, so messages are logged in WARN log level |
||
158 | * |
||
159 | * @return bool |
||
160 | */ |
||
161 | public function Check($logAsDebug = false) { |
||
162 | $ret = parent::Check($logAsDebug); |
||
163 | |||
164 | // semantic checks general "turn off switch" |
||
165 | if (defined("DO_SEMANTIC_CHECKS") && DO_SEMANTIC_CHECKS === false) { |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
166 | return $ret; |
||
167 | } |
||
168 | |||
169 | if (!$ret) { |
||
170 | return false; |
||
171 | } |
||
172 | |||
173 | if (isset($this->start, $this->until) && $this->until < $this->start) { |
||
174 | SLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): Unmet condition in object from type %s: parameter 'start' is HIGHER than 'until'. Check failed!", get_class($this))); |
||
175 | |||
176 | return false; |
||
177 | } |
||
178 | |||
179 | return true; |
||
180 | } |
||
181 | } |
||
182 |