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