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