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

Abstract Calendaring backend. More...

+ Inheritance diagram for Sabre\CalDAV\Backend\AbstractBackend:
+ Collaboration diagram for Sabre\CalDAV\Backend\AbstractBackend:

Public Member Functions

 updateCalendar ($calendarId, \Sabre\DAV\PropPatch $propPatch)
 Updates properties for a calendar. More...
 
 getMultipleCalendarObjects ($calendarId, array $uris)
 Returns a list of calendar objects. More...
 
 calendarQuery ($calendarId, array $filters)
 Performs a calendar-query on the contents of this calendar. More...
 
 getCalendarObjectByUID ($principalUri, $uid)
 Searches through all of a users calendars and calendar objects to find an object with a specific UID. More...
 
- Public Member Functions inherited from Sabre\CalDAV\Backend\BackendInterface
 getCalendarsForUser ($principalUri)
 Returns a list of calendars for a principal. More...
 
 createCalendar ($principalUri, $calendarUri, array $properties)
 Creates a new calendar for a principal. More...
 
 deleteCalendar ($calendarId)
 Delete a calendar and all its objects. More...
 
 getCalendarObjects ($calendarId)
 Returns all calendar objects within a calendar. More...
 
 getCalendarObject ($calendarId, $objectUri)
 Returns information from a single calendar object, based on it's object uri. More...
 
 createCalendarObject ($calendarId, $objectUri, $calendarData)
 Creates a new calendar object. More...
 
 updateCalendarObject ($calendarId, $objectUri, $calendarData)
 Updates an existing calendarobject, based on it's uri. More...
 
 deleteCalendarObject ($calendarId, $objectUri)
 Deletes an existing calendar object. More...
 

Protected Member Functions

 validateFilterForObject (array $object, array $filters)
 This method validates if a filter (as passed to calendarQuery) matches the given object. More...
 

Detailed Description

Abstract Calendaring backend.

Extend this class to create your own backends.

Checkout the BackendInterface for all the methods that must be implemented.

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

Definition at line 17 of file AbstractBackend.php.

Member Function Documentation

◆ calendarQuery()

Sabre\CalDAV\Backend\AbstractBackend::calendarQuery (   $calendarId,
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 .

Note that it is extremely likely that getCalendarObject for every path returned from this method will be called almost immediately after. You may want to anticipate this to speed up these requests.

This method provides a default implementation, which parses all the iCalendar objects in the specified calendar.

This default may well be good enough for personal use, and calendars that aren't very large. But if you anticipate high usage, big calendars or high loads, you are strongly adviced to optimize certain paths.

The best way to do so is override this method and to optimize specifically for 'common filters'.

Requests that are extremely common are:

  • requests for just VEVENTS
  • requests for just VTODO
  • requests with a time-range-filter on either VEVENT or VTODO.

..and combinations of these requests. It may not be worth it to try to handle every possible situation and just rely on the (relatively easy to use) CalendarQueryValidator to handle the rest.

Note that especially time-range-filters may be difficult to parse. A time-range filter specified on a VEVENT must for instance also handle recurrence rules correctly. A good example of how to interprete all these filters can also simply be found in . This class is as correct as possible, so it gives you a good idea on what type of stuff you need to think of.

Parameters
mixed$calendarId
array$filters
Returns
array

Implements Sabre\CalDAV\Backend\BackendInterface.

Definition at line 108 of file AbstractBackend.php.

References $result, Sabre\CalDAV\Backend\BackendInterface\getCalendarObjects(), and Sabre\CalDAV\Backend\AbstractBackend\validateFilterForObject().

Referenced by Sabre\CalDAV\Backend\AbstractBackend\getCalendarObjectByUID().

108  {
109 
110  $result = [];
111  $objects = $this->getCalendarObjects($calendarId);
112 
113  foreach ($objects as $object) {
114 
115  if ($this->validateFilterForObject($object, $filters)) {
116  $result[] = $object['uri'];
117  }
118 
119  }
120 
121  return $result;
122 
123  }
$result
getCalendarObjects($calendarId)
Returns all calendar objects within a calendar.
validateFilterForObject(array $object, array $filters)
This method validates if a filter (as passed to calendarQuery) matches the given object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCalendarObjectByUID()

Sabre\CalDAV\Backend\AbstractBackend::getCalendarObjectByUID (   $principalUri,
  $uid 
)

Searches through all of a users calendars and calendar objects to find an object with a specific UID.

This method should return the path to this object, relative to the calendar home, so this path usually only contains two parts:

calendarpath/objectpath.ics

If the uid is not found, return null.

This method should only consider * objects that the principal owns, so any calendars owned by other principals that also appear in this collection should be ignored.

Parameters
string$principalUri
string$uid
Returns
string|null

Implements Sabre\CalDAV\Backend\BackendInterface.

Definition at line 173 of file AbstractBackend.php.

References $calendar, $results, Sabre\CalDAV\Backend\AbstractBackend\calendarQuery(), and Sabre\CalDAV\Backend\BackendInterface\getCalendarsForUser().

173  {
174 
175  // Note: this is a super slow naive implementation of this method. You
176  // are highly recommended to optimize it, if your backend allows it.
177  foreach ($this->getCalendarsForUser($principalUri) as $calendar) {
178 
179  // We must ignore calendars owned by other principals.
180  if ($calendar['principaluri'] !== $principalUri) {
181  continue;
182  }
183 
184  // Ignore calendars that are shared.
185  if (isset($calendar['{http://sabredav.org/ns}owner-principal']) && $calendar['{http://sabredav.org/ns}owner-principal'] !== $principalUri) {
186  continue;
187  }
188 
189  $results = $this->calendarQuery(
190  $calendar['id'],
191  [
192  'name' => 'VCALENDAR',
193  'prop-filters' => [],
194  'comp-filters' => [
195  [
196  'name' => 'VEVENT',
197  'is-not-defined' => false,
198  'time-range' => null,
199  'comp-filters' => [],
200  'prop-filters' => [
201  [
202  'name' => 'UID',
203  'is-not-defined' => false,
204  'time-range' => null,
205  'text-match' => [
206  'value' => $uid,
207  'negate-condition' => false,
208  'collation' => 'i;octet',
209  ],
210  'param-filters' => [],
211  ],
212  ]
213  ]
214  ],
215  ]
216  );
217  if ($results) {
218  // We have a match
219  return $calendar['uri'] . '/' . $results[0];
220  }
221 
222  }
223 
224  }
calendarQuery($calendarId, array $filters)
Performs a calendar-query on the contents of this calendar.
getCalendarsForUser($principalUri)
Returns a list of calendars for a principal.
$results
Definition: svg-scanner.php:47
+ Here is the call graph for this function:

◆ getMultipleCalendarObjects()

Sabre\CalDAV\Backend\AbstractBackend::getMultipleCalendarObjects (   $calendarId,
array  $uris 
)

Returns a list of calendar objects.

This method should work identical to getCalendarObject, but instead return all the calendar objects in the list as an array.

If the backend supports this, it may allow for some speed-ups.

Parameters
mixed$calendarId
array$uris
Returns
array

Implements Sabre\CalDAV\Backend\BackendInterface.

Definition at line 51 of file AbstractBackend.php.

References Sabre\CalDAV\Backend\BackendInterface\getCalendarObject().

51  {
52 
53  return array_map(function($uri) use ($calendarId) {
54  return $this->getCalendarObject($calendarId, $uri);
55  }, $uris);
56 
57  }
getCalendarObject($calendarId, $objectUri)
Returns information from a single calendar object, based on it's object uri.
+ Here is the call graph for this function:

◆ updateCalendar()

Sabre\CalDAV\Backend\AbstractBackend::updateCalendar (   $calendarId,
\Sabre\DAV\PropPatch  $propPatch 
)

Updates properties for a calendar.

The list of mutations is stored in a Sabre object. To do the actual updates, you must tell this object which properties you're going to process with the handle() method.

Calling the handle method is like telling the PropPatch object "I promise I can handle updating this property".

Read the PropPatch documentation for more info and examples.

Parameters
mixed$calendarId
\Sabre\DAV\PropPatch$propPatch
Returns
void

Implements Sabre\CalDAV\Backend\BackendInterface.

Definition at line 35 of file AbstractBackend.php.

35  {
36 
37  }

◆ validateFilterForObject()

Sabre\CalDAV\Backend\AbstractBackend::validateFilterForObject ( array  $object,
array  $filters 
)
protected

This method validates if a filter (as passed to calendarQuery) matches the given object.

Parameters
array$object
array$filters
Returns
bool

Definition at line 133 of file AbstractBackend.php.

References $result, Sabre\CalDAV\Backend\BackendInterface\getCalendarObject(), and Sabre\VObject\Reader\read().

Referenced by Sabre\CalDAV\Backend\AbstractBackend\calendarQuery(), and Sabre\CalDAV\Backend\PDO\calendarQuery().

133  {
134 
135  // Unfortunately, setting the 'calendardata' here is optional. If
136  // it was excluded, we actually need another call to get this as
137  // well.
138  if (!isset($object['calendardata'])) {
139  $object = $this->getCalendarObject($object['calendarid'], $object['uri']);
140  }
141 
142  $vObject = VObject\Reader::read($object['calendardata']);
143 
144  $validator = new CalDAV\CalendarQueryValidator();
145  $result = $validator->validate($vObject, $filters);
146 
147  // Destroy circular references so PHP will GC the object.
148  $vObject->destroy();
149 
150  return $result;
151 
152  }
$result
getCalendarObject($calendarId, $objectUri)
Returns information from a single calendar object, based on it's object uri.
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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