]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/lib/Sabre/CalDAV/Backend/BackendInterface.php
Merge branch '3.6-release'
[friendica-addons.git] / dav / SabreDAV / lib / Sabre / CalDAV / Backend / BackendInterface.php
1 <?php
2
3 /**
4  * Every CalDAV backend must at least implement this interface.
5  * 
6  * @package Sabre
7  * @subpackage CalDAV
8  * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
9  * @author Evert Pot (http://www.rooftopsolutions.nl/) 
10  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
11  */
12 interface Sabre_CalDAV_Backend_BackendInterface {
13
14     /**
15      * Returns a list of calendars for a principal.
16      *
17      * Every project is an array with the following keys:
18      *  * id, a unique id that will be used by other functions to modify the
19      *    calendar. This can be the same as the uri or a database key.
20      *  * uri, which the basename of the uri with which the calendar is
21      *    accessed.
22      *  * principaluri. The owner of the calendar. Almost always the same as
23      *    principalUri passed to this method.
24      *
25      * Furthermore it can contain webdav properties in clark notation. A very
26      * common one is '{DAV:}displayname'.
27      *
28      * @param string $principalUri
29      * @return array
30      */
31     public function getCalendarsForUser($principalUri);
32
33     /**
34      * Creates a new calendar for a principal.
35      *
36      * If the creation was a success, an id must be returned that can be used to reference
37      * this calendar in other methods, such as updateCalendar.
38      *
39      * @param string $principalUri
40      * @param string $calendarUri
41      * @param array $properties
42      * @return void
43      */
44     public function createCalendar($principalUri,$calendarUri,array $properties);
45
46     /**
47      * Updates properties for a calendar.
48      *
49      * The mutations array uses the propertyName in clark-notation as key,
50      * and the array value for the property value. In the case a property
51      * should be deleted, the property value will be null.
52      *
53      * This method must be atomic. If one property cannot be changed, the
54      * entire operation must fail.
55      *
56      * If the operation was successful, true can be returned.
57      * If the operation failed, false can be returned.
58      *
59      * Deletion of a non-existent property is always successful.
60      *
61      * Lastly, it is optional to return detailed information about any
62      * failures. In this case an array should be returned with the following
63      * structure:
64      *
65      * array(
66      *   403 => array(
67      *      '{DAV:}displayname' => null,
68      *   ),
69      *   424 => array(
70      *      '{DAV:}owner' => null,
71      *   )
72      * )
73      *
74      * In this example it was forbidden to update {DAV:}displayname.
75      * (403 Forbidden), which in turn also caused {DAV:}owner to fail
76      * (424 Failed Dependency) because the request needs to be atomic.
77      *
78      * @param mixed $calendarId
79      * @param array $mutations
80      * @return bool|array
81      */
82     public function updateCalendar($calendarId, array $mutations); 
83
84     /**
85      * Delete a calendar and all it's objects
86      *
87      * @param mixed $calendarId
88      * @return void
89      */
90     public function deleteCalendar($calendarId);
91
92     /**
93      * Returns all calendar objects within a calendar.
94      *
95      * Every item contains an array with the following keys:
96      *   * id - unique identifier which will be used for subsequent updates
97      *   * calendardata - The iCalendar-compatible calendar data
98      *   * uri - a unique key which will be used to construct the uri. This can be any arbitrary string.
99      *   * lastmodified - a timestamp of the last modification time
100      *   * etag - An arbitrary string, surrounded by double-quotes. (e.g.:
101      *   '  "abcdef"')
102      *   * calendarid - The calendarid as it was passed to this function.
103      *   * size - The size of the calendar objects, in bytes.
104      *
105      * Note that the etag is optional, but it's highly encouraged to return for
106      * speed reasons.
107      *
108      * The calendardata is also optional. If it's not returned
109      * 'getCalendarObject' will be called later, which *is* expected to return
110      * calendardata.
111      *
112      * If neither etag or size are specified, the calendardata will be
113      * used/fetched to determine these numbers. If both are specified the
114      * amount of times this is needed is reduced by a great degree.
115      *
116      * @param mixed $calendarId
117      * @return array
118      */
119     public function getCalendarObjects($calendarId);
120
121     /**
122      * Returns information from a single calendar object, based on it's object
123      * uri.
124      *
125      * The returned array must have the same keys as getCalendarObjects. The
126      * 'calendardata' object is required here though, while it's not required
127      * for getCalendarObjects.
128      *
129      * @param mixed $calendarId
130      * @param string $objectUri
131      * @return array
132      */
133     public function getCalendarObject($calendarId,$objectUri);
134
135     /**
136      * Creates a new calendar object.
137      *
138      * It is possible return an etag from this function, which will be used in
139      * the response to this PUT request. Note that the ETag must be surrounded
140      * by double-quotes.
141      *
142      * However, you should only really return this ETag if you don't mangle the
143      * calendar-data. If the result of a subsequent GET to this object is not
144      * the exact same as this request body, you should omit the ETag.
145      *
146      * @param mixed $calendarId
147      * @param string $objectUri
148      * @param string $calendarData
149      * @return string|null
150      */
151     public function createCalendarObject($calendarId,$objectUri,$calendarData);
152
153     /**
154      * Updates an existing calendarobject, based on it's uri.
155      *
156      * It is possible return an etag from this function, which will be used in
157      * the response to this PUT request. Note that the ETag must be surrounded
158      * by double-quotes.
159      *
160      * However, you should only really return this ETag if you don't mangle the
161      * calendar-data. If the result of a subsequent GET to this object is not
162      * the exact same as this request body, you should omit the ETag.
163      *
164      * @param mixed $calendarId
165      * @param string $objectUri
166      * @param string $calendarData
167      * @return string|null
168      */
169     public function updateCalendarObject($calendarId,$objectUri,$calendarData);
170
171     /**
172      * Deletes an existing calendar object.
173      *
174      * @param mixed $calendarId
175      * @param string $objectUri
176      * @return void
177      */
178     public function deleteCalendarObject($calendarId,$objectUri);
179
180     /**
181      * Performs a calendar-query on the contents of this calendar.
182      *
183      * The calendar-query is defined in RFC4791 : CalDAV. Using the
184      * calendar-query it is possible for a client to request a specific set of
185      * object, based on contents of iCalendar properties, date-ranges and
186      * iCalendar component types (VTODO, VEVENT).
187      *
188      * This method should just return a list of (relative) urls that match this
189      * query.
190      *
191      * The list of filters are specified as an array. The exact array is
192      * documented by Sabre_CalDAV_CalendarQueryParser.
193      *
194      * Note that it is extremely likely that getCalendarObject for every path
195      * returned from this method will be called almost immediately after. You
196      * may want to anticipate this to speed up these requests.
197      *
198      * This method provides a default implementation, which parses *all* the
199      * iCalendar objects in the specified calendar.
200      *
201      * This default may well be good enough for personal use, and calendars
202      * that aren't very large. But if you anticipate high usage, big calendars
203      * or high loads, you are strongly adviced to optimize certain paths.
204      *
205      * The best way to do so is override this method and to optimize
206      * specifically for 'common filters'.
207      *
208      * Requests that are extremely common are:
209      *   * requests for just VEVENTS
210      *   * requests for just VTODO
211      *   * requests with a time-range-filter on either VEVENT or VTODO.
212      *
213      * ..and combinations of these requests. It may not be worth it to try to
214      * handle every possible situation and just rely on the (relatively
215      * easy to use) CalendarQueryValidator to handle the rest.
216      *
217      * Note that especially time-range-filters may be difficult to parse. A
218      * time-range filter specified on a VEVENT must for instance also handle
219      * recurrence rules correctly.
220      * A good example of how to interprete all these filters can also simply
221      * be found in Sabre_CalDAV_CalendarQueryFilter. This class is as correct
222      * as possible, so it gives you a good idea on what type of stuff you need
223      * to think of.
224      *
225      * @param mixed $calendarId
226      * @param array $filters
227      * @return array
228      */
229     public function calendarQuery($calendarId, array $filters); 
230
231 }