SharingSupport.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <?php
  2. namespace Sabre\CalDAV\Backend;
  3. /**
  4. * Adds support for sharing features to a CalDAV server.
  5. *
  6. * Note: This feature is experimental, and may change in between different
  7. * SabreDAV versions.
  8. *
  9. * Early warning: Currently SabreDAV provides no implementation for this. This
  10. * is, because in it's current state there is no elegant way to do this.
  11. * The problem lies in the fact that a real CalDAV server with sharing support
  12. * would first need email support (with invite notifications), and really also
  13. * a browser-frontend that allows people to accept or reject these shares.
  14. *
  15. * In addition, the CalDAV backends are currently kept as independent as
  16. * possible, and should not be aware of principals, email addresses or
  17. * accounts.
  18. *
  19. * Adding an implementation for Sharing to standard-sabredav would contradict
  20. * these goals, so for this reason this is currently not implemented, although
  21. * it may very well in the future; but probably not before SabreDAV 2.0.
  22. *
  23. * The interface works however, so if you implement all this, and do it
  24. * correctly sharing _will_ work. It's not particularly easy, and I _urge you_
  25. * to make yourself acquainted with the following document first:
  26. *
  27. * https://trac.calendarserver.org/browser/CalendarServer/trunk/doc/Extensions/caldav-sharing.txt
  28. *
  29. * An overview
  30. * ===========
  31. *
  32. * Implementing this interface will allow a user to share his or her calendars
  33. * to other users. Effectively, when a calendar is shared the calendar will
  34. * show up in both the Sharer's and Sharee's calendar-home root.
  35. * This interface adds a few methods that ensure that this happens, and there
  36. * are also a number of new requirements in the base-class you must now follow.
  37. *
  38. *
  39. * How it works
  40. * ============
  41. *
  42. * When a user shares a calendar, the updateShares() method will be called with
  43. * a list of sharees that are now added, and a list of sharees that have been
  44. * removed.
  45. * Removal is instant, but when a sharee is added the sharee first gets a
  46. * chance to accept or reject the invitation for a share.
  47. *
  48. * After a share is accepted, the calendar will be returned from
  49. * getUserCalendars for both the sharer, and the sharee.
  50. *
  51. * If the sharee deletes the calendar, only their share gets deleted. When the
  52. * owner deletes a calendar, it will be removed for everybody.
  53. *
  54. *
  55. * Notifications
  56. * =============
  57. *
  58. * During all these sharing operations, a lot of notifications are sent back
  59. * and forward.
  60. *
  61. * Whenever the list of sharees for a calendar has been changed (they have been
  62. * added, removed or modified) all sharees should get a notification for this
  63. * change.
  64. * This notification is always represented by:
  65. *
  66. * Sabre\CalDAV\Notifications\Notification\Invite
  67. *
  68. * In the case of an invite, the sharee may reply with an 'accept' or
  69. * 'decline'. These are always represented by:
  70. *
  71. * Sabre\CalDAV\Notifications\Notification\InviteReply
  72. *
  73. *
  74. * Calendar access by sharees
  75. * ==========================
  76. *
  77. * As mentioned earlier, shared calendars must now also be returned for
  78. * getCalendarsForUser for sharees. A few things change though.
  79. *
  80. * The following properties must be specified:
  81. *
  82. * 1. {http://calendarserver.org/ns/}shared-url
  83. *
  84. * This property MUST contain the url to the original calendar, that is.. the
  85. * path to the calendar from the owner.
  86. *
  87. * 2. {http://sabredav.org/ns}owner-principal
  88. *
  89. * This is a url to to the principal who is sharing the calendar.
  90. *
  91. * 3. {http://sabredav.org/ns}read-only
  92. *
  93. * This should be either 0 or 1, depending on if the user has read-only or
  94. * read-write access to the calendar.
  95. *
  96. * Only when this is done, the calendar will correctly be marked as a calendar
  97. * that's shared to him, thus allowing clients to display the correct interface
  98. * and ACL enforcement.
  99. *
  100. * If a sharee deletes their calendar, only their instance of the calendar
  101. * should be deleted, the original should still exists.
  102. * Pretty much any 'dead' WebDAV properties on these shared calendars should be
  103. * specific to a user. This means that if the displayname is changed by a
  104. * sharee, the original is not affected. This is also true for:
  105. * * The description
  106. * * The color
  107. * * The order
  108. * * And any other dead properties.
  109. *
  110. * Properties like a ctag should not be different for multiple instances of the
  111. * calendar.
  112. *
  113. * Lastly, objects *within* calendars should also have user-specific data. The
  114. * two things that are user-specific are:
  115. * * VALARM objects
  116. * * The TRANSP property
  117. *
  118. * This _also_ implies that if a VALARM is deleted by a sharee for some event,
  119. * this has no effect on the original VALARM.
  120. *
  121. * Understandably, the this last requirement is one of the hardest.
  122. * Realisticly, I can see people ignoring this part of the spec, but that could
  123. * cause a different set of issues.
  124. *
  125. *
  126. * Publishing
  127. * ==========
  128. *
  129. * When a user publishes a url, the server should generate a 'publish url'.
  130. * This is a read-only url, anybody can use to consume the calendar feed.
  131. *
  132. * Calendars are in one of two states:
  133. * * published
  134. * * unpublished
  135. *
  136. * If a calendar is published, the following property should be returned
  137. * for each calendar in getCalendarsForUser.
  138. *
  139. * {http://calendarserver.org/ns/}publish-url
  140. *
  141. * This element should contain a {DAV:}href element, which points to the
  142. * public url that does not require authentication. Unlike every other href,
  143. * this url must be absolute.
  144. *
  145. * Ideally, the following property is always returned
  146. *
  147. * {http://calendarserver.org/ns/}pre-publish-url
  148. *
  149. * This property should contain the url that the calendar _would_ have, if it
  150. * were to be published. iCal uses this to display the url, before the user
  151. * will actually publish it.
  152. *
  153. *
  154. * Selectively disabling publish or share feature
  155. * ==============================================
  156. *
  157. * If Sabre\CalDAV\Property\AllowedSharingModes is returned from
  158. * getCalendarsForUser, this allows the server to specify whether either sharing,
  159. * or publishing is supported.
  160. *
  161. * This allows a client to determine in advance which features are available,
  162. * and update the interface appropriately. If this property is not returned by
  163. * the backend, the SharingPlugin automatically injects it and assumes both
  164. * features are available.
  165. *
  166. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  167. * @author Evert Pot (http://evertpot.com/)
  168. * @license http://sabre.io/license/ Modified BSD License
  169. */
  170. interface SharingSupport extends NotificationSupport {
  171. /**
  172. * Updates the list of shares.
  173. *
  174. * The first array is a list of people that are to be added to the
  175. * calendar.
  176. *
  177. * Every element in the add array has the following properties:
  178. * * href - A url. Usually a mailto: address
  179. * * commonName - Usually a first and last name, or false
  180. * * summary - A description of the share, can also be false
  181. * * readOnly - A boolean value
  182. *
  183. * Every element in the remove array is just the address string.
  184. *
  185. * Note that if the calendar is currently marked as 'not shared' by and
  186. * this method is called, the calendar should be 'upgraded' to a shared
  187. * calendar.
  188. *
  189. * @param mixed $calendarId
  190. * @param array $add
  191. * @param array $remove
  192. * @return void
  193. */
  194. function updateShares($calendarId, array $add, array $remove);
  195. /**
  196. * Returns the list of people whom this calendar is shared with.
  197. *
  198. * Every element in this array should have the following properties:
  199. * * href - Often a mailto: address
  200. * * commonName - Optional, for example a first + last name
  201. * * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants.
  202. * * readOnly - boolean
  203. * * summary - Optional, a description for the share
  204. *
  205. * This method may be called by either the original instance of the
  206. * calendar, as well as the shared instances. In the case of the shared
  207. * instances, it is perfectly acceptable to return an empty array in case
  208. * there are privacy concerns.
  209. *
  210. * @param mixed $calendarId
  211. * @return array
  212. */
  213. function getShares($calendarId);
  214. /**
  215. * This method is called when a user replied to a request to share.
  216. *
  217. * If the user chose to accept the share, this method should return the
  218. * newly created calendar url.
  219. *
  220. * @param string href The sharee who is replying (often a mailto: address)
  221. * @param int status One of the SharingPlugin::STATUS_* constants
  222. * @param string $calendarUri The url to the calendar thats being shared
  223. * @param string $inReplyTo The unique id this message is a response to
  224. * @param string $summary A description of the reply
  225. * @return null|string
  226. */
  227. function shareReply($href, $status, $calendarUri, $inReplyTo, $summary = null);
  228. /**
  229. * Publishes a calendar
  230. *
  231. * @param mixed $calendarId
  232. * @param bool $value
  233. * @return void
  234. */
  235. function setPublishStatus($calendarId, $value);
  236. }