@@ -2,9 +2,9 @@ |
||
2 | 2 | |
3 | 3 | namespace Sabre\CalDAV\Xml\Notification; |
4 | 4 | |
5 | -use Sabre\Xml\Writer; |
|
6 | -use Sabre\CalDAV\SharingPlugin as SharingPlugin; |
|
7 | 5 | use Sabre\CalDAV; |
6 | +use Sabre\CalDAV\SharingPlugin as SharingPlugin; |
|
7 | +use Sabre\Xml\Writer; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * This class represents the cs:invite-notification notification element. |
@@ -18,290 +18,290 @@ |
||
18 | 18 | */ |
19 | 19 | class Invite implements NotificationInterface { |
20 | 20 | |
21 | - /** |
|
22 | - * A unique id for the message |
|
23 | - * |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - protected $id; |
|
27 | - |
|
28 | - /** |
|
29 | - * Timestamp of the notification |
|
30 | - * |
|
31 | - * @var DateTime |
|
32 | - */ |
|
33 | - protected $dtStamp; |
|
34 | - |
|
35 | - /** |
|
36 | - * A url to the recipient of the notification. This can be an email |
|
37 | - * address (mailto:), or a principal url. |
|
38 | - * |
|
39 | - * @var string |
|
40 | - */ |
|
41 | - protected $href; |
|
42 | - |
|
43 | - /** |
|
44 | - * The type of message, see the SharingPlugin::STATUS_* constants. |
|
45 | - * |
|
46 | - * @var int |
|
47 | - */ |
|
48 | - protected $type; |
|
49 | - |
|
50 | - /** |
|
51 | - * True if access to a calendar is read-only. |
|
52 | - * |
|
53 | - * @var bool |
|
54 | - */ |
|
55 | - protected $readOnly; |
|
56 | - |
|
57 | - /** |
|
58 | - * A url to the shared calendar. |
|
59 | - * |
|
60 | - * @var string |
|
61 | - */ |
|
62 | - protected $hostUrl; |
|
63 | - |
|
64 | - /** |
|
65 | - * Url to the sharer of the calendar |
|
66 | - * |
|
67 | - * @var string |
|
68 | - */ |
|
69 | - protected $organizer; |
|
70 | - |
|
71 | - /** |
|
72 | - * The name of the sharer. |
|
73 | - * |
|
74 | - * @var string |
|
75 | - */ |
|
76 | - protected $commonName; |
|
77 | - |
|
78 | - /** |
|
79 | - * The name of the sharer. |
|
80 | - * |
|
81 | - * @var string |
|
82 | - */ |
|
83 | - protected $firstName; |
|
84 | - |
|
85 | - /** |
|
86 | - * The name of the sharer. |
|
87 | - * |
|
88 | - * @var string |
|
89 | - */ |
|
90 | - protected $lastName; |
|
91 | - |
|
92 | - /** |
|
93 | - * A description of the share request |
|
94 | - * |
|
95 | - * @var string |
|
96 | - */ |
|
97 | - protected $summary; |
|
98 | - |
|
99 | - /** |
|
100 | - * The Etag for the notification |
|
101 | - * |
|
102 | - * @var string |
|
103 | - */ |
|
104 | - protected $etag; |
|
105 | - |
|
106 | - /** |
|
107 | - * The list of supported components |
|
108 | - * |
|
109 | - * @var Sabre\CalDAV\Property\SupportedCalendarComponentSet |
|
110 | - */ |
|
111 | - protected $supportedComponents; |
|
112 | - |
|
113 | - /** |
|
114 | - * Creates the Invite notification. |
|
115 | - * |
|
116 | - * This constructor receives an array with the following elements: |
|
117 | - * |
|
118 | - * * id - A unique id |
|
119 | - * * etag - The etag |
|
120 | - * * dtStamp - A DateTime object with a timestamp for the notification. |
|
121 | - * * type - The type of notification, see SharingPlugin::STATUS_* |
|
122 | - * constants for details. |
|
123 | - * * readOnly - This must be set to true, if this is an invite for |
|
124 | - * read-only access to a calendar. |
|
125 | - * * hostUrl - A url to the shared calendar. |
|
126 | - * * organizer - Url to the sharer principal. |
|
127 | - * * commonName - The real name of the sharer (optional). |
|
128 | - * * firstName - The first name of the sharer (optional). |
|
129 | - * * lastName - The last name of the sharer (optional). |
|
130 | - * * summary - Description of the share, can be the same as the |
|
131 | - * calendar, but may also be modified (optional). |
|
132 | - * * supportedComponents - An instance of |
|
133 | - * Sabre\CalDAV\Property\SupportedCalendarComponentSet. |
|
134 | - * This allows the client to determine which components |
|
135 | - * will be supported in the shared calendar. This is |
|
136 | - * also optional. |
|
137 | - * |
|
138 | - * @param array $values All the options |
|
139 | - */ |
|
140 | - public function __construct(array $values) { |
|
141 | - |
|
142 | - $required = [ |
|
143 | - 'id', |
|
144 | - 'etag', |
|
145 | - 'href', |
|
146 | - 'dtStamp', |
|
147 | - 'type', |
|
148 | - 'readOnly', |
|
149 | - 'hostUrl', |
|
150 | - 'organizer', |
|
151 | - ]; |
|
152 | - foreach ($required as $item) { |
|
153 | - if (!isset($values[$item])) { |
|
154 | - throw new \InvalidArgumentException($item . ' is a required constructor option'); |
|
155 | - } |
|
156 | - } |
|
157 | - |
|
158 | - foreach ($values as $key => $value) { |
|
159 | - if (!property_exists($this, $key)) { |
|
160 | - throw new \InvalidArgumentException('Unknown option: ' . $key); |
|
161 | - } |
|
162 | - $this->$key = $value; |
|
163 | - } |
|
164 | - |
|
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * The xmlSerialize metod is called during xml writing. |
|
169 | - * |
|
170 | - * Use the $writer argument to write its own xml serialization. |
|
171 | - * |
|
172 | - * An important note: do _not_ create a parent element. Any element |
|
173 | - * implementing XmlSerializble should only ever write what's considered |
|
174 | - * its 'inner xml'. |
|
175 | - * |
|
176 | - * The parent of the current element is responsible for writing a |
|
177 | - * containing element. |
|
178 | - * |
|
179 | - * This allows serializers to be re-used for different element names. |
|
180 | - * |
|
181 | - * If you are opening new elements, you must also close them again. |
|
182 | - * |
|
183 | - * @param Writer $writer |
|
184 | - * @return void |
|
185 | - */ |
|
186 | - public function xmlSerialize(Writer $writer) { |
|
187 | - |
|
188 | - $writer->writeElement('{' . CalDAV\Plugin::NS_CALENDARSERVER . '}invite-notification'); |
|
189 | - |
|
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * This method serializes the entire notification, as it is used in the |
|
194 | - * response body. |
|
195 | - * |
|
196 | - * @param Writer $writer |
|
197 | - * @return void |
|
198 | - */ |
|
199 | - public function xmlSerializeFull(Writer $writer) { |
|
200 | - |
|
201 | - $cs = '{' . CalDAV\Plugin::NS_CALENDARSERVER . '}'; |
|
202 | - |
|
203 | - $this->dtStamp->setTimezone(new \DateTimezone('GMT')); |
|
204 | - $writer->writeElement($cs . 'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); |
|
205 | - |
|
206 | - $writer->startElement($cs . 'invite-notification'); |
|
207 | - |
|
208 | - $writer->writeElement($cs . 'uid', $this->id); |
|
209 | - $writer->writeElement('{DAV:}href', $this->href); |
|
210 | - |
|
211 | - switch ($this->type) { |
|
212 | - |
|
213 | - case SharingPlugin::STATUS_ACCEPTED : |
|
214 | - $writer->writeElement($cs . 'invite-accepted'); |
|
215 | - break; |
|
216 | - case SharingPlugin::STATUS_DECLINED : |
|
217 | - $writer->writeElement($cs . 'invite-declined'); |
|
218 | - break; |
|
219 | - case SharingPlugin::STATUS_DELETED : |
|
220 | - $writer->writeElement($cs . 'invite-deleted'); |
|
221 | - break; |
|
222 | - case SharingPlugin::STATUS_NORESPONSE : |
|
223 | - $writer->writeElement($cs . 'invite-noresponse'); |
|
224 | - break; |
|
225 | - |
|
226 | - } |
|
227 | - |
|
228 | - $writer->writeElement($cs . 'hosturl', [ |
|
229 | - '{DAV:}href' => $writer->contextUri . $this->hostUrl |
|
230 | - ]); |
|
231 | - |
|
232 | - if ($this->summary) { |
|
233 | - $writer->writeElement($cs . 'summary', $this->summary); |
|
234 | - } |
|
235 | - |
|
236 | - $writer->startElement($cs . 'access'); |
|
237 | - if ($this->readOnly) { |
|
238 | - $writer->writeElement($cs . 'read'); |
|
239 | - } else { |
|
240 | - $writer->writeElement($cs . 'read-write'); |
|
241 | - } |
|
242 | - $writer->endElement(); // access |
|
243 | - |
|
244 | - $writer->startElement($cs . 'organizer'); |
|
245 | - // If the organizer contains a 'mailto:' part, it means it should be |
|
246 | - // treated as absolute. |
|
247 | - if (strtolower(substr($this->organizer, 0, 7)) === 'mailto:') { |
|
248 | - $writer->writeElement('{DAV:}href', $this->organizer); |
|
249 | - } else { |
|
250 | - $writer->writeElement('{DAV:}href', $writer->contextUri . $this->organizer); |
|
251 | - } |
|
252 | - if ($this->commonName) { |
|
253 | - $writer->writeElement($cs . 'common-name', $this->commonName); |
|
254 | - } |
|
255 | - if ($this->firstName) { |
|
256 | - $writer->writeElement($cs . 'first-name', $this->firstName); |
|
257 | - } |
|
258 | - if ($this->lastName) { |
|
259 | - $writer->writeElement($cs . 'last-name', $this->lastName); |
|
260 | - } |
|
261 | - $writer->endElement(); // organizer |
|
262 | - |
|
263 | - if ($this->commonName) { |
|
264 | - $writer->writeElement($cs . 'organizer-cn', $this->commonName); |
|
265 | - } |
|
266 | - if ($this->firstName) { |
|
267 | - $writer->writeElement($cs . 'organizer-first', $this->firstName); |
|
268 | - } |
|
269 | - if ($this->lastName) { |
|
270 | - $writer->writeElement($cs . 'organizer-last', $this->lastName); |
|
271 | - } |
|
272 | - if ($this->supportedComponents) { |
|
273 | - $writer->writeElement('{' . CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set', $this->supportedComponents); |
|
274 | - } |
|
275 | - |
|
276 | - $writer->endElement(); // invite-notification |
|
277 | - |
|
278 | - } |
|
279 | - |
|
280 | - /** |
|
281 | - * Returns a unique id for this notification |
|
282 | - * |
|
283 | - * This is just the base url. This should generally be some kind of unique |
|
284 | - * id. |
|
285 | - * |
|
286 | - * @return string |
|
287 | - */ |
|
288 | - public function getId() { |
|
289 | - |
|
290 | - return $this->id; |
|
291 | - |
|
292 | - } |
|
293 | - |
|
294 | - /** |
|
295 | - * Returns the ETag for this notification. |
|
296 | - * |
|
297 | - * The ETag must be surrounded by literal double-quotes. |
|
298 | - * |
|
299 | - * @return string |
|
300 | - */ |
|
301 | - public function getETag() { |
|
302 | - |
|
303 | - return $this->etag; |
|
304 | - |
|
305 | - } |
|
21 | + /** |
|
22 | + * A unique id for the message |
|
23 | + * |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + protected $id; |
|
27 | + |
|
28 | + /** |
|
29 | + * Timestamp of the notification |
|
30 | + * |
|
31 | + * @var DateTime |
|
32 | + */ |
|
33 | + protected $dtStamp; |
|
34 | + |
|
35 | + /** |
|
36 | + * A url to the recipient of the notification. This can be an email |
|
37 | + * address (mailto:), or a principal url. |
|
38 | + * |
|
39 | + * @var string |
|
40 | + */ |
|
41 | + protected $href; |
|
42 | + |
|
43 | + /** |
|
44 | + * The type of message, see the SharingPlugin::STATUS_* constants. |
|
45 | + * |
|
46 | + * @var int |
|
47 | + */ |
|
48 | + protected $type; |
|
49 | + |
|
50 | + /** |
|
51 | + * True if access to a calendar is read-only. |
|
52 | + * |
|
53 | + * @var bool |
|
54 | + */ |
|
55 | + protected $readOnly; |
|
56 | + |
|
57 | + /** |
|
58 | + * A url to the shared calendar. |
|
59 | + * |
|
60 | + * @var string |
|
61 | + */ |
|
62 | + protected $hostUrl; |
|
63 | + |
|
64 | + /** |
|
65 | + * Url to the sharer of the calendar |
|
66 | + * |
|
67 | + * @var string |
|
68 | + */ |
|
69 | + protected $organizer; |
|
70 | + |
|
71 | + /** |
|
72 | + * The name of the sharer. |
|
73 | + * |
|
74 | + * @var string |
|
75 | + */ |
|
76 | + protected $commonName; |
|
77 | + |
|
78 | + /** |
|
79 | + * The name of the sharer. |
|
80 | + * |
|
81 | + * @var string |
|
82 | + */ |
|
83 | + protected $firstName; |
|
84 | + |
|
85 | + /** |
|
86 | + * The name of the sharer. |
|
87 | + * |
|
88 | + * @var string |
|
89 | + */ |
|
90 | + protected $lastName; |
|
91 | + |
|
92 | + /** |
|
93 | + * A description of the share request |
|
94 | + * |
|
95 | + * @var string |
|
96 | + */ |
|
97 | + protected $summary; |
|
98 | + |
|
99 | + /** |
|
100 | + * The Etag for the notification |
|
101 | + * |
|
102 | + * @var string |
|
103 | + */ |
|
104 | + protected $etag; |
|
105 | + |
|
106 | + /** |
|
107 | + * The list of supported components |
|
108 | + * |
|
109 | + * @var Sabre\CalDAV\Property\SupportedCalendarComponentSet |
|
110 | + */ |
|
111 | + protected $supportedComponents; |
|
112 | + |
|
113 | + /** |
|
114 | + * Creates the Invite notification. |
|
115 | + * |
|
116 | + * This constructor receives an array with the following elements: |
|
117 | + * |
|
118 | + * * id - A unique id |
|
119 | + * * etag - The etag |
|
120 | + * * dtStamp - A DateTime object with a timestamp for the notification. |
|
121 | + * * type - The type of notification, see SharingPlugin::STATUS_* |
|
122 | + * constants for details. |
|
123 | + * * readOnly - This must be set to true, if this is an invite for |
|
124 | + * read-only access to a calendar. |
|
125 | + * * hostUrl - A url to the shared calendar. |
|
126 | + * * organizer - Url to the sharer principal. |
|
127 | + * * commonName - The real name of the sharer (optional). |
|
128 | + * * firstName - The first name of the sharer (optional). |
|
129 | + * * lastName - The last name of the sharer (optional). |
|
130 | + * * summary - Description of the share, can be the same as the |
|
131 | + * calendar, but may also be modified (optional). |
|
132 | + * * supportedComponents - An instance of |
|
133 | + * Sabre\CalDAV\Property\SupportedCalendarComponentSet. |
|
134 | + * This allows the client to determine which components |
|
135 | + * will be supported in the shared calendar. This is |
|
136 | + * also optional. |
|
137 | + * |
|
138 | + * @param array $values All the options |
|
139 | + */ |
|
140 | + public function __construct(array $values) { |
|
141 | + |
|
142 | + $required = [ |
|
143 | + 'id', |
|
144 | + 'etag', |
|
145 | + 'href', |
|
146 | + 'dtStamp', |
|
147 | + 'type', |
|
148 | + 'readOnly', |
|
149 | + 'hostUrl', |
|
150 | + 'organizer', |
|
151 | + ]; |
|
152 | + foreach ($required as $item) { |
|
153 | + if (!isset($values[$item])) { |
|
154 | + throw new \InvalidArgumentException($item . ' is a required constructor option'); |
|
155 | + } |
|
156 | + } |
|
157 | + |
|
158 | + foreach ($values as $key => $value) { |
|
159 | + if (!property_exists($this, $key)) { |
|
160 | + throw new \InvalidArgumentException('Unknown option: ' . $key); |
|
161 | + } |
|
162 | + $this->$key = $value; |
|
163 | + } |
|
164 | + |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * The xmlSerialize metod is called during xml writing. |
|
169 | + * |
|
170 | + * Use the $writer argument to write its own xml serialization. |
|
171 | + * |
|
172 | + * An important note: do _not_ create a parent element. Any element |
|
173 | + * implementing XmlSerializble should only ever write what's considered |
|
174 | + * its 'inner xml'. |
|
175 | + * |
|
176 | + * The parent of the current element is responsible for writing a |
|
177 | + * containing element. |
|
178 | + * |
|
179 | + * This allows serializers to be re-used for different element names. |
|
180 | + * |
|
181 | + * If you are opening new elements, you must also close them again. |
|
182 | + * |
|
183 | + * @param Writer $writer |
|
184 | + * @return void |
|
185 | + */ |
|
186 | + public function xmlSerialize(Writer $writer) { |
|
187 | + |
|
188 | + $writer->writeElement('{' . CalDAV\Plugin::NS_CALENDARSERVER . '}invite-notification'); |
|
189 | + |
|
190 | + } |
|
191 | + |
|
192 | + /** |
|
193 | + * This method serializes the entire notification, as it is used in the |
|
194 | + * response body. |
|
195 | + * |
|
196 | + * @param Writer $writer |
|
197 | + * @return void |
|
198 | + */ |
|
199 | + public function xmlSerializeFull(Writer $writer) { |
|
200 | + |
|
201 | + $cs = '{' . CalDAV\Plugin::NS_CALENDARSERVER . '}'; |
|
202 | + |
|
203 | + $this->dtStamp->setTimezone(new \DateTimezone('GMT')); |
|
204 | + $writer->writeElement($cs . 'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); |
|
205 | + |
|
206 | + $writer->startElement($cs . 'invite-notification'); |
|
207 | + |
|
208 | + $writer->writeElement($cs . 'uid', $this->id); |
|
209 | + $writer->writeElement('{DAV:}href', $this->href); |
|
210 | + |
|
211 | + switch ($this->type) { |
|
212 | + |
|
213 | + case SharingPlugin::STATUS_ACCEPTED : |
|
214 | + $writer->writeElement($cs . 'invite-accepted'); |
|
215 | + break; |
|
216 | + case SharingPlugin::STATUS_DECLINED : |
|
217 | + $writer->writeElement($cs . 'invite-declined'); |
|
218 | + break; |
|
219 | + case SharingPlugin::STATUS_DELETED : |
|
220 | + $writer->writeElement($cs . 'invite-deleted'); |
|
221 | + break; |
|
222 | + case SharingPlugin::STATUS_NORESPONSE : |
|
223 | + $writer->writeElement($cs . 'invite-noresponse'); |
|
224 | + break; |
|
225 | + |
|
226 | + } |
|
227 | + |
|
228 | + $writer->writeElement($cs . 'hosturl', [ |
|
229 | + '{DAV:}href' => $writer->contextUri . $this->hostUrl |
|
230 | + ]); |
|
231 | + |
|
232 | + if ($this->summary) { |
|
233 | + $writer->writeElement($cs . 'summary', $this->summary); |
|
234 | + } |
|
235 | + |
|
236 | + $writer->startElement($cs . 'access'); |
|
237 | + if ($this->readOnly) { |
|
238 | + $writer->writeElement($cs . 'read'); |
|
239 | + } else { |
|
240 | + $writer->writeElement($cs . 'read-write'); |
|
241 | + } |
|
242 | + $writer->endElement(); // access |
|
243 | + |
|
244 | + $writer->startElement($cs . 'organizer'); |
|
245 | + // If the organizer contains a 'mailto:' part, it means it should be |
|
246 | + // treated as absolute. |
|
247 | + if (strtolower(substr($this->organizer, 0, 7)) === 'mailto:') { |
|
248 | + $writer->writeElement('{DAV:}href', $this->organizer); |
|
249 | + } else { |
|
250 | + $writer->writeElement('{DAV:}href', $writer->contextUri . $this->organizer); |
|
251 | + } |
|
252 | + if ($this->commonName) { |
|
253 | + $writer->writeElement($cs . 'common-name', $this->commonName); |
|
254 | + } |
|
255 | + if ($this->firstName) { |
|
256 | + $writer->writeElement($cs . 'first-name', $this->firstName); |
|
257 | + } |
|
258 | + if ($this->lastName) { |
|
259 | + $writer->writeElement($cs . 'last-name', $this->lastName); |
|
260 | + } |
|
261 | + $writer->endElement(); // organizer |
|
262 | + |
|
263 | + if ($this->commonName) { |
|
264 | + $writer->writeElement($cs . 'organizer-cn', $this->commonName); |
|
265 | + } |
|
266 | + if ($this->firstName) { |
|
267 | + $writer->writeElement($cs . 'organizer-first', $this->firstName); |
|
268 | + } |
|
269 | + if ($this->lastName) { |
|
270 | + $writer->writeElement($cs . 'organizer-last', $this->lastName); |
|
271 | + } |
|
272 | + if ($this->supportedComponents) { |
|
273 | + $writer->writeElement('{' . CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set', $this->supportedComponents); |
|
274 | + } |
|
275 | + |
|
276 | + $writer->endElement(); // invite-notification |
|
277 | + |
|
278 | + } |
|
279 | + |
|
280 | + /** |
|
281 | + * Returns a unique id for this notification |
|
282 | + * |
|
283 | + * This is just the base url. This should generally be some kind of unique |
|
284 | + * id. |
|
285 | + * |
|
286 | + * @return string |
|
287 | + */ |
|
288 | + public function getId() { |
|
289 | + |
|
290 | + return $this->id; |
|
291 | + |
|
292 | + } |
|
293 | + |
|
294 | + /** |
|
295 | + * Returns the ETag for this notification. |
|
296 | + * |
|
297 | + * The ETag must be surrounded by literal double-quotes. |
|
298 | + * |
|
299 | + * @return string |
|
300 | + */ |
|
301 | + public function getETag() { |
|
302 | + |
|
303 | + return $this->etag; |
|
304 | + |
|
305 | + } |
|
306 | 306 | |
307 | 307 | } |
@@ -2,9 +2,9 @@ |
||
2 | 2 | |
3 | 3 | namespace Sabre\CalDAV\Xml\Notification; |
4 | 4 | |
5 | -use Sabre\Xml\Writer; |
|
6 | 5 | use Sabre\CalDAV; |
7 | 6 | use Sabre\CalDAV\SharingPlugin; |
7 | +use Sabre\Xml\Writer; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * This class represents the cs:invite-reply notification element. |
@@ -15,198 +15,198 @@ |
||
15 | 15 | */ |
16 | 16 | class InviteReply implements NotificationInterface { |
17 | 17 | |
18 | - /** |
|
19 | - * A unique id for the message |
|
20 | - * |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $id; |
|
24 | - |
|
25 | - /** |
|
26 | - * Timestamp of the notification |
|
27 | - * |
|
28 | - * @var DateTime |
|
29 | - */ |
|
30 | - protected $dtStamp; |
|
31 | - |
|
32 | - /** |
|
33 | - * The unique id of the notification this was a reply to. |
|
34 | - * |
|
35 | - * @var string |
|
36 | - */ |
|
37 | - protected $inReplyTo; |
|
38 | - |
|
39 | - /** |
|
40 | - * A url to the recipient of the original (!) notification. |
|
41 | - * |
|
42 | - * @var string |
|
43 | - */ |
|
44 | - protected $href; |
|
45 | - |
|
46 | - /** |
|
47 | - * The type of message, see the SharingPlugin::STATUS_ constants. |
|
48 | - * |
|
49 | - * @var int |
|
50 | - */ |
|
51 | - protected $type; |
|
52 | - |
|
53 | - /** |
|
54 | - * A url to the shared calendar. |
|
55 | - * |
|
56 | - * @var string |
|
57 | - */ |
|
58 | - protected $hostUrl; |
|
59 | - |
|
60 | - /** |
|
61 | - * A description of the share request |
|
62 | - * |
|
63 | - * @var string |
|
64 | - */ |
|
65 | - protected $summary; |
|
66 | - |
|
67 | - /** |
|
68 | - * Notification Etag |
|
69 | - * |
|
70 | - * @var string |
|
71 | - */ |
|
72 | - protected $etag; |
|
73 | - |
|
74 | - /** |
|
75 | - * Creates the Invite Reply Notification. |
|
76 | - * |
|
77 | - * This constructor receives an array with the following elements: |
|
78 | - * |
|
79 | - * * id - A unique id |
|
80 | - * * etag - The etag |
|
81 | - * * dtStamp - A DateTime object with a timestamp for the notification. |
|
82 | - * * inReplyTo - This should refer to the 'id' of the notification |
|
83 | - * this is a reply to. |
|
84 | - * * type - The type of notification, see SharingPlugin::STATUS_* |
|
85 | - * constants for details. |
|
86 | - * * hostUrl - A url to the shared calendar. |
|
87 | - * * summary - Description of the share, can be the same as the |
|
88 | - * calendar, but may also be modified (optional). |
|
89 | - * |
|
90 | - * @param array $values |
|
91 | - */ |
|
92 | - public function __construct(array $values) { |
|
93 | - |
|
94 | - $required = [ |
|
95 | - 'id', |
|
96 | - 'etag', |
|
97 | - 'href', |
|
98 | - 'dtStamp', |
|
99 | - 'inReplyTo', |
|
100 | - 'type', |
|
101 | - 'hostUrl', |
|
102 | - ]; |
|
103 | - foreach ($required as $item) { |
|
104 | - if (!isset($values[$item])) { |
|
105 | - throw new \InvalidArgumentException($item . ' is a required constructor option'); |
|
106 | - } |
|
107 | - } |
|
108 | - |
|
109 | - foreach ($values as $key => $value) { |
|
110 | - if (!property_exists($this, $key)) { |
|
111 | - throw new \InvalidArgumentException('Unknown option: ' . $key); |
|
112 | - } |
|
113 | - $this->$key = $value; |
|
114 | - } |
|
115 | - |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * The xmlSerialize metod is called during xml writing. |
|
120 | - * |
|
121 | - * Use the $writer argument to write its own xml serialization. |
|
122 | - * |
|
123 | - * An important note: do _not_ create a parent element. Any element |
|
124 | - * implementing XmlSerializble should only ever write what's considered |
|
125 | - * its 'inner xml'. |
|
126 | - * |
|
127 | - * The parent of the current element is responsible for writing a |
|
128 | - * containing element. |
|
129 | - * |
|
130 | - * This allows serializers to be re-used for different element names. |
|
131 | - * |
|
132 | - * If you are opening new elements, you must also close them again. |
|
133 | - * |
|
134 | - * @param Writer $writer |
|
135 | - * @return void |
|
136 | - */ |
|
137 | - public function xmlSerialize(Writer $writer) { |
|
138 | - |
|
139 | - $writer->writeElement('{' . CalDAV\Plugin::NS_CALENDARSERVER . '}invite-reply'); |
|
140 | - |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * This method serializes the entire notification, as it is used in the |
|
145 | - * response body. |
|
146 | - * |
|
147 | - * @param Writer $writer |
|
148 | - * @return void |
|
149 | - */ |
|
150 | - public function xmlSerializeFull(Writer $writer) { |
|
151 | - |
|
152 | - $cs = '{' . CalDAV\Plugin::NS_CALENDARSERVER . '}'; |
|
153 | - |
|
154 | - $this->dtStamp->setTimezone(new \DateTimezone('GMT')); |
|
155 | - $writer->writeElement($cs . 'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); |
|
156 | - |
|
157 | - $writer->startElement($cs . 'invite-reply'); |
|
158 | - |
|
159 | - $writer->writeElement($cs . 'uid', $this->id); |
|
160 | - $writer->writeElement($cs . 'in-reply-to', $this->inReplyTo); |
|
161 | - $writer->writeElement('{DAV:}href', $this->href); |
|
162 | - |
|
163 | - switch ($this->type) { |
|
164 | - |
|
165 | - case SharingPlugin::STATUS_ACCEPTED : |
|
166 | - $writer->writeElement($cs . 'invite-accepted'); |
|
167 | - break; |
|
168 | - case SharingPlugin::STATUS_DECLINED : |
|
169 | - $writer->writeElement($cs . 'invite-declined'); |
|
170 | - break; |
|
171 | - |
|
172 | - } |
|
173 | - |
|
174 | - $writer->writeElement($cs . 'hosturl', [ |
|
175 | - '{DAV:}href' => $writer->contextUri . $this->hostUrl |
|
176 | - ]); |
|
177 | - |
|
178 | - if ($this->summary) { |
|
179 | - $writer->writeElement($cs . 'summary', $this->summary); |
|
180 | - } |
|
181 | - $writer->endElement(); // invite-reply |
|
182 | - |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * Returns a unique id for this notification |
|
187 | - * |
|
188 | - * This is just the base url. This should generally be some kind of unique |
|
189 | - * id. |
|
190 | - * |
|
191 | - * @return string |
|
192 | - */ |
|
193 | - public function getId() { |
|
194 | - |
|
195 | - return $this->id; |
|
196 | - |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * Returns the ETag for this notification. |
|
201 | - * |
|
202 | - * The ETag must be surrounded by literal double-quotes. |
|
203 | - * |
|
204 | - * @return string |
|
205 | - */ |
|
206 | - public function getETag() { |
|
207 | - |
|
208 | - return $this->etag; |
|
209 | - |
|
210 | - } |
|
18 | + /** |
|
19 | + * A unique id for the message |
|
20 | + * |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $id; |
|
24 | + |
|
25 | + /** |
|
26 | + * Timestamp of the notification |
|
27 | + * |
|
28 | + * @var DateTime |
|
29 | + */ |
|
30 | + protected $dtStamp; |
|
31 | + |
|
32 | + /** |
|
33 | + * The unique id of the notification this was a reply to. |
|
34 | + * |
|
35 | + * @var string |
|
36 | + */ |
|
37 | + protected $inReplyTo; |
|
38 | + |
|
39 | + /** |
|
40 | + * A url to the recipient of the original (!) notification. |
|
41 | + * |
|
42 | + * @var string |
|
43 | + */ |
|
44 | + protected $href; |
|
45 | + |
|
46 | + /** |
|
47 | + * The type of message, see the SharingPlugin::STATUS_ constants. |
|
48 | + * |
|
49 | + * @var int |
|
50 | + */ |
|
51 | + protected $type; |
|
52 | + |
|
53 | + /** |
|
54 | + * A url to the shared calendar. |
|
55 | + * |
|
56 | + * @var string |
|
57 | + */ |
|
58 | + protected $hostUrl; |
|
59 | + |
|
60 | + /** |
|
61 | + * A description of the share request |
|
62 | + * |
|
63 | + * @var string |
|
64 | + */ |
|
65 | + protected $summary; |
|
66 | + |
|
67 | + /** |
|
68 | + * Notification Etag |
|
69 | + * |
|
70 | + * @var string |
|
71 | + */ |
|
72 | + protected $etag; |
|
73 | + |
|
74 | + /** |
|
75 | + * Creates the Invite Reply Notification. |
|
76 | + * |
|
77 | + * This constructor receives an array with the following elements: |
|
78 | + * |
|
79 | + * * id - A unique id |
|
80 | + * * etag - The etag |
|
81 | + * * dtStamp - A DateTime object with a timestamp for the notification. |
|
82 | + * * inReplyTo - This should refer to the 'id' of the notification |
|
83 | + * this is a reply to. |
|
84 | + * * type - The type of notification, see SharingPlugin::STATUS_* |
|
85 | + * constants for details. |
|
86 | + * * hostUrl - A url to the shared calendar. |
|
87 | + * * summary - Description of the share, can be the same as the |
|
88 | + * calendar, but may also be modified (optional). |
|
89 | + * |
|
90 | + * @param array $values |
|
91 | + */ |
|
92 | + public function __construct(array $values) { |
|
93 | + |
|
94 | + $required = [ |
|
95 | + 'id', |
|
96 | + 'etag', |
|
97 | + 'href', |
|
98 | + 'dtStamp', |
|
99 | + 'inReplyTo', |
|
100 | + 'type', |
|
101 | + 'hostUrl', |
|
102 | + ]; |
|
103 | + foreach ($required as $item) { |
|
104 | + if (!isset($values[$item])) { |
|
105 | + throw new \InvalidArgumentException($item . ' is a required constructor option'); |
|
106 | + } |
|
107 | + } |
|
108 | + |
|
109 | + foreach ($values as $key => $value) { |
|
110 | + if (!property_exists($this, $key)) { |
|
111 | + throw new \InvalidArgumentException('Unknown option: ' . $key); |
|
112 | + } |
|
113 | + $this->$key = $value; |
|
114 | + } |
|
115 | + |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * The xmlSerialize metod is called during xml writing. |
|
120 | + * |
|
121 | + * Use the $writer argument to write its own xml serialization. |
|
122 | + * |
|
123 | + * An important note: do _not_ create a parent element. Any element |
|
124 | + * implementing XmlSerializble should only ever write what's considered |
|
125 | + * its 'inner xml'. |
|
126 | + * |
|
127 | + * The parent of the current element is responsible for writing a |
|
128 | + * containing element. |
|
129 | + * |
|
130 | + * This allows serializers to be re-used for different element names. |
|
131 | + * |
|
132 | + * If you are opening new elements, you must also close them again. |
|
133 | + * |
|
134 | + * @param Writer $writer |
|
135 | + * @return void |
|
136 | + */ |
|
137 | + public function xmlSerialize(Writer $writer) { |
|
138 | + |
|
139 | + $writer->writeElement('{' . CalDAV\Plugin::NS_CALENDARSERVER . '}invite-reply'); |
|
140 | + |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * This method serializes the entire notification, as it is used in the |
|
145 | + * response body. |
|
146 | + * |
|
147 | + * @param Writer $writer |
|
148 | + * @return void |
|
149 | + */ |
|
150 | + public function xmlSerializeFull(Writer $writer) { |
|
151 | + |
|
152 | + $cs = '{' . CalDAV\Plugin::NS_CALENDARSERVER . '}'; |
|
153 | + |
|
154 | + $this->dtStamp->setTimezone(new \DateTimezone('GMT')); |
|
155 | + $writer->writeElement($cs . 'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); |
|
156 | + |
|
157 | + $writer->startElement($cs . 'invite-reply'); |
|
158 | + |
|
159 | + $writer->writeElement($cs . 'uid', $this->id); |
|
160 | + $writer->writeElement($cs . 'in-reply-to', $this->inReplyTo); |
|
161 | + $writer->writeElement('{DAV:}href', $this->href); |
|
162 | + |
|
163 | + switch ($this->type) { |
|
164 | + |
|
165 | + case SharingPlugin::STATUS_ACCEPTED : |
|
166 | + $writer->writeElement($cs . 'invite-accepted'); |
|
167 | + break; |
|
168 | + case SharingPlugin::STATUS_DECLINED : |
|
169 | + $writer->writeElement($cs . 'invite-declined'); |
|
170 | + break; |
|
171 | + |
|
172 | + } |
|
173 | + |
|
174 | + $writer->writeElement($cs . 'hosturl', [ |
|
175 | + '{DAV:}href' => $writer->contextUri . $this->hostUrl |
|
176 | + ]); |
|
177 | + |
|
178 | + if ($this->summary) { |
|
179 | + $writer->writeElement($cs . 'summary', $this->summary); |
|
180 | + } |
|
181 | + $writer->endElement(); // invite-reply |
|
182 | + |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * Returns a unique id for this notification |
|
187 | + * |
|
188 | + * This is just the base url. This should generally be some kind of unique |
|
189 | + * id. |
|
190 | + * |
|
191 | + * @return string |
|
192 | + */ |
|
193 | + public function getId() { |
|
194 | + |
|
195 | + return $this->id; |
|
196 | + |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * Returns the ETag for this notification. |
|
201 | + * |
|
202 | + * The ETag must be surrounded by literal double-quotes. |
|
203 | + * |
|
204 | + * @return string |
|
205 | + */ |
|
206 | + public function getETag() { |
|
207 | + |
|
208 | + return $this->etag; |
|
209 | + |
|
210 | + } |
|
211 | 211 | |
212 | 212 | } |
@@ -2,8 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Sabre\CalDAV\Xml\Notification; |
4 | 4 | |
5 | -use Sabre\Xml\Writer; |
|
6 | 5 | use Sabre\CalDAV\Plugin; |
6 | +use Sabre\Xml\Writer; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * SystemStatus notification |
@@ -17,166 +17,166 @@ |
||
17 | 17 | */ |
18 | 18 | class SystemStatus implements NotificationInterface { |
19 | 19 | |
20 | - const TYPE_LOW = 1; |
|
21 | - const TYPE_MEDIUM = 2; |
|
22 | - const TYPE_HIGH = 3; |
|
23 | - |
|
24 | - /** |
|
25 | - * A unique id |
|
26 | - * |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - protected $id; |
|
30 | - |
|
31 | - /** |
|
32 | - * The type of alert. This should be one of the TYPE_ constants. |
|
33 | - * |
|
34 | - * @var int |
|
35 | - */ |
|
36 | - protected $type; |
|
37 | - |
|
38 | - /** |
|
39 | - * A human-readable description of the problem. |
|
40 | - * |
|
41 | - * @var string |
|
42 | - */ |
|
43 | - protected $description; |
|
44 | - |
|
45 | - /** |
|
46 | - * A url to a website with more information for the user. |
|
47 | - * |
|
48 | - * @var string |
|
49 | - */ |
|
50 | - protected $href; |
|
51 | - |
|
52 | - /** |
|
53 | - * Notification Etag |
|
54 | - * |
|
55 | - * @var string |
|
56 | - */ |
|
57 | - protected $etag; |
|
58 | - |
|
59 | - /** |
|
60 | - * Creates the notification. |
|
61 | - * |
|
62 | - * Some kind of unique id should be provided. This is used to generate a |
|
63 | - * url. |
|
64 | - * |
|
65 | - * @param string $id |
|
66 | - * @param string $etag |
|
67 | - * @param int $type |
|
68 | - * @param string $description |
|
69 | - * @param string $href |
|
70 | - */ |
|
71 | - public function __construct($id, $etag, $type = self::TYPE_HIGH, $description = null, $href = null) { |
|
72 | - |
|
73 | - $this->id = $id; |
|
74 | - $this->type = $type; |
|
75 | - $this->description = $description; |
|
76 | - $this->href = $href; |
|
77 | - $this->etag = $etag; |
|
78 | - |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * The serialize method is called during xml writing. |
|
83 | - * |
|
84 | - * It should use the $writer argument to encode this object into XML. |
|
85 | - * |
|
86 | - * Important note: it is not needed to create the parent element. The |
|
87 | - * parent element is already created, and we only have to worry about |
|
88 | - * attributes, child elements and text (if any). |
|
89 | - * |
|
90 | - * Important note 2: If you are writing any new elements, you are also |
|
91 | - * responsible for closing them. |
|
92 | - * |
|
93 | - * @param Writer $writer |
|
94 | - * @return void |
|
95 | - */ |
|
96 | - public function xmlSerialize(Writer $writer) { |
|
97 | - |
|
98 | - switch ($this->type) { |
|
99 | - case self::TYPE_LOW : |
|
100 | - $type = 'low'; |
|
101 | - break; |
|
102 | - case self::TYPE_MEDIUM : |
|
103 | - $type = 'medium'; |
|
104 | - break; |
|
105 | - default : |
|
106 | - case self::TYPE_HIGH : |
|
107 | - $type = 'high'; |
|
108 | - break; |
|
109 | - } |
|
110 | - |
|
111 | - $writer->startElement('{' . Plugin::NS_CALENDARSERVER . '}systemstatus'); |
|
112 | - $writer->writeAttribute('type', $type); |
|
113 | - $writer->endElement(); |
|
114 | - |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * This method serializes the entire notification, as it is used in the |
|
119 | - * response body. |
|
120 | - * |
|
121 | - * @param Writer $writer |
|
122 | - * @return void |
|
123 | - */ |
|
124 | - public function xmlSerializeFull(Writer $writer) { |
|
125 | - |
|
126 | - $cs = '{' . Plugin::NS_CALENDARSERVER . '}'; |
|
127 | - switch ($this->type) { |
|
128 | - case self::TYPE_LOW : |
|
129 | - $type = 'low'; |
|
130 | - break; |
|
131 | - case self::TYPE_MEDIUM : |
|
132 | - $type = 'medium'; |
|
133 | - break; |
|
134 | - default : |
|
135 | - case self::TYPE_HIGH : |
|
136 | - $type = 'high'; |
|
137 | - break; |
|
138 | - } |
|
139 | - |
|
140 | - $writer->startElement($cs . 'systemstatus'); |
|
141 | - $writer->writeAttribute('type', $type); |
|
142 | - |
|
143 | - |
|
144 | - if ($this->description) { |
|
145 | - $writer->writeElement($cs . 'description', $this->description); |
|
146 | - } |
|
147 | - if ($this->href) { |
|
148 | - $writer->writeElement('{DAV:}href', $this->href); |
|
149 | - } |
|
150 | - |
|
151 | - $writer->endElement(); // systemstatus |
|
152 | - |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * Returns a unique id for this notification |
|
157 | - * |
|
158 | - * This is just the base url. This should generally be some kind of unique |
|
159 | - * id. |
|
160 | - * |
|
161 | - * @return string |
|
162 | - */ |
|
163 | - public function getId() { |
|
164 | - |
|
165 | - return $this->id; |
|
166 | - |
|
167 | - } |
|
168 | - |
|
169 | - /* |
|
20 | + const TYPE_LOW = 1; |
|
21 | + const TYPE_MEDIUM = 2; |
|
22 | + const TYPE_HIGH = 3; |
|
23 | + |
|
24 | + /** |
|
25 | + * A unique id |
|
26 | + * |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + protected $id; |
|
30 | + |
|
31 | + /** |
|
32 | + * The type of alert. This should be one of the TYPE_ constants. |
|
33 | + * |
|
34 | + * @var int |
|
35 | + */ |
|
36 | + protected $type; |
|
37 | + |
|
38 | + /** |
|
39 | + * A human-readable description of the problem. |
|
40 | + * |
|
41 | + * @var string |
|
42 | + */ |
|
43 | + protected $description; |
|
44 | + |
|
45 | + /** |
|
46 | + * A url to a website with more information for the user. |
|
47 | + * |
|
48 | + * @var string |
|
49 | + */ |
|
50 | + protected $href; |
|
51 | + |
|
52 | + /** |
|
53 | + * Notification Etag |
|
54 | + * |
|
55 | + * @var string |
|
56 | + */ |
|
57 | + protected $etag; |
|
58 | + |
|
59 | + /** |
|
60 | + * Creates the notification. |
|
61 | + * |
|
62 | + * Some kind of unique id should be provided. This is used to generate a |
|
63 | + * url. |
|
64 | + * |
|
65 | + * @param string $id |
|
66 | + * @param string $etag |
|
67 | + * @param int $type |
|
68 | + * @param string $description |
|
69 | + * @param string $href |
|
70 | + */ |
|
71 | + public function __construct($id, $etag, $type = self::TYPE_HIGH, $description = null, $href = null) { |
|
72 | + |
|
73 | + $this->id = $id; |
|
74 | + $this->type = $type; |
|
75 | + $this->description = $description; |
|
76 | + $this->href = $href; |
|
77 | + $this->etag = $etag; |
|
78 | + |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * The serialize method is called during xml writing. |
|
83 | + * |
|
84 | + * It should use the $writer argument to encode this object into XML. |
|
85 | + * |
|
86 | + * Important note: it is not needed to create the parent element. The |
|
87 | + * parent element is already created, and we only have to worry about |
|
88 | + * attributes, child elements and text (if any). |
|
89 | + * |
|
90 | + * Important note 2: If you are writing any new elements, you are also |
|
91 | + * responsible for closing them. |
|
92 | + * |
|
93 | + * @param Writer $writer |
|
94 | + * @return void |
|
95 | + */ |
|
96 | + public function xmlSerialize(Writer $writer) { |
|
97 | + |
|
98 | + switch ($this->type) { |
|
99 | + case self::TYPE_LOW : |
|
100 | + $type = 'low'; |
|
101 | + break; |
|
102 | + case self::TYPE_MEDIUM : |
|
103 | + $type = 'medium'; |
|
104 | + break; |
|
105 | + default : |
|
106 | + case self::TYPE_HIGH : |
|
107 | + $type = 'high'; |
|
108 | + break; |
|
109 | + } |
|
110 | + |
|
111 | + $writer->startElement('{' . Plugin::NS_CALENDARSERVER . '}systemstatus'); |
|
112 | + $writer->writeAttribute('type', $type); |
|
113 | + $writer->endElement(); |
|
114 | + |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * This method serializes the entire notification, as it is used in the |
|
119 | + * response body. |
|
120 | + * |
|
121 | + * @param Writer $writer |
|
122 | + * @return void |
|
123 | + */ |
|
124 | + public function xmlSerializeFull(Writer $writer) { |
|
125 | + |
|
126 | + $cs = '{' . Plugin::NS_CALENDARSERVER . '}'; |
|
127 | + switch ($this->type) { |
|
128 | + case self::TYPE_LOW : |
|
129 | + $type = 'low'; |
|
130 | + break; |
|
131 | + case self::TYPE_MEDIUM : |
|
132 | + $type = 'medium'; |
|
133 | + break; |
|
134 | + default : |
|
135 | + case self::TYPE_HIGH : |
|
136 | + $type = 'high'; |
|
137 | + break; |
|
138 | + } |
|
139 | + |
|
140 | + $writer->startElement($cs . 'systemstatus'); |
|
141 | + $writer->writeAttribute('type', $type); |
|
142 | + |
|
143 | + |
|
144 | + if ($this->description) { |
|
145 | + $writer->writeElement($cs . 'description', $this->description); |
|
146 | + } |
|
147 | + if ($this->href) { |
|
148 | + $writer->writeElement('{DAV:}href', $this->href); |
|
149 | + } |
|
150 | + |
|
151 | + $writer->endElement(); // systemstatus |
|
152 | + |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * Returns a unique id for this notification |
|
157 | + * |
|
158 | + * This is just the base url. This should generally be some kind of unique |
|
159 | + * id. |
|
160 | + * |
|
161 | + * @return string |
|
162 | + */ |
|
163 | + public function getId() { |
|
164 | + |
|
165 | + return $this->id; |
|
166 | + |
|
167 | + } |
|
168 | + |
|
169 | + /* |
|
170 | 170 | * Returns the ETag for this notification. |
171 | 171 | * |
172 | 172 | * The ETag must be surrounded by literal double-quotes. |
173 | 173 | * |
174 | 174 | * @return string |
175 | 175 | */ |
176 | - public function getETag() { |
|
176 | + public function getETag() { |
|
177 | 177 | |
178 | - return $this->etag; |
|
178 | + return $this->etag; |
|
179 | 179 | |
180 | - } |
|
180 | + } |
|
181 | 181 | |
182 | 182 | } |
@@ -2,9 +2,9 @@ |
||
2 | 2 | |
3 | 3 | namespace Sabre\CalDAV\Xml\Property; |
4 | 4 | |
5 | -use Sabre\Xml\XmlSerializable; |
|
6 | -use Sabre\Xml\Writer; |
|
7 | 5 | use Sabre\CalDAV\Plugin; |
6 | +use Sabre\Xml\Writer; |
|
7 | +use Sabre\Xml\XmlSerializable; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * AllowedSharingModes |
@@ -24,63 +24,63 @@ |
||
24 | 24 | */ |
25 | 25 | class AllowedSharingModes implements XmlSerializable { |
26 | 26 | |
27 | - /** |
|
28 | - * Whether or not a calendar can be shared with another user |
|
29 | - * |
|
30 | - * @var bool |
|
31 | - */ |
|
32 | - protected $canBeShared; |
|
27 | + /** |
|
28 | + * Whether or not a calendar can be shared with another user |
|
29 | + * |
|
30 | + * @var bool |
|
31 | + */ |
|
32 | + protected $canBeShared; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Whether or not the calendar can be placed on a public url. |
|
36 | - * |
|
37 | - * @var bool |
|
38 | - */ |
|
39 | - protected $canBePublished; |
|
34 | + /** |
|
35 | + * Whether or not the calendar can be placed on a public url. |
|
36 | + * |
|
37 | + * @var bool |
|
38 | + */ |
|
39 | + protected $canBePublished; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Constructor |
|
43 | - * |
|
44 | - * @param bool $canBeShared |
|
45 | - * @param bool $canBePublished |
|
46 | - * @return void |
|
47 | - */ |
|
48 | - public function __construct($canBeShared, $canBePublished) { |
|
41 | + /** |
|
42 | + * Constructor |
|
43 | + * |
|
44 | + * @param bool $canBeShared |
|
45 | + * @param bool $canBePublished |
|
46 | + * @return void |
|
47 | + */ |
|
48 | + public function __construct($canBeShared, $canBePublished) { |
|
49 | 49 | |
50 | - $this->canBeShared = $canBeShared; |
|
51 | - $this->canBePublished = $canBePublished; |
|
50 | + $this->canBeShared = $canBeShared; |
|
51 | + $this->canBePublished = $canBePublished; |
|
52 | 52 | |
53 | - } |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * The xmlSerialize metod is called during xml writing. |
|
57 | - * |
|
58 | - * Use the $writer argument to write its own xml serialization. |
|
59 | - * |
|
60 | - * An important note: do _not_ create a parent element. Any element |
|
61 | - * implementing XmlSerializble should only ever write what's considered |
|
62 | - * its 'inner xml'. |
|
63 | - * |
|
64 | - * The parent of the current element is responsible for writing a |
|
65 | - * containing element. |
|
66 | - * |
|
67 | - * This allows serializers to be re-used for different element names. |
|
68 | - * |
|
69 | - * If you are opening new elements, you must also close them again. |
|
70 | - * |
|
71 | - * @param Writer $writer |
|
72 | - * @return void |
|
73 | - */ |
|
74 | - public function xmlSerialize(Writer $writer) { |
|
55 | + /** |
|
56 | + * The xmlSerialize metod is called during xml writing. |
|
57 | + * |
|
58 | + * Use the $writer argument to write its own xml serialization. |
|
59 | + * |
|
60 | + * An important note: do _not_ create a parent element. Any element |
|
61 | + * implementing XmlSerializble should only ever write what's considered |
|
62 | + * its 'inner xml'. |
|
63 | + * |
|
64 | + * The parent of the current element is responsible for writing a |
|
65 | + * containing element. |
|
66 | + * |
|
67 | + * This allows serializers to be re-used for different element names. |
|
68 | + * |
|
69 | + * If you are opening new elements, you must also close them again. |
|
70 | + * |
|
71 | + * @param Writer $writer |
|
72 | + * @return void |
|
73 | + */ |
|
74 | + public function xmlSerialize(Writer $writer) { |
|
75 | 75 | |
76 | - if ($this->canBeShared) { |
|
77 | - $writer->writeElement('{' . Plugin::NS_CALENDARSERVER . '}can-be-shared'); |
|
78 | - } |
|
79 | - if ($this->canBePublished) { |
|
80 | - $writer->writeElement('{' . Plugin::NS_CALENDARSERVER . '}can-be-published'); |
|
81 | - } |
|
76 | + if ($this->canBeShared) { |
|
77 | + $writer->writeElement('{' . Plugin::NS_CALENDARSERVER . '}can-be-shared'); |
|
78 | + } |
|
79 | + if ($this->canBePublished) { |
|
80 | + $writer->writeElement('{' . Plugin::NS_CALENDARSERVER . '}can-be-published'); |
|
81 | + } |
|
82 | 82 | |
83 | - } |
|
83 | + } |
|
84 | 84 | |
85 | 85 | |
86 | 86 |
@@ -182,7 +182,7 @@ |
||
182 | 182 | * the next element. |
183 | 183 | * |
184 | 184 | * @param Reader $reader |
185 | - * @return mixed |
|
185 | + * @return Invite |
|
186 | 186 | */ |
187 | 187 | static function xmlDeserialize(Reader $reader) { |
188 | 188 |
@@ -2,11 +2,11 @@ |
||
2 | 2 | |
3 | 3 | namespace Sabre\CalDAV\Xml\Property; |
4 | 4 | |
5 | +use Sabre\CalDAV\Plugin; |
|
6 | +use Sabre\CalDAV\SharingPlugin; |
|
5 | 7 | use Sabre\Xml\Element; |
6 | 8 | use Sabre\Xml\Reader; |
7 | 9 | use Sabre\Xml\Writer; |
8 | -use Sabre\CalDAV\Plugin; |
|
9 | -use Sabre\CalDAV\SharingPlugin; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Invite property |
@@ -192,8 +192,9 @@ |
||
192 | 192 | |
193 | 193 | foreach ($reader->parseInnerTree() as $elem) { |
194 | 194 | |
195 | - if ($elem['name'] !== $cs . 'user') |
|
196 | - continue; |
|
195 | + if ($elem['name'] !== $cs . 'user') { |
|
196 | + continue; |
|
197 | + } |
|
197 | 198 | |
198 | 199 | $user = [ |
199 | 200 | 'href' => null, |
@@ -22,231 +22,231 @@ |
||
22 | 22 | */ |
23 | 23 | class Invite implements Element { |
24 | 24 | |
25 | - /** |
|
26 | - * The list of users a calendar has been shared to. |
|
27 | - * |
|
28 | - * @var array |
|
29 | - */ |
|
30 | - protected $users; |
|
31 | - |
|
32 | - /** |
|
33 | - * The organizer contains information about the person who shared the |
|
34 | - * object. |
|
35 | - * |
|
36 | - * @var array |
|
37 | - */ |
|
38 | - protected $organizer; |
|
39 | - |
|
40 | - /** |
|
41 | - * Creates the property. |
|
42 | - * |
|
43 | - * Users is an array. Each element of the array has the following |
|
44 | - * properties: |
|
45 | - * |
|
46 | - * * href - Often a mailto: address |
|
47 | - * * commonName - Optional, for example a first and lastname for a user. |
|
48 | - * * status - One of the SharingPlugin::STATUS_* constants. |
|
49 | - * * readOnly - true or false |
|
50 | - * * summary - Optional, description of the share |
|
51 | - * |
|
52 | - * The organizer key is optional to specify. It's only useful when a |
|
53 | - * 'sharee' requests the sharing information. |
|
54 | - * |
|
55 | - * The organizer may have the following properties: |
|
56 | - * * href - Often a mailto: address. |
|
57 | - * * commonName - Optional human-readable name. |
|
58 | - * * firstName - Optional first name. |
|
59 | - * * lastName - Optional last name. |
|
60 | - * |
|
61 | - * If you wonder why these two structures are so different, I guess a |
|
62 | - * valid answer is that the current spec is still a draft. |
|
63 | - * |
|
64 | - * @param array $users |
|
65 | - */ |
|
66 | - public function __construct(array $users, array $organizer = null) { |
|
67 | - |
|
68 | - $this->users = $users; |
|
69 | - $this->organizer = $organizer; |
|
70 | - |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * Returns the list of users, as it was passed to the constructor. |
|
75 | - * |
|
76 | - * @return array |
|
77 | - */ |
|
78 | - public function getValue() { |
|
79 | - |
|
80 | - return $this->users; |
|
81 | - |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * The xmlSerialize metod is called during xml writing. |
|
86 | - * |
|
87 | - * Use the $writer argument to write its own xml serialization. |
|
88 | - * |
|
89 | - * An important note: do _not_ create a parent element. Any element |
|
90 | - * implementing XmlSerializble should only ever write what's considered |
|
91 | - * its 'inner xml'. |
|
92 | - * |
|
93 | - * The parent of the current element is responsible for writing a |
|
94 | - * containing element. |
|
95 | - * |
|
96 | - * This allows serializers to be re-used for different element names. |
|
97 | - * |
|
98 | - * If you are opening new elements, you must also close them again. |
|
99 | - * |
|
100 | - * @param Writer $writer |
|
101 | - * @return void |
|
102 | - */ |
|
103 | - public function xmlSerialize(Writer $writer) { |
|
104 | - |
|
105 | - $cs = '{' . Plugin::NS_CALENDARSERVER . '}'; |
|
106 | - |
|
107 | - if (!is_null($this->organizer)) { |
|
108 | - |
|
109 | - $writer->startElement($cs . 'organizer'); |
|
110 | - $writer->writeElement('{DAV:}href', $this->organizer['href']); |
|
111 | - |
|
112 | - if (isset($this->organizer['commonName']) && $this->organizer['commonName']) { |
|
113 | - $writer->writeElement($cs . 'common-name', $this->organizer['commonName']); |
|
114 | - } |
|
115 | - if (isset($this->organizer['firstName']) && $this->organizer['firstName']) { |
|
116 | - $writer->writeElement($cs . 'first-name', $this->organizer['firstName']); |
|
117 | - } |
|
118 | - if (isset($this->organizer['lastName']) && $this->organizer['lastName']) { |
|
119 | - $writer->writeElement($cs . 'last-name', $this->organizer['lastName']); |
|
120 | - } |
|
121 | - $writer->endElement(); // organizer |
|
122 | - |
|
123 | - } |
|
124 | - |
|
125 | - foreach ($this->users as $user) { |
|
126 | - |
|
127 | - $writer->startElement($cs . 'user'); |
|
128 | - $writer->writeElement('{DAV:}href', $user['href']); |
|
129 | - if (isset($user['commonName']) && $user['commonName']) { |
|
130 | - $writer->writeElement($cs . 'common-name', $user['commonName']); |
|
131 | - } |
|
132 | - switch ($user['status']) { |
|
133 | - |
|
134 | - case SharingPlugin::STATUS_ACCEPTED : |
|
135 | - $writer->writeElement($cs . 'invite-accepted'); |
|
136 | - break; |
|
137 | - case SharingPlugin::STATUS_DECLINED : |
|
138 | - $writer->writeElement($cs . 'invite-declined'); |
|
139 | - break; |
|
140 | - case SharingPlugin::STATUS_NORESPONSE : |
|
141 | - $writer->writeElement($cs . 'invite-noresponse'); |
|
142 | - break; |
|
143 | - case SharingPlugin::STATUS_INVALID : |
|
144 | - $writer->writeElement($cs . 'invite-invalid'); |
|
145 | - break; |
|
146 | - } |
|
147 | - |
|
148 | - $writer->startElement($cs . 'access'); |
|
149 | - if ($user['readOnly']) { |
|
150 | - $writer->writeElement($cs . 'read'); |
|
151 | - } else { |
|
152 | - $writer->writeElement($cs . 'read-write'); |
|
153 | - } |
|
154 | - $writer->endElement(); // access |
|
155 | - |
|
156 | - if (isset($user['summary']) && $user['summary']) { |
|
157 | - $writer->writeElement($cs . 'summary', $user['summary']); |
|
158 | - } |
|
159 | - |
|
160 | - $writer->endElement(); //user |
|
161 | - |
|
162 | - } |
|
163 | - |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * The deserialize method is called during xml parsing. |
|
168 | - * |
|
169 | - * This method is called statictly, this is because in theory this method |
|
170 | - * may be used as a type of constructor, or factory method. |
|
171 | - * |
|
172 | - * Often you want to return an instance of the current class, but you are |
|
173 | - * free to return other data as well. |
|
174 | - * |
|
175 | - * You are responsible for advancing the reader to the next element. Not |
|
176 | - * doing anything will result in a never-ending loop. |
|
177 | - * |
|
178 | - * If you just want to skip parsing for this element altogether, you can |
|
179 | - * just call $reader->next(); |
|
180 | - * |
|
181 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
182 | - * the next element. |
|
183 | - * |
|
184 | - * @param Reader $reader |
|
185 | - * @return mixed |
|
186 | - */ |
|
187 | - static function xmlDeserialize(Reader $reader) { |
|
188 | - |
|
189 | - $cs = '{' . Plugin::NS_CALENDARSERVER . '}'; |
|
190 | - |
|
191 | - $users = []; |
|
192 | - |
|
193 | - foreach ($reader->parseInnerTree() as $elem) { |
|
194 | - |
|
195 | - if ($elem['name'] !== $cs . 'user') |
|
196 | - continue; |
|
197 | - |
|
198 | - $user = [ |
|
199 | - 'href' => null, |
|
200 | - 'commonName' => null, |
|
201 | - 'readOnly' => null, |
|
202 | - 'summary' => null, |
|
203 | - 'status' => null, |
|
204 | - ]; |
|
205 | - |
|
206 | - foreach ($elem['value'] as $userElem) { |
|
207 | - |
|
208 | - switch ($userElem['name']) { |
|
209 | - case $cs . 'invite-accepted' : |
|
210 | - $user['status'] = SharingPlugin::STATUS_ACCEPTED; |
|
211 | - break; |
|
212 | - case $cs . 'invite-declined' : |
|
213 | - $user['status'] = SharingPlugin::STATUS_DECLINED; |
|
214 | - break; |
|
215 | - case $cs . 'invite-noresponse' : |
|
216 | - $user['status'] = SharingPlugin::STATUS_NORESPONSE; |
|
217 | - break; |
|
218 | - case $cs . 'invite-invalid' : |
|
219 | - $user['status'] = SharingPlugin::STATUS_INVALID; |
|
220 | - break; |
|
221 | - case '{DAV:}href' : |
|
222 | - $user['href'] = $userElem['value']; |
|
223 | - break; |
|
224 | - case $cs . 'common-name' : |
|
225 | - $user['commonName'] = $userElem['value']; |
|
226 | - break; |
|
227 | - case $cs . 'access' : |
|
228 | - foreach ($userElem['value'] as $accessHref) { |
|
229 | - if ($accessHref['name'] === $cs . 'read') { |
|
230 | - $user['readOnly'] = true; |
|
231 | - } |
|
232 | - } |
|
233 | - break; |
|
234 | - case $cs . 'summary' : |
|
235 | - $user['summary'] = $userElem['value']; |
|
236 | - break; |
|
237 | - |
|
238 | - } |
|
239 | - |
|
240 | - } |
|
241 | - if (!$user['status']) { |
|
242 | - throw new \InvalidArgumentException('Every user must have one of cs:invite-accepted, cs:invite-declined, cs:invite-noresponse or cs:invite-invalid'); |
|
243 | - } |
|
244 | - |
|
245 | - $users[] = $user; |
|
246 | - |
|
247 | - } |
|
248 | - |
|
249 | - return new self($users); |
|
250 | - |
|
251 | - } |
|
25 | + /** |
|
26 | + * The list of users a calendar has been shared to. |
|
27 | + * |
|
28 | + * @var array |
|
29 | + */ |
|
30 | + protected $users; |
|
31 | + |
|
32 | + /** |
|
33 | + * The organizer contains information about the person who shared the |
|
34 | + * object. |
|
35 | + * |
|
36 | + * @var array |
|
37 | + */ |
|
38 | + protected $organizer; |
|
39 | + |
|
40 | + /** |
|
41 | + * Creates the property. |
|
42 | + * |
|
43 | + * Users is an array. Each element of the array has the following |
|
44 | + * properties: |
|
45 | + * |
|
46 | + * * href - Often a mailto: address |
|
47 | + * * commonName - Optional, for example a first and lastname for a user. |
|
48 | + * * status - One of the SharingPlugin::STATUS_* constants. |
|
49 | + * * readOnly - true or false |
|
50 | + * * summary - Optional, description of the share |
|
51 | + * |
|
52 | + * The organizer key is optional to specify. It's only useful when a |
|
53 | + * 'sharee' requests the sharing information. |
|
54 | + * |
|
55 | + * The organizer may have the following properties: |
|
56 | + * * href - Often a mailto: address. |
|
57 | + * * commonName - Optional human-readable name. |
|
58 | + * * firstName - Optional first name. |
|
59 | + * * lastName - Optional last name. |
|
60 | + * |
|
61 | + * If you wonder why these two structures are so different, I guess a |
|
62 | + * valid answer is that the current spec is still a draft. |
|
63 | + * |
|
64 | + * @param array $users |
|
65 | + */ |
|
66 | + public function __construct(array $users, array $organizer = null) { |
|
67 | + |
|
68 | + $this->users = $users; |
|
69 | + $this->organizer = $organizer; |
|
70 | + |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * Returns the list of users, as it was passed to the constructor. |
|
75 | + * |
|
76 | + * @return array |
|
77 | + */ |
|
78 | + public function getValue() { |
|
79 | + |
|
80 | + return $this->users; |
|
81 | + |
|
82 | + } |
|
83 | + |
|
84 | + /** |
|
85 | + * The xmlSerialize metod is called during xml writing. |
|
86 | + * |
|
87 | + * Use the $writer argument to write its own xml serialization. |
|
88 | + * |
|
89 | + * An important note: do _not_ create a parent element. Any element |
|
90 | + * implementing XmlSerializble should only ever write what's considered |
|
91 | + * its 'inner xml'. |
|
92 | + * |
|
93 | + * The parent of the current element is responsible for writing a |
|
94 | + * containing element. |
|
95 | + * |
|
96 | + * This allows serializers to be re-used for different element names. |
|
97 | + * |
|
98 | + * If you are opening new elements, you must also close them again. |
|
99 | + * |
|
100 | + * @param Writer $writer |
|
101 | + * @return void |
|
102 | + */ |
|
103 | + public function xmlSerialize(Writer $writer) { |
|
104 | + |
|
105 | + $cs = '{' . Plugin::NS_CALENDARSERVER . '}'; |
|
106 | + |
|
107 | + if (!is_null($this->organizer)) { |
|
108 | + |
|
109 | + $writer->startElement($cs . 'organizer'); |
|
110 | + $writer->writeElement('{DAV:}href', $this->organizer['href']); |
|
111 | + |
|
112 | + if (isset($this->organizer['commonName']) && $this->organizer['commonName']) { |
|
113 | + $writer->writeElement($cs . 'common-name', $this->organizer['commonName']); |
|
114 | + } |
|
115 | + if (isset($this->organizer['firstName']) && $this->organizer['firstName']) { |
|
116 | + $writer->writeElement($cs . 'first-name', $this->organizer['firstName']); |
|
117 | + } |
|
118 | + if (isset($this->organizer['lastName']) && $this->organizer['lastName']) { |
|
119 | + $writer->writeElement($cs . 'last-name', $this->organizer['lastName']); |
|
120 | + } |
|
121 | + $writer->endElement(); // organizer |
|
122 | + |
|
123 | + } |
|
124 | + |
|
125 | + foreach ($this->users as $user) { |
|
126 | + |
|
127 | + $writer->startElement($cs . 'user'); |
|
128 | + $writer->writeElement('{DAV:}href', $user['href']); |
|
129 | + if (isset($user['commonName']) && $user['commonName']) { |
|
130 | + $writer->writeElement($cs . 'common-name', $user['commonName']); |
|
131 | + } |
|
132 | + switch ($user['status']) { |
|
133 | + |
|
134 | + case SharingPlugin::STATUS_ACCEPTED : |
|
135 | + $writer->writeElement($cs . 'invite-accepted'); |
|
136 | + break; |
|
137 | + case SharingPlugin::STATUS_DECLINED : |
|
138 | + $writer->writeElement($cs . 'invite-declined'); |
|
139 | + break; |
|
140 | + case SharingPlugin::STATUS_NORESPONSE : |
|
141 | + $writer->writeElement($cs . 'invite-noresponse'); |
|
142 | + break; |
|
143 | + case SharingPlugin::STATUS_INVALID : |
|
144 | + $writer->writeElement($cs . 'invite-invalid'); |
|
145 | + break; |
|
146 | + } |
|
147 | + |
|
148 | + $writer->startElement($cs . 'access'); |
|
149 | + if ($user['readOnly']) { |
|
150 | + $writer->writeElement($cs . 'read'); |
|
151 | + } else { |
|
152 | + $writer->writeElement($cs . 'read-write'); |
|
153 | + } |
|
154 | + $writer->endElement(); // access |
|
155 | + |
|
156 | + if (isset($user['summary']) && $user['summary']) { |
|
157 | + $writer->writeElement($cs . 'summary', $user['summary']); |
|
158 | + } |
|
159 | + |
|
160 | + $writer->endElement(); //user |
|
161 | + |
|
162 | + } |
|
163 | + |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * The deserialize method is called during xml parsing. |
|
168 | + * |
|
169 | + * This method is called statictly, this is because in theory this method |
|
170 | + * may be used as a type of constructor, or factory method. |
|
171 | + * |
|
172 | + * Often you want to return an instance of the current class, but you are |
|
173 | + * free to return other data as well. |
|
174 | + * |
|
175 | + * You are responsible for advancing the reader to the next element. Not |
|
176 | + * doing anything will result in a never-ending loop. |
|
177 | + * |
|
178 | + * If you just want to skip parsing for this element altogether, you can |
|
179 | + * just call $reader->next(); |
|
180 | + * |
|
181 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
182 | + * the next element. |
|
183 | + * |
|
184 | + * @param Reader $reader |
|
185 | + * @return mixed |
|
186 | + */ |
|
187 | + static function xmlDeserialize(Reader $reader) { |
|
188 | + |
|
189 | + $cs = '{' . Plugin::NS_CALENDARSERVER . '}'; |
|
190 | + |
|
191 | + $users = []; |
|
192 | + |
|
193 | + foreach ($reader->parseInnerTree() as $elem) { |
|
194 | + |
|
195 | + if ($elem['name'] !== $cs . 'user') |
|
196 | + continue; |
|
197 | + |
|
198 | + $user = [ |
|
199 | + 'href' => null, |
|
200 | + 'commonName' => null, |
|
201 | + 'readOnly' => null, |
|
202 | + 'summary' => null, |
|
203 | + 'status' => null, |
|
204 | + ]; |
|
205 | + |
|
206 | + foreach ($elem['value'] as $userElem) { |
|
207 | + |
|
208 | + switch ($userElem['name']) { |
|
209 | + case $cs . 'invite-accepted' : |
|
210 | + $user['status'] = SharingPlugin::STATUS_ACCEPTED; |
|
211 | + break; |
|
212 | + case $cs . 'invite-declined' : |
|
213 | + $user['status'] = SharingPlugin::STATUS_DECLINED; |
|
214 | + break; |
|
215 | + case $cs . 'invite-noresponse' : |
|
216 | + $user['status'] = SharingPlugin::STATUS_NORESPONSE; |
|
217 | + break; |
|
218 | + case $cs . 'invite-invalid' : |
|
219 | + $user['status'] = SharingPlugin::STATUS_INVALID; |
|
220 | + break; |
|
221 | + case '{DAV:}href' : |
|
222 | + $user['href'] = $userElem['value']; |
|
223 | + break; |
|
224 | + case $cs . 'common-name' : |
|
225 | + $user['commonName'] = $userElem['value']; |
|
226 | + break; |
|
227 | + case $cs . 'access' : |
|
228 | + foreach ($userElem['value'] as $accessHref) { |
|
229 | + if ($accessHref['name'] === $cs . 'read') { |
|
230 | + $user['readOnly'] = true; |
|
231 | + } |
|
232 | + } |
|
233 | + break; |
|
234 | + case $cs . 'summary' : |
|
235 | + $user['summary'] = $userElem['value']; |
|
236 | + break; |
|
237 | + |
|
238 | + } |
|
239 | + |
|
240 | + } |
|
241 | + if (!$user['status']) { |
|
242 | + throw new \InvalidArgumentException('Every user must have one of cs:invite-accepted, cs:invite-declined, cs:invite-noresponse or cs:invite-invalid'); |
|
243 | + } |
|
244 | + |
|
245 | + $users[] = $user; |
|
246 | + |
|
247 | + } |
|
248 | + |
|
249 | + return new self($users); |
|
250 | + |
|
251 | + } |
|
252 | 252 | } |
@@ -112,7 +112,7 @@ |
||
112 | 112 | * the next element. |
113 | 113 | * |
114 | 114 | * @param Reader $reader |
115 | - * @return mixed |
|
115 | + * @return null|ScheduleCalendarTransp |
|
116 | 116 | */ |
117 | 117 | static function xmlDeserialize(Reader $reader) { |
118 | 118 |
@@ -2,11 +2,11 @@ |
||
2 | 2 | |
3 | 3 | namespace Sabre\CalDAV\Xml\Property; |
4 | 4 | |
5 | +use Sabre\CalDAV\Plugin; |
|
5 | 6 | use Sabre\Xml\Element; |
7 | +use Sabre\Xml\Element\Elements; |
|
6 | 8 | use Sabre\Xml\Reader; |
7 | 9 | use Sabre\Xml\Writer; |
8 | -use Sabre\Xml\Element\Elements; |
|
9 | -use Sabre\CalDAV\Plugin; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * schedule-calendar-transp property. |
@@ -130,8 +130,9 @@ |
||
130 | 130 | break; |
131 | 131 | } |
132 | 132 | } |
133 | - if (is_null($value)) |
|
134 | - return null; |
|
133 | + if (is_null($value)) { |
|
134 | + return null; |
|
135 | + } |
|
135 | 136 | |
136 | 137 | return new self($value); |
137 | 138 |
@@ -26,115 +26,115 @@ |
||
26 | 26 | */ |
27 | 27 | class ScheduleCalendarTransp implements Element { |
28 | 28 | |
29 | - const TRANSPARENT = 'transparent'; |
|
30 | - const OPAQUE = 'opaque'; |
|
31 | - |
|
32 | - /** |
|
33 | - * value |
|
34 | - * |
|
35 | - * @var string |
|
36 | - */ |
|
37 | - protected $value; |
|
38 | - |
|
39 | - /** |
|
40 | - * Creates the property |
|
41 | - * |
|
42 | - * @param string $value |
|
43 | - */ |
|
44 | - public function __construct($value) { |
|
45 | - |
|
46 | - if ($value !== self::TRANSPARENT && $value !== self::OPAQUE) { |
|
47 | - throw new \InvalidArgumentException('The value must either be specified as "transparent" or "opaque"'); |
|
48 | - } |
|
49 | - $this->value = $value; |
|
50 | - |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * Returns the current value |
|
55 | - * |
|
56 | - * @return string |
|
57 | - */ |
|
58 | - public function getValue() { |
|
59 | - |
|
60 | - return $this->value; |
|
61 | - |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * The xmlSerialize metod is called during xml writing. |
|
66 | - * |
|
67 | - * Use the $writer argument to write its own xml serialization. |
|
68 | - * |
|
69 | - * An important note: do _not_ create a parent element. Any element |
|
70 | - * implementing XmlSerializble should only ever write what's considered |
|
71 | - * its 'inner xml'. |
|
72 | - * |
|
73 | - * The parent of the current element is responsible for writing a |
|
74 | - * containing element. |
|
75 | - * |
|
76 | - * This allows serializers to be re-used for different element names. |
|
77 | - * |
|
78 | - * If you are opening new elements, you must also close them again. |
|
79 | - * |
|
80 | - * @param Writer $writer |
|
81 | - * @return void |
|
82 | - */ |
|
83 | - public function xmlSerialize(Writer $writer) { |
|
84 | - |
|
85 | - switch ($this->value) { |
|
86 | - case self::TRANSPARENT : |
|
87 | - $writer->writeElement('{' . Plugin::NS_CALDAV . '}transparent'); |
|
88 | - break; |
|
89 | - case self::OPAQUE : |
|
90 | - $writer->writeElement('{' . Plugin::NS_CALDAV . '}opaque'); |
|
91 | - break; |
|
92 | - } |
|
93 | - |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * The deserialize method is called during xml parsing. |
|
98 | - * |
|
99 | - * This method is called statictly, this is because in theory this method |
|
100 | - * may be used as a type of constructor, or factory method. |
|
101 | - * |
|
102 | - * Often you want to return an instance of the current class, but you are |
|
103 | - * free to return other data as well. |
|
104 | - * |
|
105 | - * You are responsible for advancing the reader to the next element. Not |
|
106 | - * doing anything will result in a never-ending loop. |
|
107 | - * |
|
108 | - * If you just want to skip parsing for this element altogether, you can |
|
109 | - * just call $reader->next(); |
|
110 | - * |
|
111 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
112 | - * the next element. |
|
113 | - * |
|
114 | - * @param Reader $reader |
|
115 | - * @return mixed |
|
116 | - */ |
|
117 | - static function xmlDeserialize(Reader $reader) { |
|
118 | - |
|
119 | - $elems = Elements::xmlDeserialize($reader); |
|
120 | - |
|
121 | - $value = null; |
|
122 | - |
|
123 | - foreach ($elems as $elem) { |
|
124 | - switch ($elem) { |
|
125 | - case '{' . Plugin::NS_CALDAV . '}opaque' : |
|
126 | - $value = self::OPAQUE; |
|
127 | - break; |
|
128 | - case '{' . Plugin::NS_CALDAV . '}transparent' : |
|
129 | - $value = self::TRANSPARENT; |
|
130 | - break; |
|
131 | - } |
|
132 | - } |
|
133 | - if (is_null($value)) |
|
134 | - return null; |
|
135 | - |
|
136 | - return new self($value); |
|
137 | - |
|
138 | - } |
|
29 | + const TRANSPARENT = 'transparent'; |
|
30 | + const OPAQUE = 'opaque'; |
|
31 | + |
|
32 | + /** |
|
33 | + * value |
|
34 | + * |
|
35 | + * @var string |
|
36 | + */ |
|
37 | + protected $value; |
|
38 | + |
|
39 | + /** |
|
40 | + * Creates the property |
|
41 | + * |
|
42 | + * @param string $value |
|
43 | + */ |
|
44 | + public function __construct($value) { |
|
45 | + |
|
46 | + if ($value !== self::TRANSPARENT && $value !== self::OPAQUE) { |
|
47 | + throw new \InvalidArgumentException('The value must either be specified as "transparent" or "opaque"'); |
|
48 | + } |
|
49 | + $this->value = $value; |
|
50 | + |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * Returns the current value |
|
55 | + * |
|
56 | + * @return string |
|
57 | + */ |
|
58 | + public function getValue() { |
|
59 | + |
|
60 | + return $this->value; |
|
61 | + |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * The xmlSerialize metod is called during xml writing. |
|
66 | + * |
|
67 | + * Use the $writer argument to write its own xml serialization. |
|
68 | + * |
|
69 | + * An important note: do _not_ create a parent element. Any element |
|
70 | + * implementing XmlSerializble should only ever write what's considered |
|
71 | + * its 'inner xml'. |
|
72 | + * |
|
73 | + * The parent of the current element is responsible for writing a |
|
74 | + * containing element. |
|
75 | + * |
|
76 | + * This allows serializers to be re-used for different element names. |
|
77 | + * |
|
78 | + * If you are opening new elements, you must also close them again. |
|
79 | + * |
|
80 | + * @param Writer $writer |
|
81 | + * @return void |
|
82 | + */ |
|
83 | + public function xmlSerialize(Writer $writer) { |
|
84 | + |
|
85 | + switch ($this->value) { |
|
86 | + case self::TRANSPARENT : |
|
87 | + $writer->writeElement('{' . Plugin::NS_CALDAV . '}transparent'); |
|
88 | + break; |
|
89 | + case self::OPAQUE : |
|
90 | + $writer->writeElement('{' . Plugin::NS_CALDAV . '}opaque'); |
|
91 | + break; |
|
92 | + } |
|
93 | + |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * The deserialize method is called during xml parsing. |
|
98 | + * |
|
99 | + * This method is called statictly, this is because in theory this method |
|
100 | + * may be used as a type of constructor, or factory method. |
|
101 | + * |
|
102 | + * Often you want to return an instance of the current class, but you are |
|
103 | + * free to return other data as well. |
|
104 | + * |
|
105 | + * You are responsible for advancing the reader to the next element. Not |
|
106 | + * doing anything will result in a never-ending loop. |
|
107 | + * |
|
108 | + * If you just want to skip parsing for this element altogether, you can |
|
109 | + * just call $reader->next(); |
|
110 | + * |
|
111 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
112 | + * the next element. |
|
113 | + * |
|
114 | + * @param Reader $reader |
|
115 | + * @return mixed |
|
116 | + */ |
|
117 | + static function xmlDeserialize(Reader $reader) { |
|
118 | + |
|
119 | + $elems = Elements::xmlDeserialize($reader); |
|
120 | + |
|
121 | + $value = null; |
|
122 | + |
|
123 | + foreach ($elems as $elem) { |
|
124 | + switch ($elem) { |
|
125 | + case '{' . Plugin::NS_CALDAV . '}opaque' : |
|
126 | + $value = self::OPAQUE; |
|
127 | + break; |
|
128 | + case '{' . Plugin::NS_CALDAV . '}transparent' : |
|
129 | + $value = self::TRANSPARENT; |
|
130 | + break; |
|
131 | + } |
|
132 | + } |
|
133 | + if (is_null($value)) |
|
134 | + return null; |
|
135 | + |
|
136 | + return new self($value); |
|
137 | + |
|
138 | + } |
|
139 | 139 | |
140 | 140 | } |
@@ -104,7 +104,7 @@ |
||
104 | 104 | * the next element. |
105 | 105 | * |
106 | 106 | * @param Reader $reader |
107 | - * @return mixed |
|
107 | + * @return SupportedCalendarComponentSet |
|
108 | 108 | */ |
109 | 109 | static function xmlDeserialize(Reader $reader) { |
110 | 110 |
@@ -2,11 +2,11 @@ |
||
2 | 2 | |
3 | 3 | namespace Sabre\CalDAV\Xml\Property; |
4 | 4 | |
5 | +use Sabre\CalDAV\Plugin; |
|
5 | 6 | use Sabre\Xml\Element; |
6 | 7 | use Sabre\Xml\ParseException; |
7 | 8 | use Sabre\Xml\Reader; |
8 | 9 | use Sabre\Xml\Writer; |
9 | -use Sabre\CalDAV\Plugin; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * SupportedCalendarComponentSet property. |
@@ -112,7 +112,7 @@ |
||
112 | 112 | |
113 | 113 | $components = []; |
114 | 114 | |
115 | - foreach ((array)$elems as $elem) { |
|
115 | + foreach ((array) $elems as $elem) { |
|
116 | 116 | if ($elem['name'] === '{' . Plugin::NS_CALDAV . '}comp') { |
117 | 117 | $components[] = $elem['attributes']['name']; |
118 | 118 | } |
@@ -23,107 +23,107 @@ |
||
23 | 23 | */ |
24 | 24 | class SupportedCalendarComponentSet implements Element { |
25 | 25 | |
26 | - /** |
|
27 | - * List of supported components. |
|
28 | - * |
|
29 | - * This array will contain values such as VEVENT, VTODO and VJOURNAL. |
|
30 | - * |
|
31 | - * @var array |
|
32 | - */ |
|
33 | - protected $components = []; |
|
34 | - |
|
35 | - /** |
|
36 | - * Creates the property. |
|
37 | - * |
|
38 | - * @param array $components |
|
39 | - */ |
|
40 | - public function __construct(array $components) { |
|
41 | - |
|
42 | - $this->components = $components; |
|
43 | - |
|
44 | - } |
|
45 | - |
|
46 | - /** |
|
47 | - * Returns the list of supported components |
|
48 | - * |
|
49 | - * @return array |
|
50 | - */ |
|
51 | - public function getValue() { |
|
52 | - |
|
53 | - return $this->components; |
|
54 | - |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * The xmlSerialize metod is called during xml writing. |
|
59 | - * |
|
60 | - * Use the $writer argument to write its own xml serialization. |
|
61 | - * |
|
62 | - * An important note: do _not_ create a parent element. Any element |
|
63 | - * implementing XmlSerializble should only ever write what's considered |
|
64 | - * its 'inner xml'. |
|
65 | - * |
|
66 | - * The parent of the current element is responsible for writing a |
|
67 | - * containing element. |
|
68 | - * |
|
69 | - * This allows serializers to be re-used for different element names. |
|
70 | - * |
|
71 | - * If you are opening new elements, you must also close them again. |
|
72 | - * |
|
73 | - * @param Writer $writer |
|
74 | - * @return void |
|
75 | - */ |
|
76 | - public function xmlSerialize(Writer $writer) { |
|
77 | - |
|
78 | - foreach ($this->components as $component) { |
|
79 | - |
|
80 | - $writer->startElement('{' . Plugin::NS_CALDAV . '}comp'); |
|
81 | - $writer->writeAttributes(['name' => $component]); |
|
82 | - $writer->endElement(); |
|
83 | - |
|
84 | - } |
|
85 | - |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * The deserialize method is called during xml parsing. |
|
90 | - * |
|
91 | - * This method is called statictly, this is because in theory this method |
|
92 | - * may be used as a type of constructor, or factory method. |
|
93 | - * |
|
94 | - * Often you want to return an instance of the current class, but you are |
|
95 | - * free to return other data as well. |
|
96 | - * |
|
97 | - * You are responsible for advancing the reader to the next element. Not |
|
98 | - * doing anything will result in a never-ending loop. |
|
99 | - * |
|
100 | - * If you just want to skip parsing for this element altogether, you can |
|
101 | - * just call $reader->next(); |
|
102 | - * |
|
103 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
104 | - * the next element. |
|
105 | - * |
|
106 | - * @param Reader $reader |
|
107 | - * @return mixed |
|
108 | - */ |
|
109 | - static function xmlDeserialize(Reader $reader) { |
|
110 | - |
|
111 | - $elems = $reader->parseInnerTree(); |
|
112 | - |
|
113 | - $components = []; |
|
114 | - |
|
115 | - foreach ((array)$elems as $elem) { |
|
116 | - if ($elem['name'] === '{' . Plugin::NS_CALDAV . '}comp') { |
|
117 | - $components[] = $elem['attributes']['name']; |
|
118 | - } |
|
119 | - } |
|
120 | - |
|
121 | - if (!$components) { |
|
122 | - throw new ParseException('supported-calendar-component-set must have at least one CALDAV:comp element'); |
|
123 | - } |
|
124 | - |
|
125 | - return new self($components); |
|
126 | - |
|
127 | - } |
|
26 | + /** |
|
27 | + * List of supported components. |
|
28 | + * |
|
29 | + * This array will contain values such as VEVENT, VTODO and VJOURNAL. |
|
30 | + * |
|
31 | + * @var array |
|
32 | + */ |
|
33 | + protected $components = []; |
|
34 | + |
|
35 | + /** |
|
36 | + * Creates the property. |
|
37 | + * |
|
38 | + * @param array $components |
|
39 | + */ |
|
40 | + public function __construct(array $components) { |
|
41 | + |
|
42 | + $this->components = $components; |
|
43 | + |
|
44 | + } |
|
45 | + |
|
46 | + /** |
|
47 | + * Returns the list of supported components |
|
48 | + * |
|
49 | + * @return array |
|
50 | + */ |
|
51 | + public function getValue() { |
|
52 | + |
|
53 | + return $this->components; |
|
54 | + |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * The xmlSerialize metod is called during xml writing. |
|
59 | + * |
|
60 | + * Use the $writer argument to write its own xml serialization. |
|
61 | + * |
|
62 | + * An important note: do _not_ create a parent element. Any element |
|
63 | + * implementing XmlSerializble should only ever write what's considered |
|
64 | + * its 'inner xml'. |
|
65 | + * |
|
66 | + * The parent of the current element is responsible for writing a |
|
67 | + * containing element. |
|
68 | + * |
|
69 | + * This allows serializers to be re-used for different element names. |
|
70 | + * |
|
71 | + * If you are opening new elements, you must also close them again. |
|
72 | + * |
|
73 | + * @param Writer $writer |
|
74 | + * @return void |
|
75 | + */ |
|
76 | + public function xmlSerialize(Writer $writer) { |
|
77 | + |
|
78 | + foreach ($this->components as $component) { |
|
79 | + |
|
80 | + $writer->startElement('{' . Plugin::NS_CALDAV . '}comp'); |
|
81 | + $writer->writeAttributes(['name' => $component]); |
|
82 | + $writer->endElement(); |
|
83 | + |
|
84 | + } |
|
85 | + |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * The deserialize method is called during xml parsing. |
|
90 | + * |
|
91 | + * This method is called statictly, this is because in theory this method |
|
92 | + * may be used as a type of constructor, or factory method. |
|
93 | + * |
|
94 | + * Often you want to return an instance of the current class, but you are |
|
95 | + * free to return other data as well. |
|
96 | + * |
|
97 | + * You are responsible for advancing the reader to the next element. Not |
|
98 | + * doing anything will result in a never-ending loop. |
|
99 | + * |
|
100 | + * If you just want to skip parsing for this element altogether, you can |
|
101 | + * just call $reader->next(); |
|
102 | + * |
|
103 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
104 | + * the next element. |
|
105 | + * |
|
106 | + * @param Reader $reader |
|
107 | + * @return mixed |
|
108 | + */ |
|
109 | + static function xmlDeserialize(Reader $reader) { |
|
110 | + |
|
111 | + $elems = $reader->parseInnerTree(); |
|
112 | + |
|
113 | + $components = []; |
|
114 | + |
|
115 | + foreach ((array)$elems as $elem) { |
|
116 | + if ($elem['name'] === '{' . Plugin::NS_CALDAV . '}comp') { |
|
117 | + $components[] = $elem['attributes']['name']; |
|
118 | + } |
|
119 | + } |
|
120 | + |
|
121 | + if (!$components) { |
|
122 | + throw new ParseException('supported-calendar-component-set must have at least one CALDAV:comp element'); |
|
123 | + } |
|
124 | + |
|
125 | + return new self($components); |
|
126 | + |
|
127 | + } |
|
128 | 128 | |
129 | 129 | } |
@@ -80,7 +80,7 @@ |
||
80 | 80 | * the next element. |
81 | 81 | * |
82 | 82 | * @param Reader $reader |
83 | - * @return mixed |
|
83 | + * @return CalendarMultiGetReport |
|
84 | 84 | */ |
85 | 85 | static function xmlDeserialize(Reader $reader) { |
86 | 86 |
@@ -2,10 +2,10 @@ |
||
2 | 2 | |
3 | 3 | namespace Sabre\CalDAV\Xml\Request; |
4 | 4 | |
5 | -use Sabre\Xml\XmlDeserializable; |
|
6 | -use Sabre\Xml\Reader; |
|
7 | 5 | use Sabre\CalDAV\Plugin; |
8 | 6 | use Sabre\Uri; |
7 | +use Sabre\Xml\Reader; |
|
8 | +use Sabre\Xml\XmlDeserializable; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * CalendarMultiGetReport request parser. |
@@ -21,104 +21,104 @@ |
||
21 | 21 | */ |
22 | 22 | class CalendarMultiGetReport implements XmlDeserializable { |
23 | 23 | |
24 | - /** |
|
25 | - * An array with requested properties. |
|
26 | - * |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - public $properties; |
|
30 | - |
|
31 | - /** |
|
32 | - * This is an array with the urls that are being requested. |
|
33 | - * |
|
34 | - * @var array |
|
35 | - */ |
|
36 | - public $hrefs; |
|
37 | - |
|
38 | - /** |
|
39 | - * If the calendar data must be expanded, this will contain an array with 2 |
|
40 | - * elements: start and end. |
|
41 | - * |
|
42 | - * Each may be a DateTime or null. |
|
43 | - * |
|
44 | - * @var array|null |
|
45 | - */ |
|
46 | - public $expand = null; |
|
47 | - |
|
48 | - /** |
|
49 | - * The mimetype of the content that should be returend. Usually |
|
50 | - * text/calendar. |
|
51 | - * |
|
52 | - * @var string |
|
53 | - */ |
|
54 | - public $contentType = null; |
|
55 | - |
|
56 | - /** |
|
57 | - * The version of calendar-data that should be returned. Usually '2.0', |
|
58 | - * referring to iCalendar 2.0. |
|
59 | - * |
|
60 | - * @var string |
|
61 | - */ |
|
62 | - public $version = null; |
|
63 | - |
|
64 | - /** |
|
65 | - * The deserialize method is called during xml parsing. |
|
66 | - * |
|
67 | - * This method is called statictly, this is because in theory this method |
|
68 | - * may be used as a type of constructor, or factory method. |
|
69 | - * |
|
70 | - * Often you want to return an instance of the current class, but you are |
|
71 | - * free to return other data as well. |
|
72 | - * |
|
73 | - * You are responsible for advancing the reader to the next element. Not |
|
74 | - * doing anything will result in a never-ending loop. |
|
75 | - * |
|
76 | - * If you just want to skip parsing for this element altogether, you can |
|
77 | - * just call $reader->next(); |
|
78 | - * |
|
79 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
80 | - * the next element. |
|
81 | - * |
|
82 | - * @param Reader $reader |
|
83 | - * @return mixed |
|
84 | - */ |
|
85 | - static function xmlDeserialize(Reader $reader) { |
|
86 | - |
|
87 | - $elems = $reader->parseInnerTree([ |
|
88 | - '{urn:ietf:params:xml:ns:caldav}calendar-data' => 'Sabre\\CalDAV\\Xml\\Filter\\CalendarData', |
|
89 | - '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', |
|
90 | - ]); |
|
91 | - |
|
92 | - $newProps = [ |
|
93 | - 'hrefs' => [], |
|
94 | - 'properties' => [], |
|
95 | - ]; |
|
96 | - |
|
97 | - foreach ($elems as $elem) { |
|
98 | - |
|
99 | - switch ($elem['name']) { |
|
100 | - |
|
101 | - case '{DAV:}prop' : |
|
102 | - $newProps['properties'] = array_keys($elem['value']); |
|
103 | - if (isset($elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data'])) { |
|
104 | - $newProps += $elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data']; |
|
105 | - } |
|
106 | - break; |
|
107 | - case '{DAV:}href' : |
|
108 | - $newProps['hrefs'][] = Uri\resolve($reader->contextUri, $elem['value']); |
|
109 | - break; |
|
110 | - |
|
111 | - } |
|
112 | - |
|
113 | - } |
|
114 | - |
|
115 | - $obj = new self(); |
|
116 | - foreach ($newProps as $key => $value) { |
|
117 | - $obj->$key = $value; |
|
118 | - } |
|
119 | - |
|
120 | - return $obj; |
|
121 | - |
|
122 | - } |
|
24 | + /** |
|
25 | + * An array with requested properties. |
|
26 | + * |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + public $properties; |
|
30 | + |
|
31 | + /** |
|
32 | + * This is an array with the urls that are being requested. |
|
33 | + * |
|
34 | + * @var array |
|
35 | + */ |
|
36 | + public $hrefs; |
|
37 | + |
|
38 | + /** |
|
39 | + * If the calendar data must be expanded, this will contain an array with 2 |
|
40 | + * elements: start and end. |
|
41 | + * |
|
42 | + * Each may be a DateTime or null. |
|
43 | + * |
|
44 | + * @var array|null |
|
45 | + */ |
|
46 | + public $expand = null; |
|
47 | + |
|
48 | + /** |
|
49 | + * The mimetype of the content that should be returend. Usually |
|
50 | + * text/calendar. |
|
51 | + * |
|
52 | + * @var string |
|
53 | + */ |
|
54 | + public $contentType = null; |
|
55 | + |
|
56 | + /** |
|
57 | + * The version of calendar-data that should be returned. Usually '2.0', |
|
58 | + * referring to iCalendar 2.0. |
|
59 | + * |
|
60 | + * @var string |
|
61 | + */ |
|
62 | + public $version = null; |
|
63 | + |
|
64 | + /** |
|
65 | + * The deserialize method is called during xml parsing. |
|
66 | + * |
|
67 | + * This method is called statictly, this is because in theory this method |
|
68 | + * may be used as a type of constructor, or factory method. |
|
69 | + * |
|
70 | + * Often you want to return an instance of the current class, but you are |
|
71 | + * free to return other data as well. |
|
72 | + * |
|
73 | + * You are responsible for advancing the reader to the next element. Not |
|
74 | + * doing anything will result in a never-ending loop. |
|
75 | + * |
|
76 | + * If you just want to skip parsing for this element altogether, you can |
|
77 | + * just call $reader->next(); |
|
78 | + * |
|
79 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
80 | + * the next element. |
|
81 | + * |
|
82 | + * @param Reader $reader |
|
83 | + * @return mixed |
|
84 | + */ |
|
85 | + static function xmlDeserialize(Reader $reader) { |
|
86 | + |
|
87 | + $elems = $reader->parseInnerTree([ |
|
88 | + '{urn:ietf:params:xml:ns:caldav}calendar-data' => 'Sabre\\CalDAV\\Xml\\Filter\\CalendarData', |
|
89 | + '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', |
|
90 | + ]); |
|
91 | + |
|
92 | + $newProps = [ |
|
93 | + 'hrefs' => [], |
|
94 | + 'properties' => [], |
|
95 | + ]; |
|
96 | + |
|
97 | + foreach ($elems as $elem) { |
|
98 | + |
|
99 | + switch ($elem['name']) { |
|
100 | + |
|
101 | + case '{DAV:}prop' : |
|
102 | + $newProps['properties'] = array_keys($elem['value']); |
|
103 | + if (isset($elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data'])) { |
|
104 | + $newProps += $elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data']; |
|
105 | + } |
|
106 | + break; |
|
107 | + case '{DAV:}href' : |
|
108 | + $newProps['hrefs'][] = Uri\resolve($reader->contextUri, $elem['value']); |
|
109 | + break; |
|
110 | + |
|
111 | + } |
|
112 | + |
|
113 | + } |
|
114 | + |
|
115 | + $obj = new self(); |
|
116 | + foreach ($newProps as $key => $value) { |
|
117 | + $obj->$key = $value; |
|
118 | + } |
|
119 | + |
|
120 | + return $obj; |
|
121 | + |
|
122 | + } |
|
123 | 123 | |
124 | 124 | } |
@@ -80,7 +80,7 @@ |
||
80 | 80 | * the next element. |
81 | 81 | * |
82 | 82 | * @param Reader $reader |
83 | - * @return mixed |
|
83 | + * @return CalendarQueryReport |
|
84 | 84 | */ |
85 | 85 | static function xmlDeserialize(Reader $reader) { |
86 | 86 |
@@ -2,10 +2,10 @@ |
||
2 | 2 | |
3 | 3 | namespace Sabre\CalDAV\Xml\Request; |
4 | 4 | |
5 | -use Sabre\Xml\XmlDeserializable; |
|
6 | -use Sabre\Xml\Reader; |
|
7 | -use Sabre\DAV\Exception\BadRequest; |
|
8 | 5 | use Sabre\CalDAV\Plugin; |
6 | +use Sabre\DAV\Exception\BadRequest; |
|
7 | +use Sabre\Xml\Reader; |
|
8 | +use Sabre\Xml\XmlDeserializable; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * CalendarQueryReport request parser. |
@@ -21,119 +21,119 @@ |
||
21 | 21 | */ |
22 | 22 | class CalendarQueryReport implements XmlDeserializable { |
23 | 23 | |
24 | - /** |
|
25 | - * An array with requested properties. |
|
26 | - * |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - public $properties; |
|
30 | - |
|
31 | - /** |
|
32 | - * List of property/component filters. |
|
33 | - * |
|
34 | - * @var array |
|
35 | - */ |
|
36 | - public $filters; |
|
37 | - |
|
38 | - /** |
|
39 | - * If the calendar data must be expanded, this will contain an array with 2 |
|
40 | - * elements: start and end. |
|
41 | - * |
|
42 | - * Each may be a DateTime or null. |
|
43 | - * |
|
44 | - * @var array|null |
|
45 | - */ |
|
46 | - public $expand = null; |
|
47 | - |
|
48 | - /** |
|
49 | - * The mimetype of the content that should be returend. Usually |
|
50 | - * text/calendar. |
|
51 | - * |
|
52 | - * @var string |
|
53 | - */ |
|
54 | - public $contentType = null; |
|
55 | - |
|
56 | - /** |
|
57 | - * The version of calendar-data that should be returned. Usually '2.0', |
|
58 | - * referring to iCalendar 2.0. |
|
59 | - * |
|
60 | - * @var string |
|
61 | - */ |
|
62 | - public $version = null; |
|
63 | - |
|
64 | - /** |
|
65 | - * The deserialize method is called during xml parsing. |
|
66 | - * |
|
67 | - * This method is called statictly, this is because in theory this method |
|
68 | - * may be used as a type of constructor, or factory method. |
|
69 | - * |
|
70 | - * Often you want to return an instance of the current class, but you are |
|
71 | - * free to return other data as well. |
|
72 | - * |
|
73 | - * You are responsible for advancing the reader to the next element. Not |
|
74 | - * doing anything will result in a never-ending loop. |
|
75 | - * |
|
76 | - * If you just want to skip parsing for this element altogether, you can |
|
77 | - * just call $reader->next(); |
|
78 | - * |
|
79 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
80 | - * the next element. |
|
81 | - * |
|
82 | - * @param Reader $reader |
|
83 | - * @return mixed |
|
84 | - */ |
|
85 | - static function xmlDeserialize(Reader $reader) { |
|
86 | - |
|
87 | - $elems = $reader->parseInnerTree([ |
|
88 | - '{urn:ietf:params:xml:ns:caldav}comp-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\CompFilter', |
|
89 | - '{urn:ietf:params:xml:ns:caldav}prop-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\PropFilter', |
|
90 | - '{urn:ietf:params:xml:ns:caldav}param-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\ParamFilter', |
|
91 | - '{urn:ietf:params:xml:ns:caldav}calendar-data' => 'Sabre\\CalDAV\\Xml\\Filter\\CalendarData', |
|
92 | - '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', |
|
93 | - ]); |
|
94 | - |
|
95 | - $newProps = [ |
|
96 | - 'filters' => null, |
|
97 | - 'properties' => [], |
|
98 | - ]; |
|
99 | - |
|
100 | - if (!is_array($elems)) $elems = []; |
|
101 | - |
|
102 | - foreach ($elems as $elem) { |
|
103 | - |
|
104 | - switch ($elem['name']) { |
|
105 | - |
|
106 | - case '{DAV:}prop' : |
|
107 | - $newProps['properties'] = array_keys($elem['value']); |
|
108 | - if (isset($elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data'])) { |
|
109 | - $newProps += $elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data']; |
|
110 | - } |
|
111 | - break; |
|
112 | - case '{' . Plugin::NS_CALDAV . '}filter' : |
|
113 | - foreach ($elem['value'] as $subElem) { |
|
114 | - if ($subElem['name'] === '{' . Plugin::NS_CALDAV . '}comp-filter') { |
|
115 | - if (!is_null($newProps['filters'])) { |
|
116 | - throw new BadRequest('Only one top-level comp-filter may be defined'); |
|
117 | - } |
|
118 | - $newProps['filters'] = $subElem['value']; |
|
119 | - } |
|
120 | - } |
|
121 | - break; |
|
122 | - |
|
123 | - } |
|
124 | - |
|
125 | - } |
|
126 | - |
|
127 | - if (is_null($newProps['filters'])) { |
|
128 | - throw new BadRequest('The {' . Plugin::NS_CALDAV . '}filter element is required for this request'); |
|
129 | - } |
|
130 | - |
|
131 | - $obj = new self(); |
|
132 | - foreach ($newProps as $key => $value) { |
|
133 | - $obj->$key = $value; |
|
134 | - } |
|
135 | - return $obj; |
|
136 | - |
|
137 | - } |
|
24 | + /** |
|
25 | + * An array with requested properties. |
|
26 | + * |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + public $properties; |
|
30 | + |
|
31 | + /** |
|
32 | + * List of property/component filters. |
|
33 | + * |
|
34 | + * @var array |
|
35 | + */ |
|
36 | + public $filters; |
|
37 | + |
|
38 | + /** |
|
39 | + * If the calendar data must be expanded, this will contain an array with 2 |
|
40 | + * elements: start and end. |
|
41 | + * |
|
42 | + * Each may be a DateTime or null. |
|
43 | + * |
|
44 | + * @var array|null |
|
45 | + */ |
|
46 | + public $expand = null; |
|
47 | + |
|
48 | + /** |
|
49 | + * The mimetype of the content that should be returend. Usually |
|
50 | + * text/calendar. |
|
51 | + * |
|
52 | + * @var string |
|
53 | + */ |
|
54 | + public $contentType = null; |
|
55 | + |
|
56 | + /** |
|
57 | + * The version of calendar-data that should be returned. Usually '2.0', |
|
58 | + * referring to iCalendar 2.0. |
|
59 | + * |
|
60 | + * @var string |
|
61 | + */ |
|
62 | + public $version = null; |
|
63 | + |
|
64 | + /** |
|
65 | + * The deserialize method is called during xml parsing. |
|
66 | + * |
|
67 | + * This method is called statictly, this is because in theory this method |
|
68 | + * may be used as a type of constructor, or factory method. |
|
69 | + * |
|
70 | + * Often you want to return an instance of the current class, but you are |
|
71 | + * free to return other data as well. |
|
72 | + * |
|
73 | + * You are responsible for advancing the reader to the next element. Not |
|
74 | + * doing anything will result in a never-ending loop. |
|
75 | + * |
|
76 | + * If you just want to skip parsing for this element altogether, you can |
|
77 | + * just call $reader->next(); |
|
78 | + * |
|
79 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
80 | + * the next element. |
|
81 | + * |
|
82 | + * @param Reader $reader |
|
83 | + * @return mixed |
|
84 | + */ |
|
85 | + static function xmlDeserialize(Reader $reader) { |
|
86 | + |
|
87 | + $elems = $reader->parseInnerTree([ |
|
88 | + '{urn:ietf:params:xml:ns:caldav}comp-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\CompFilter', |
|
89 | + '{urn:ietf:params:xml:ns:caldav}prop-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\PropFilter', |
|
90 | + '{urn:ietf:params:xml:ns:caldav}param-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\ParamFilter', |
|
91 | + '{urn:ietf:params:xml:ns:caldav}calendar-data' => 'Sabre\\CalDAV\\Xml\\Filter\\CalendarData', |
|
92 | + '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', |
|
93 | + ]); |
|
94 | + |
|
95 | + $newProps = [ |
|
96 | + 'filters' => null, |
|
97 | + 'properties' => [], |
|
98 | + ]; |
|
99 | + |
|
100 | + if (!is_array($elems)) $elems = []; |
|
101 | + |
|
102 | + foreach ($elems as $elem) { |
|
103 | + |
|
104 | + switch ($elem['name']) { |
|
105 | + |
|
106 | + case '{DAV:}prop' : |
|
107 | + $newProps['properties'] = array_keys($elem['value']); |
|
108 | + if (isset($elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data'])) { |
|
109 | + $newProps += $elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data']; |
|
110 | + } |
|
111 | + break; |
|
112 | + case '{' . Plugin::NS_CALDAV . '}filter' : |
|
113 | + foreach ($elem['value'] as $subElem) { |
|
114 | + if ($subElem['name'] === '{' . Plugin::NS_CALDAV . '}comp-filter') { |
|
115 | + if (!is_null($newProps['filters'])) { |
|
116 | + throw new BadRequest('Only one top-level comp-filter may be defined'); |
|
117 | + } |
|
118 | + $newProps['filters'] = $subElem['value']; |
|
119 | + } |
|
120 | + } |
|
121 | + break; |
|
122 | + |
|
123 | + } |
|
124 | + |
|
125 | + } |
|
126 | + |
|
127 | + if (is_null($newProps['filters'])) { |
|
128 | + throw new BadRequest('The {' . Plugin::NS_CALDAV . '}filter element is required for this request'); |
|
129 | + } |
|
130 | + |
|
131 | + $obj = new self(); |
|
132 | + foreach ($newProps as $key => $value) { |
|
133 | + $obj->$key = $value; |
|
134 | + } |
|
135 | + return $obj; |
|
136 | + |
|
137 | + } |
|
138 | 138 | |
139 | 139 | } |
@@ -97,7 +97,9 @@ |
||
97 | 97 | 'properties' => [], |
98 | 98 | ]; |
99 | 99 | |
100 | - if (!is_array($elems)) $elems = []; |
|
100 | + if (!is_array($elems)) { |
|
101 | + $elems = []; |
|
102 | + } |
|
101 | 103 | |
102 | 104 | foreach ($elems as $elem) { |
103 | 105 |