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 entities that can be parsed directly (as a stream) from WBXML. |
||
| 9 | * It is automatically decoded according to $mapping and the Sync WBXML |
||
| 10 | * mappings. |
||
| 11 | */ |
||
| 12 | |||
| 13 | class SyncTask extends SyncObject { |
||
| 14 | public $body; |
||
| 15 | public $complete; |
||
| 16 | public $datecompleted; |
||
| 17 | public $duedate; |
||
| 18 | public $utcduedate; |
||
| 19 | public $importance; |
||
| 20 | public $recurrence; |
||
| 21 | public $regenerate; |
||
| 22 | public $deadoccur; |
||
| 23 | public $reminderset; |
||
| 24 | public $remindertime; |
||
| 25 | public $sensitivity; |
||
| 26 | public $startdate; |
||
| 27 | public $utcstartdate; |
||
| 28 | public $subject; |
||
| 29 | public $rtf; |
||
| 30 | public $categories; |
||
| 31 | |||
| 32 | public function __construct() { |
||
| 33 | $mapping = [ |
||
| 34 | SYNC_POOMTASKS_BODY => [ |
||
| 35 | self::STREAMER_VAR => "body", |
||
| 36 | self::STREAMER_RONOTIFY => true, |
||
| 37 | ], |
||
| 38 | SYNC_POOMTASKS_COMPLETE => [ |
||
| 39 | self::STREAMER_VAR => "complete", |
||
| 40 | self::STREAMER_CHECKS => [ |
||
| 41 | self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETZERO, |
||
| 42 | self::STREAMER_CHECK_ZEROORONE => self::STREAMER_CHECK_SETZERO, |
||
| 43 | ], |
||
| 44 | self::STREAMER_RONOTIFY => true, |
||
| 45 | ], |
||
| 46 | SYNC_POOMTASKS_DATECOMPLETED => [ |
||
| 47 | self::STREAMER_VAR => "datecompleted", |
||
| 48 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE_DASHES, |
||
| 49 | self::STREAMER_RONOTIFY => true, |
||
| 50 | ], |
||
| 51 | SYNC_POOMTASKS_DUEDATE => [ |
||
| 52 | self::STREAMER_VAR => "duedate", |
||
| 53 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE_DASHES, |
||
| 54 | self::STREAMER_RONOTIFY => true, |
||
| 55 | ], |
||
| 56 | SYNC_POOMTASKS_UTCDUEDATE => [ |
||
| 57 | self::STREAMER_VAR => "utcduedate", |
||
| 58 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE_DASHES, |
||
| 59 | self::STREAMER_RONOTIFY => true, |
||
| 60 | ], |
||
| 61 | // Importance values |
||
| 62 | // 0 = Low |
||
| 63 | // 1 = Normal |
||
| 64 | // 2 = High |
||
| 65 | // even the default value 1 is optional, the native android client 2.2 interprets a non-existing value as 0 (low) |
||
| 66 | SYNC_POOMTASKS_IMPORTANCE => [self::STREAMER_VAR => "importance", |
||
| 67 | self::STREAMER_CHECKS => [ |
||
| 68 | self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETONE, |
||
| 69 | self::STREAMER_CHECK_ONEVALUEOF => [0, 1, 2], |
||
| 70 | ], |
||
| 71 | self::STREAMER_RONOTIFY => true, |
||
| 72 | ], |
||
| 73 | SYNC_POOMTASKS_RECURRENCE => [ |
||
| 74 | self::STREAMER_VAR => "recurrence", |
||
| 75 | self::STREAMER_TYPE => "SyncTaskRecurrence", |
||
| 76 | self::STREAMER_RONOTIFY => true, |
||
| 77 | ], |
||
| 78 | SYNC_POOMTASKS_REGENERATE => [ |
||
| 79 | self::STREAMER_VAR => "regenerate", |
||
| 80 | self::STREAMER_RONOTIFY => true, |
||
| 81 | ], |
||
| 82 | SYNC_POOMTASKS_DEADOCCUR => [ |
||
| 83 | self::STREAMER_VAR => "deadoccur", |
||
| 84 | self::STREAMER_RONOTIFY => true, |
||
| 85 | ], |
||
| 86 | SYNC_POOMTASKS_REMINDERSET => [ |
||
| 87 | self::STREAMER_VAR => "reminderset", |
||
| 88 | self::STREAMER_CHECKS => [ |
||
| 89 | self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETZERO, |
||
| 90 | self::STREAMER_CHECK_ZEROORONE => self::STREAMER_CHECK_SETZERO, |
||
| 91 | ], |
||
| 92 | self::STREAMER_RONOTIFY => true, |
||
| 93 | ], |
||
| 94 | SYNC_POOMTASKS_REMINDERTIME => [ |
||
| 95 | self::STREAMER_VAR => "remindertime", |
||
| 96 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE_DASHES, |
||
| 97 | self::STREAMER_RONOTIFY => true, |
||
| 98 | ], |
||
| 99 | // Sensitivity values |
||
| 100 | // 0 = Normal |
||
| 101 | // 1 = Personal |
||
| 102 | // 2 = Private |
||
| 103 | // 3 = Confident |
||
| 104 | SYNC_POOMTASKS_SENSITIVITY => [ |
||
| 105 | self::STREAMER_VAR => "sensitivity", |
||
| 106 | self::STREAMER_CHECKS => [self::STREAMER_CHECK_ONEVALUEOF => [0, 1, 2, 3]], |
||
| 107 | self::STREAMER_RONOTIFY => true, |
||
| 108 | ], |
||
| 109 | SYNC_POOMTASKS_STARTDATE => [ |
||
| 110 | self::STREAMER_VAR => "startdate", |
||
| 111 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE_DASHES, |
||
| 112 | self::STREAMER_RONOTIFY => true, |
||
| 113 | ], |
||
| 114 | SYNC_POOMTASKS_UTCSTARTDATE => [ |
||
| 115 | self::STREAMER_VAR => "utcstartdate", |
||
| 116 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE_DASHES, |
||
| 117 | self::STREAMER_RONOTIFY => true, |
||
| 118 | ], |
||
| 119 | SYNC_POOMTASKS_SUBJECT => [ |
||
| 120 | self::STREAMER_VAR => "subject", |
||
| 121 | self::STREAMER_RONOTIFY => true, |
||
| 122 | ], |
||
| 123 | SYNC_POOMTASKS_CATEGORIES => [ |
||
| 124 | self::STREAMER_VAR => "categories", |
||
| 125 | self::STREAMER_ARRAY => SYNC_POOMTASKS_CATEGORY, |
||
| 126 | self::STREAMER_RONOTIFY => true, |
||
| 127 | ], |
||
| 128 | ]; |
||
| 129 | |||
| 130 | if (Request::GetProtocolVersion() >= 12.0) { |
||
| 131 | $mapping[SYNC_AIRSYNCBASE_BODY] = [ |
||
| 132 | self::STREAMER_VAR => "asbody", |
||
| 133 | self::STREAMER_TYPE => "SyncBaseBody", |
||
| 134 | self::STREAMER_RONOTIFY => true, |
||
| 135 | ]; |
||
| 136 | |||
| 137 | // unset these properties because airsyncbase body and attachments will be used instead |
||
| 138 | unset($mapping[SYNC_POOMTASKS_BODY]); |
||
| 139 | } |
||
| 140 | |||
| 141 | parent::__construct($mapping); |
||
| 142 | } |
||
| 143 | |||
| 144 | /** |
||
| 145 | * Method checks if the object has the minimum of required parameters |
||
| 146 | * and fulfills semantic dependencies. |
||
| 147 | * |
||
| 148 | * This overloads the general check() with special checks to be executed |
||
| 149 | * |
||
| 150 | * @param bool $logAsDebug (opt) default is false, so messages are logged in WARN log level |
||
| 151 | * |
||
| 152 | * @return bool |
||
| 153 | */ |
||
| 154 | #[Override] |
||
| 155 | public function Check($logAsDebug = false) { |
||
| 156 | $ret = parent::Check($logAsDebug); |
||
| 157 | |||
| 158 | // semantic checks general "turn off switch" |
||
| 159 | if (defined("DO_SEMANTIC_CHECKS") && DO_SEMANTIC_CHECKS === false) { |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 160 | return $ret; |
||
| 161 | } |
||
| 162 | |||
| 163 | if (!$ret) { |
||
| 164 | return false; |
||
| 165 | } |
||
| 166 | |||
| 167 | if (isset($this->startdate, $this->duedate) && $this->duedate < $this->startdate) { |
||
| 168 | SLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): Unmet condition in object from type %s: parameter 'startdate' is HIGHER than 'duedate'. Check failed!", static::class)); |
||
| 169 | |||
| 170 | return false; |
||
| 171 | } |
||
| 172 | |||
| 173 | if (isset($this->utcstartdate, $this->utcduedate) && $this->utcduedate < $this->utcstartdate) { |
||
| 174 | SLog::Write(LOGLEVEL_WARN, sprintf("SyncObject->Check(): Unmet condition in object from type %s: parameter 'utcstartdate' is HIGHER than 'utcduedate'. Check failed!", static::class)); |
||
| 175 | |||
| 176 | return false; |
||
| 177 | } |
||
| 178 | |||
| 179 | if (isset($this->duedate) && $this->duedate != Utils::getDayStartOfTimestamp($this->duedate)) { |
||
| 180 | $this->duedate = Utils::getDayStartOfTimestamp($this->duedate); |
||
| 181 | SLog::Write(LOGLEVEL_DEBUG, "Set the due time to the start of the day"); |
||
| 182 | if (isset($this->startdate) && $this->duedate < $this->startdate) { |
||
| 183 | $this->startdate = Utils::getDayStartOfTimestamp($this->startdate); |
||
| 184 | SLog::Write(LOGLEVEL_DEBUG, "Set the start date to the start of the day"); |
||
| 185 | } |
||
| 186 | } |
||
| 187 | |||
| 188 | return true; |
||
| 189 | } |
||
| 190 | } |
||
| 191 | |||
| 192 | class SyncTaskResponse extends SyncTask { |
||
| 193 | use ResponseTrait; |
||
| 194 | } |
||
| 195 |