ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Invite.php
Go to the documentation of this file.
1<?php
2
4
7use Sabre\DAV;
9
20class Invite implements NotificationInterface {
21
27 protected $id;
28
34 protected $dtStamp;
35
42 protected $href;
43
49 protected $type;
50
56 protected $readOnly;
57
63 protected $hostUrl;
64
70 protected $organizer;
71
77 protected $commonName;
78
84 protected $firstName;
85
91 protected $lastName;
92
98 protected $summary;
99
105 protected $etag;
106
113
141 function __construct(array $values) {
142
143 $required = [
144 'id',
145 'etag',
146 'href',
147 'dtStamp',
148 'type',
149 'readOnly',
150 'hostUrl',
151 'organizer',
152 ];
153 foreach ($required as $item) {
154 if (!isset($values[$item])) {
155 throw new \InvalidArgumentException($item . ' is a required constructor option');
156 }
157 }
158
159 foreach ($values as $key => $value) {
160 if (!property_exists($this, $key)) {
161 throw new \InvalidArgumentException('Unknown option: ' . $key);
162 }
163 $this->$key = $value;
164 }
165
166 }
167
187 function xmlSerialize(Writer $writer) {
188
189 $writer->writeElement('{' . CalDAV\Plugin::NS_CALENDARSERVER . '}invite-notification');
190
191 }
192
200 function xmlSerializeFull(Writer $writer) {
201
202 $cs = '{' . CalDAV\Plugin::NS_CALENDARSERVER . '}';
203
204 $this->dtStamp->setTimezone(new \DateTimezone('GMT'));
205 $writer->writeElement($cs . 'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z'));
206
207 $writer->startElement($cs . 'invite-notification');
208
209 $writer->writeElement($cs . 'uid', $this->id);
210 $writer->writeElement('{DAV:}href', $this->href);
211
212 switch ($this->type) {
213
215 $writer->writeElement($cs . 'invite-accepted');
216 break;
218 $writer->writeElement($cs . 'invite-noresponse');
219 break;
220
221 }
222
223 $writer->writeElement($cs . 'hosturl', [
224 '{DAV:}href' => $writer->contextUri . $this->hostUrl
225 ]);
226
227 if ($this->summary) {
228 $writer->writeElement($cs . 'summary', $this->summary);
229 }
230
231 $writer->startElement($cs . 'access');
232 if ($this->readOnly) {
233 $writer->writeElement($cs . 'read');
234 } else {
235 $writer->writeElement($cs . 'read-write');
236 }
237 $writer->endElement(); // access
238
239 $writer->startElement($cs . 'organizer');
240 // If the organizer contains a 'mailto:' part, it means it should be
241 // treated as absolute.
242 if (strtolower(substr($this->organizer, 0, 7)) === 'mailto:') {
243 $writer->writeElement('{DAV:}href', $this->organizer);
244 } else {
245 $writer->writeElement('{DAV:}href', $writer->contextUri . $this->organizer);
246 }
247 if ($this->commonName) {
248 $writer->writeElement($cs . 'common-name', $this->commonName);
249 }
250 if ($this->firstName) {
251 $writer->writeElement($cs . 'first-name', $this->firstName);
252 }
253 if ($this->lastName) {
254 $writer->writeElement($cs . 'last-name', $this->lastName);
255 }
256 $writer->endElement(); // organizer
257
258 if ($this->commonName) {
259 $writer->writeElement($cs . 'organizer-cn', $this->commonName);
260 }
261 if ($this->firstName) {
262 $writer->writeElement($cs . 'organizer-first', $this->firstName);
263 }
264 if ($this->lastName) {
265 $writer->writeElement($cs . 'organizer-last', $this->lastName);
266 }
267 if ($this->supportedComponents) {
268 $writer->writeElement('{' . CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set', $this->supportedComponents);
269 }
270
271 $writer->endElement(); // invite-notification
272
273 }
274
283 function getId() {
284
285 return $this->id;
286
287 }
288
296 function getETag() {
297
298 return $this->etag;
299
300 }
301
302}
An exception for terminatinating execution or to throw for unit testing.
const NS_CALDAV
This is the official CalDAV namespace.
Definition: Plugin.php:33
const NS_CALENDARSERVER
This is the namespace for the proprietary calendarserver extensions.
Definition: Plugin.php:38
This plugin implements support for caldav sharing.
This class represents the cs:invite-notification notification element.
Definition: Invite.php:20
__construct(array $values)
Creates the Invite notification.
Definition: Invite.php:141
getId()
Returns a unique id for this notification.
Definition: Invite.php:283
xmlSerialize(Writer $writer)
The xmlSerialize method is called during xml writing.
Definition: Invite.php:187
getETag()
Returns the ETag for this notification.
Definition: Invite.php:296
xmlSerializeFull(Writer $writer)
This method serializes the entire notification, as it is used in the response body.
Definition: Invite.php:200
The XML Writer class.
Definition: Writer.php:31
writeElement($name, $content=null)
Write a full element tag and it's contents.
Definition: Writer.php:189
startElement($name)
Opens a new element.
Definition: Writer.php:121
$key
Definition: croninfo.php:18
This interface reflects a single notification type.
$values