ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Calendar.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\CalDAV;
4
5use Sabre\DAV;
8
20
21 use DAVACL\ACLTrait;
22
28 protected $calendarInfo;
29
35 protected $caldavBackend;
36
44
45 $this->caldavBackend = $caldavBackend;
46 $this->calendarInfo = $calendarInfo;
47
48 }
49
55 function getName() {
56
57 return $this->calendarInfo['uri'];
58
59 }
60
73 function propPatch(PropPatch $propPatch) {
74
75 return $this->caldavBackend->updateCalendar($this->calendarInfo['id'], $propPatch);
76
77 }
78
85 function getProperties($requestedProperties) {
86
87 $response = [];
88
89 foreach ($this->calendarInfo as $propName => $propValue) {
90
91 if (!is_null($propValue) && $propName[0] === '{')
92 $response[$propName] = $this->calendarInfo[$propName];
93
94 }
95 return $response;
96
97 }
98
107 function getChild($name) {
108
109 $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name);
110
111 if (!$obj) throw new DAV\Exception\NotFound('Calendar object not found');
112
113 $obj['acl'] = $this->getChildACL();
114
115 return new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj);
116
117 }
118
124 function getChildren() {
125
126 $objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']);
127 $children = [];
128 foreach ($objs as $obj) {
129 $obj['acl'] = $this->getChildACL();
130 $children[] = new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj);
131 }
132 return $children;
133
134 }
135
145 function getMultipleChildren(array $paths) {
146
147 $objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths);
148 $children = [];
149 foreach ($objs as $obj) {
150 $obj['acl'] = $this->getChildACL();
151 $children[] = new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj);
152 }
153 return $children;
154
155 }
156
163 function childExists($name) {
164
165 $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name);
166 if (!$obj)
167 return false;
168 else
169 return true;
170
171 }
172
182
183 throw new DAV\Exception\MethodNotAllowed('Creating collections in calendar objects is not allowed');
184
185 }
186
196 function createFile($name, $calendarData = null) {
197
198 if (is_resource($calendarData)) {
199 $calendarData = stream_get_contents($calendarData);
200 }
201 return $this->caldavBackend->createCalendarObject($this->calendarInfo['id'], $name, $calendarData);
202
203 }
204
210 function delete() {
211
212 $this->caldavBackend->deleteCalendar($this->calendarInfo['id']);
213
214 }
215
223 function setName($newName) {
224
225 throw new DAV\Exception\MethodNotAllowed('Renaming calendars is not yet supported');
226
227 }
228
234 function getLastModified() {
235
236 return null;
237
238 }
239
247 function getOwner() {
248
249 return $this->calendarInfo['principaluri'];
250
251 }
252
265 function getACL() {
266
267 $acl = [
268 [
269 'privilege' => '{DAV:}read',
270 'principal' => $this->getOwner(),
271 'protected' => true,
272 ],
273 [
274 'privilege' => '{DAV:}read',
275 'principal' => $this->getOwner() . '/calendar-proxy-write',
276 'protected' => true,
277 ],
278 [
279 'privilege' => '{DAV:}read',
280 'principal' => $this->getOwner() . '/calendar-proxy-read',
281 'protected' => true,
282 ],
283 [
284 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy',
285 'principal' => '{DAV:}authenticated',
286 'protected' => true,
287 ],
288
289 ];
290 if (empty($this->calendarInfo['{http://sabredav.org/ns}read-only'])) {
291 $acl[] = [
292 'privilege' => '{DAV:}write',
293 'principal' => $this->getOwner(),
294 'protected' => true,
295 ];
296 $acl[] = [
297 'privilege' => '{DAV:}write',
298 'principal' => $this->getOwner() . '/calendar-proxy-write',
299 'protected' => true,
300 ];
301 }
302
303 return $acl;
304
305 }
306
314 function getChildACL() {
315
316 $acl = [
317 [
318 'privilege' => '{DAV:}read',
319 'principal' => $this->getOwner(),
320 'protected' => true,
321 ],
322
323 [
324 'privilege' => '{DAV:}read',
325 'principal' => $this->getOwner() . '/calendar-proxy-write',
326 'protected' => true,
327 ],
328 [
329 'privilege' => '{DAV:}read',
330 'principal' => $this->getOwner() . '/calendar-proxy-read',
331 'protected' => true,
332 ],
333
334 ];
335 if (empty($this->calendarInfo['{http://sabredav.org/ns}read-only'])) {
336 $acl[] = [
337 'privilege' => '{DAV:}write',
338 'principal' => $this->getOwner(),
339 'protected' => true,
340 ];
341 $acl[] = [
342 'privilege' => '{DAV:}write',
343 'principal' => $this->getOwner() . '/calendar-proxy-write',
344 'protected' => true,
345 ];
346
347 }
348 return $acl;
349
350 }
351
352
370 function calendarQuery(array $filters) {
371
372 return $this->caldavBackend->calendarQuery($this->calendarInfo['id'], $filters);
373
374 }
375
385 function getSyncToken() {
386
387 if (
388 $this->caldavBackend instanceof Backend\SyncSupport &&
389 isset($this->calendarInfo['{DAV:}sync-token'])
390 ) {
391 return $this->calendarInfo['{DAV:}sync-token'];
392 }
393 if (
394 $this->caldavBackend instanceof Backend\SyncSupport &&
395 isset($this->calendarInfo['{http://sabredav.org/ns}sync-token'])
396 ) {
397 return $this->calendarInfo['{http://sabredav.org/ns}sync-token'];
398 }
399
400 }
401
457 function getChanges($syncToken, $syncLevel, $limit = null) {
458
459 if (!$this->caldavBackend instanceof Backend\SyncSupport) {
460 return null;
461 }
462
463 return $this->caldavBackend->getChangesForCalendar(
464 $this->calendarInfo['id'],
465 $syncToken,
466 $syncLevel,
467 $limit
468 );
469
470 }
471
472}
An exception for terminatinating execution or to throw for unit testing.
The CalendarObject represents a single VEVENT or VTODO within a Calendar.
This object represents a CalDAV calendar.
Definition: Calendar.php:19
childExists($name)
Checks if a child-node exists.
Definition: Calendar.php:163
getChildACL()
This method returns the ACL's for calendar objects in this calendar.
Definition: Calendar.php:314
calendarQuery(array $filters)
Performs a calendar-query on the contents of this calendar.
Definition: Calendar.php:370
createDirectory($name)
Creates a new directory.
Definition: Calendar.php:181
getChanges($syncToken, $syncLevel, $limit=null)
The getChanges method returns all the changes that have happened, since the specified syncToken and t...
Definition: Calendar.php:457
getChildren()
Returns the full list of calendar objects.
Definition: Calendar.php:124
getProperties($requestedProperties)
Returns the list of properties.
Definition: Calendar.php:85
getACL()
Returns a list of ACE's for this node.
Definition: Calendar.php:265
setName($newName)
Renames the calendar.
Definition: Calendar.php:223
createFile($name, $calendarData=null)
Creates a new file.
Definition: Calendar.php:196
getSyncToken()
This method returns the current sync-token for this collection.
Definition: Calendar.php:385
getChild($name)
Returns a calendar object.
Definition: Calendar.php:107
getLastModified()
Returns the last modification date as a unix timestamp.
Definition: Calendar.php:234
getMultipleChildren(array $paths)
This method receives a list of paths in it's first argument.
Definition: Calendar.php:145
getOwner()
Returns the owner principal.
Definition: Calendar.php:247
getName()
Returns the name of the calendar.
Definition: Calendar.php:55
__construct(Backend\BackendInterface $caldavBackend, $calendarInfo)
Constructor.
Definition: Calendar.php:43
propPatch(PropPatch $propPatch)
Updates properties on this node.
Definition: Calendar.php:73
const NS_CALDAV
This is the official CalDAV namespace.
Definition: Plugin.php:33
This class represents a set of properties that are going to be updated.
Definition: PropPatch.php:20
Calendar interface.
Definition: ICalendar.php:16
Implement this interface to create your own principal backends.
IProperties interface.
Definition: IProperties.php:14
If a class extends ISyncCollection, it supports WebDAV-sync.
if($argc< 2) $paths
Definition: migrateto20.php:44
$response