BackendInterface.php 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <?php
  2. namespace Sabre\CalDAV\Backend;
  3. /**
  4. * Every CalDAV backend must at least implement this interface.
  5. *
  6. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  7. * @author Evert Pot (http://evertpot.com/)
  8. * @license http://sabre.io/license/ Modified BSD License
  9. */
  10. interface BackendInterface {
  11. /**
  12. * Returns a list of calendars for a principal.
  13. *
  14. * Every project is an array with the following keys:
  15. * * id, a unique id that will be used by other functions to modify the
  16. * calendar. This can be the same as the uri or a database key.
  17. * * uri, which is the basename of the uri with which the calendar is
  18. * accessed.
  19. * * principaluri. The owner of the calendar. Almost always the same as
  20. * principalUri passed to this method.
  21. *
  22. * Furthermore it can contain webdav properties in clark notation. A very
  23. * common one is '{DAV:}displayname'.
  24. *
  25. * Many clients also require:
  26. * {urn:ietf:params:xml:ns:caldav}supported-calendar-component-set
  27. * For this property, you can just return an instance of
  28. * Sabre\CalDAV\Property\SupportedCalendarComponentSet.
  29. *
  30. * If you return {http://sabredav.org/ns}read-only and set the value to 1,
  31. * ACL will automatically be put in read-only mode.
  32. *
  33. * @param string $principalUri
  34. * @return array
  35. */
  36. function getCalendarsForUser($principalUri);
  37. /**
  38. * Creates a new calendar for a principal.
  39. *
  40. * If the creation was a success, an id must be returned that can be used to
  41. * reference this calendar in other methods, such as updateCalendar.
  42. *
  43. * @param string $principalUri
  44. * @param string $calendarUri
  45. * @param array $properties
  46. * @return void
  47. */
  48. function createCalendar($principalUri, $calendarUri, array $properties);
  49. /**
  50. * Updates properties for a calendar.
  51. *
  52. * The list of mutations is stored in a Sabre\DAV\PropPatch object.
  53. * To do the actual updates, you must tell this object which properties
  54. * you're going to process with the handle() method.
  55. *
  56. * Calling the handle method is like telling the PropPatch object "I
  57. * promise I can handle updating this property".
  58. *
  59. * Read the PropPatch documentation for more info and examples.
  60. *
  61. * @param string $path
  62. * @param \Sabre\DAV\PropPatch $propPatch
  63. * @return void
  64. */
  65. function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch);
  66. /**
  67. * Delete a calendar and all its objects
  68. *
  69. * @param mixed $calendarId
  70. * @return void
  71. */
  72. function deleteCalendar($calendarId);
  73. /**
  74. * Returns all calendar objects within a calendar.
  75. *
  76. * Every item contains an array with the following keys:
  77. * * calendardata - The iCalendar-compatible calendar data
  78. * * uri - a unique key which will be used to construct the uri. This can
  79. * be any arbitrary string, but making sure it ends with '.ics' is a
  80. * good idea. This is only the basename, or filename, not the full
  81. * path.
  82. * * lastmodified - a timestamp of the last modification time
  83. * * etag - An arbitrary string, surrounded by double-quotes. (e.g.:
  84. * '"abcdef"')
  85. * * size - The size of the calendar objects, in bytes.
  86. * * component - optional, a string containing the type of object, such
  87. * as 'vevent' or 'vtodo'. If specified, this will be used to populate
  88. * the Content-Type header.
  89. *
  90. * Note that the etag is optional, but it's highly encouraged to return for
  91. * speed reasons.
  92. *
  93. * The calendardata is also optional. If it's not returned
  94. * 'getCalendarObject' will be called later, which *is* expected to return
  95. * calendardata.
  96. *
  97. * If neither etag or size are specified, the calendardata will be
  98. * used/fetched to determine these numbers. If both are specified the
  99. * amount of times this is needed is reduced by a great degree.
  100. *
  101. * @param mixed $calendarId
  102. * @return array
  103. */
  104. function getCalendarObjects($calendarId);
  105. /**
  106. * Returns information from a single calendar object, based on it's object
  107. * uri.
  108. *
  109. * The object uri is only the basename, or filename and not a full path.
  110. *
  111. * The returned array must have the same keys as getCalendarObjects. The
  112. * 'calendardata' object is required here though, while it's not required
  113. * for getCalendarObjects.
  114. *
  115. * This method must return null if the object did not exist.
  116. *
  117. * @param mixed $calendarId
  118. * @param string $objectUri
  119. * @return array|null
  120. */
  121. function getCalendarObject($calendarId, $objectUri);
  122. /**
  123. * Returns a list of calendar objects.
  124. *
  125. * This method should work identical to getCalendarObject, but instead
  126. * return all the calendar objects in the list as an array.
  127. *
  128. * If the backend supports this, it may allow for some speed-ups.
  129. *
  130. * @param mixed $calendarId
  131. * @param array $uris
  132. * @return array
  133. */
  134. function getMultipleCalendarObjects($calendarId, array $uris);
  135. /**
  136. * Creates a new calendar object.
  137. *
  138. * The object uri is only the basename, or filename and not a full path.
  139. *
  140. * It is possible to return an etag from this function, which will be used
  141. * in the response to this PUT request. Note that the ETag must be
  142. * surrounded by double-quotes.
  143. *
  144. * However, you should only really return this ETag if you don't mangle the
  145. * calendar-data. If the result of a subsequent GET to this object is not
  146. * the exact same as this request body, you should omit the ETag.
  147. *
  148. * @param mixed $calendarId
  149. * @param string $objectUri
  150. * @param string $calendarData
  151. * @return string|null
  152. */
  153. function createCalendarObject($calendarId, $objectUri, $calendarData);
  154. /**
  155. * Updates an existing calendarobject, based on it's uri.
  156. *
  157. * The object uri is only the basename, or filename and not a full path.
  158. *
  159. * It is possible return an etag from this function, which will be used in
  160. * the response to this PUT request. Note that the ETag must be surrounded
  161. * by double-quotes.
  162. *
  163. * However, you should only really return this ETag if you don't mangle the
  164. * calendar-data. If the result of a subsequent GET to this object is not
  165. * the exact same as this request body, you should omit the ETag.
  166. *
  167. * @param mixed $calendarId
  168. * @param string $objectUri
  169. * @param string $calendarData
  170. * @return string|null
  171. */
  172. function updateCalendarObject($calendarId, $objectUri, $calendarData);
  173. /**
  174. * Deletes an existing calendar object.
  175. *
  176. * The object uri is only the basename, or filename and not a full path.
  177. *
  178. * @param mixed $calendarId
  179. * @param string $objectUri
  180. * @return void
  181. */
  182. function deleteCalendarObject($calendarId, $objectUri);
  183. /**
  184. * Performs a calendar-query on the contents of this calendar.
  185. *
  186. * The calendar-query is defined in RFC4791 : CalDAV. Using the
  187. * calendar-query it is possible for a client to request a specific set of
  188. * object, based on contents of iCalendar properties, date-ranges and
  189. * iCalendar component types (VTODO, VEVENT).
  190. *
  191. * This method should just return a list of (relative) urls that match this
  192. * query.
  193. *
  194. * The list of filters are specified as an array. The exact array is
  195. * documented by Sabre\CalDAV\CalendarQueryParser.
  196. *
  197. * Note that it is extremely likely that getCalendarObject for every path
  198. * returned from this method will be called almost immediately after. You
  199. * may want to anticipate this to speed up these requests.
  200. *
  201. * This method provides a default implementation, which parses *all* the
  202. * iCalendar objects in the specified calendar.
  203. *
  204. * This default may well be good enough for personal use, and calendars
  205. * that aren't very large. But if you anticipate high usage, big calendars
  206. * or high loads, you are strongly adviced to optimize certain paths.
  207. *
  208. * The best way to do so is override this method and to optimize
  209. * specifically for 'common filters'.
  210. *
  211. * Requests that are extremely common are:
  212. * * requests for just VEVENTS
  213. * * requests for just VTODO
  214. * * requests with a time-range-filter on either VEVENT or VTODO.
  215. *
  216. * ..and combinations of these requests. It may not be worth it to try to
  217. * handle every possible situation and just rely on the (relatively
  218. * easy to use) CalendarQueryValidator to handle the rest.
  219. *
  220. * Note that especially time-range-filters may be difficult to parse. A
  221. * time-range filter specified on a VEVENT must for instance also handle
  222. * recurrence rules correctly.
  223. * A good example of how to interprete all these filters can also simply
  224. * be found in Sabre\CalDAV\CalendarQueryFilter. This class is as correct
  225. * as possible, so it gives you a good idea on what type of stuff you need
  226. * to think of.
  227. *
  228. * @param mixed $calendarId
  229. * @param array $filters
  230. * @return array
  231. */
  232. function calendarQuery($calendarId, array $filters);
  233. /**
  234. * Searches through all of a users calendars and calendar objects to find
  235. * an object with a specific UID.
  236. *
  237. * This method should return the path to this object, relative to the
  238. * calendar home, so this path usually only contains two parts:
  239. *
  240. * calendarpath/objectpath.ics
  241. *
  242. * If the uid is not found, return null.
  243. *
  244. * This method should only consider * objects that the principal owns, so
  245. * any calendars owned by other principals that also appear in this
  246. * collection should be ignored.
  247. *
  248. * @param string $principalUri
  249. * @param string $uid
  250. * @return string|null
  251. */
  252. function getCalendarObjectByUID($principalUri, $uid);
  253. }