ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\CalDAV\Calendar Class Reference

This object represents a CalDAV calendar. More...

+ Inheritance diagram for Sabre\CalDAV\Calendar:
+ Collaboration diagram for Sabre\CalDAV\Calendar:

Public Member Functions

 __construct (Backend\BackendInterface $caldavBackend, $calendarInfo)
 Constructor. More...
 
 getName ()
 Returns the name of the calendar. More...
 
 propPatch (PropPatch $propPatch)
 Updates properties on this node. More...
 
 getProperties ($requestedProperties)
 Returns the list of properties. More...
 
 getChild ($name)
 Returns a calendar object. More...
 
 getChildren ()
 Returns the full list of calendar objects. More...
 
 getMultipleChildren (array $paths)
 This method receives a list of paths in it's first argument. More...
 
 childExists ($name)
 Checks if a child-node exists. More...
 
 createDirectory ($name)
 Creates a new directory. More...
 
 createFile ($name, $calendarData=null)
 Creates a new file. More...
 
 delete ()
 Deletes the calendar. More...
 
 setName ($newName)
 Renames the calendar. More...
 
 getLastModified ()
 Returns the last modification date as a unix timestamp. More...
 
 getOwner ()
 Returns the owner principal. More...
 
 getACL ()
 Returns a list of ACE's for this node. More...
 
 getChildACL ()
 This method returns the ACL's for calendar objects in this calendar. More...
 
 calendarQuery (array $filters)
 Performs a calendar-query on the contents of this calendar. More...
 
 getSyncToken ()
 This method returns the current sync-token for this collection. More...
 
 getChanges ($syncToken, $syncLevel, $limit=null)
 The getChanges method returns all the changes that have happened, since the specified syncToken and the current collection. More...
 
- Public Member Functions inherited from Sabre\DAVACL\IACL
 getGroup ()
 Returns a group principal. More...
 
 setACL (array $acl)
 Updates the ACL. More...
 
 getSupportedPrivilegeSet ()
 Returns the list of supported privileges for this node. More...
 

Protected Attributes

 $calendarInfo
 
 $caldavBackend
 

Detailed Description

This object represents a CalDAV calendar.

A calendar can contain multiple TODO and or Events. These are represented as objects.

Author
Evert Pot (http://evertpot.com/) http://sabre.io/license/ Modified BSD License

Definition at line 19 of file Calendar.php.

Constructor & Destructor Documentation

◆ __construct()

Sabre\CalDAV\Calendar::__construct ( Backend\BackendInterface  $caldavBackend,
  $calendarInfo 
)

Constructor.

Parameters
Backend\BackendInterface$caldavBackend
array$calendarInfo

Definition at line 43 of file Calendar.php.

References Sabre\CalDAV\Calendar\$caldavBackend, and Sabre\CalDAV\Calendar\$calendarInfo.

43  {
44 
45  $this->caldavBackend = $caldavBackend;
46  $this->calendarInfo = $calendarInfo;
47 
48  }

Member Function Documentation

◆ calendarQuery()

Sabre\CalDAV\Calendar::calendarQuery ( array  $filters)

Performs a calendar-query on the contents of this calendar.

The calendar-query is defined in RFC4791 : CalDAV. Using the calendar-query it is possible for a client to request a specific set of object, based on contents of iCalendar properties, date-ranges and iCalendar component types (VTODO, VEVENT).

This method should just return a list of (relative) urls that match this query.

The list of filters are specified as an array. The exact array is documented by Sabre.

Parameters
array$filters
Returns
array

Implements Sabre\CalDAV\ICalendarObjectContainer.

Definition at line 370 of file Calendar.php.

370  {
371 
372  return $this->caldavBackend->calendarQuery($this->calendarInfo['id'], $filters);
373 
374  }

◆ childExists()

Sabre\CalDAV\Calendar::childExists (   $name)

Checks if a child-node exists.

Parameters
string$name
Returns
bool

Implements Sabre\DAV\ICollection.

Definition at line 163 of file Calendar.php.

References $name.

163  {
164 
165  $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name);
166  if (!$obj)
167  return false;
168  else
169  return true;
170 
171  }

◆ createDirectory()

Sabre\CalDAV\Calendar::createDirectory (   $name)

Creates a new directory.

We actually block this, as subdirectories are not allowed in calendars.

Parameters
string$name
Returns
void

Implements Sabre\DAV\ICollection.

Definition at line 181 of file Calendar.php.

181  {
182 
183  throw new DAV\Exception\MethodNotAllowed('Creating collections in calendar objects is not allowed');
184 
185  }

◆ createFile()

Sabre\CalDAV\Calendar::createFile (   $name,
  $calendarData = null 
)

Creates a new file.

The contents of the new file must be a valid ICalendar string.

Parameters
string$name
resource$calendarData
Returns
string|null

Implements Sabre\DAV\ICollection.

Definition at line 196 of file Calendar.php.

References $name.

196  {
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  }

◆ delete()

Sabre\CalDAV\Calendar::delete ( )

Deletes the calendar.

Returns
void

Implements Sabre\DAV\INode.

Definition at line 210 of file Calendar.php.

210  {
211 
212  $this->caldavBackend->deleteCalendar($this->calendarInfo['id']);
213 
214  }

◆ getACL()

Sabre\CalDAV\Calendar::getACL ( )

Returns a list of ACE's for this node.

Each ACE has the following properties:

  • 'privilege', a string such as {DAV:}read or {DAV:}write. These are currently the only supported privileges
  • 'principal', a url to the principal who owns the node
  • 'protected' (optional), indicating that this ACE is not allowed to be updated.
Returns
array

Implements Sabre\DAVACL\IACL.

Definition at line 265 of file Calendar.php.

References Sabre\CalDAV\Calendar\getOwner(), and Sabre\CalDAV\Plugin\NS_CALDAV.

265  {
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  }
getOwner()
Returns the owner principal.
Definition: Calendar.php:247
const NS_CALDAV
This is the official CalDAV namespace.
Definition: Plugin.php:33
+ Here is the call graph for this function:

◆ getChanges()

Sabre\CalDAV\Calendar::getChanges (   $syncToken,
  $syncLevel,
  $limit = null 
)

The getChanges method returns all the changes that have happened, since the specified syncToken and the current collection.

This function should return an array, such as the following:

[ 'syncToken' => 'The current synctoken', 'added' => [ 'new.txt', ], 'modified' => [ 'modified.txt', ], 'deleted' => [ 'foo.php.bak', 'old.txt' ] ];

The syncToken property should reflect the current syncToken of the collection, as reported getSyncToken(). This is needed here too, to ensure the operation is atomic.

If the syncToken is specified as null, this is an initial sync, and all members should be reported.

The modified property is an array of nodenames that have changed since the last token.

The deleted property is an array with nodenames, that have been deleted from collection.

The second argument is basically the 'depth' of the report. If it's 1, you only have to report changes that happened only directly in immediate descendants. If it's 2, it should also include changes from the nodes below the child collections. (grandchildren)

The third (optional) argument allows a client to specify how many results should be returned at most. If the limit is not specified, it should be treated as infinite.

If the limit (infinite or not) is higher than you're willing to return, you should throw a Sabre() exception.

If the syncToken is expired (due to data cleanup) or unknown, you must return null.

The limit is 'suggestive'. You are free to ignore it.

Parameters
string$syncToken
int$syncLevel
int$limit
Returns
array

Implements Sabre\DAV\Sync\ISyncCollection.

Definition at line 457 of file Calendar.php.

457  {
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  }

◆ getChild()

Sabre\CalDAV\Calendar::getChild (   $name)

Returns a calendar object.

The contained calendar objects are for example Events or Todo's.

Parameters
string$name
Returns

Implements Sabre\DAV\ICollection.

Definition at line 107 of file Calendar.php.

References $name, and Sabre\CalDAV\Calendar\getChildACL().

107  {
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  }
getChildACL()
This method returns the ACL's for calendar objects in this calendar.
Definition: Calendar.php:314
+ Here is the call graph for this function:

◆ getChildACL()

Sabre\CalDAV\Calendar::getChildACL ( )

This method returns the ACL's for calendar objects in this calendar.

The result of this method automatically gets passed to the calendar-object nodes in the calendar.

Returns
array

Definition at line 314 of file Calendar.php.

References Sabre\CalDAV\Calendar\getOwner().

Referenced by Sabre\CalDAV\Calendar\getChild(), Sabre\CalDAV\Calendar\getChildren(), and Sabre\CalDAV\Calendar\getMultipleChildren().

314  {
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  }
getOwner()
Returns the owner principal.
Definition: Calendar.php:247
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getChildren()

Sabre\CalDAV\Calendar::getChildren ( )

Returns the full list of calendar objects.

Returns
array

Implements Sabre\DAV\ICollection.

Definition at line 124 of file Calendar.php.

References Sabre\CalDAV\Calendar\getChildACL().

124  {
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  }
getChildACL()
This method returns the ACL's for calendar objects in this calendar.
Definition: Calendar.php:314
+ Here is the call graph for this function:

◆ getLastModified()

Sabre\CalDAV\Calendar::getLastModified ( )

Returns the last modification date as a unix timestamp.

Returns
null

Implements Sabre\DAV\INode.

Definition at line 234 of file Calendar.php.

234  {
235 
236  return null;
237 
238  }

◆ getMultipleChildren()

Sabre\CalDAV\Calendar::getMultipleChildren ( array  $paths)

This method receives a list of paths in it's first argument.

It must return an array with Node objects.

If any children are not found, you do not have to return them.

Parameters
string[]$paths
Returns
array

Implements Sabre\DAV\IMultiGet.

Definition at line 145 of file Calendar.php.

References Sabre\CalDAV\Calendar\getChildACL().

145  {
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  }
if($argc< 2) $paths
Definition: migrateto20.php:44
getChildACL()
This method returns the ACL&#39;s for calendar objects in this calendar.
Definition: Calendar.php:314
+ Here is the call graph for this function:

◆ getName()

Sabre\CalDAV\Calendar::getName ( )

Returns the name of the calendar.

Returns
string

Implements Sabre\DAV\INode.

Definition at line 55 of file Calendar.php.

55  {
56 
57  return $this->calendarInfo['uri'];
58 
59  }

◆ getOwner()

Sabre\CalDAV\Calendar::getOwner ( )

Returns the owner principal.

This must be a url to a principal, or null if there's no owner

Returns
string|null

Implements Sabre\DAVACL\IACL.

Definition at line 247 of file Calendar.php.

Referenced by Sabre\CalDAV\Calendar\getACL(), and Sabre\CalDAV\Calendar\getChildACL().

247  {
248 
249  return $this->calendarInfo['principaluri'];
250 
251  }
+ Here is the caller graph for this function:

◆ getProperties()

Sabre\CalDAV\Calendar::getProperties (   $requestedProperties)

Returns the list of properties.

Parameters
array$requestedProperties
Returns
array

Implements Sabre\DAV\IProperties.

Definition at line 85 of file Calendar.php.

References $response.

85  {
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  }
$response

◆ getSyncToken()

Sabre\CalDAV\Calendar::getSyncToken ( )

This method returns the current sync-token for this collection.

This can be any string.

If null is returned from this function, the plugin assumes there's no sync information available.

Returns
string|null

Implements Sabre\DAV\Sync\ISyncCollection.

Definition at line 385 of file Calendar.php.

385  {
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  }

◆ propPatch()

Sabre\CalDAV\Calendar::propPatch ( PropPatch  $propPatch)

Updates properties on this node.

This method received a PropPatch object, which contains all the information about the update.

To update specific properties, call the 'handle' method on this object. Read the PropPatch documentation for more information.

Parameters
PropPatch$propPatch
Returns
void

Implements Sabre\DAV\IProperties.

Definition at line 73 of file Calendar.php.

73  {
74 
75  return $this->caldavBackend->updateCalendar($this->calendarInfo['id'], $propPatch);
76 
77  }

◆ setName()

Sabre\CalDAV\Calendar::setName (   $newName)

Renames the calendar.

Note that most calendars use the {DAV:}displayname to display a name to display a name.

Parameters
string$newName
Returns
void

Implements Sabre\DAV\INode.

Definition at line 223 of file Calendar.php.

223  {
224 
225  throw new DAV\Exception\MethodNotAllowed('Renaming calendars is not yet supported');
226 
227  }

Field Documentation

◆ $caldavBackend

Sabre\CalDAV\Calendar::$caldavBackend
protected

Definition at line 35 of file Calendar.php.

Referenced by Sabre\CalDAV\Calendar\__construct().

◆ $calendarInfo

Sabre\CalDAV\Calendar::$calendarInfo
protected

Definition at line 28 of file Calendar.php.

Referenced by Sabre\CalDAV\Calendar\__construct().


The documentation for this class was generated from the following file: