Outbox.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?php
  2. namespace Sabre\CalDAV\Schedule;
  3. use Sabre\DAV;
  4. use Sabre\CalDAV;
  5. use Sabre\DAVACL;
  6. /**
  7. * The CalDAV scheduling outbox
  8. *
  9. * The outbox is mainly used as an endpoint in the tree for a client to do
  10. * free-busy requests. This functionality is completely handled by the
  11. * Scheduling plugin, so this object is actually mostly static.
  12. *
  13. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  14. * @author Evert Pot (http://evertpot.com/)
  15. * @license http://sabre.io/license/ Modified BSD License
  16. */
  17. class Outbox extends DAV\Collection implements IOutbox {
  18. /**
  19. * The principal Uri
  20. *
  21. * @var string
  22. */
  23. protected $principalUri;
  24. /**
  25. * Constructor
  26. *
  27. * @param string $principalUri
  28. */
  29. function __construct($principalUri) {
  30. $this->principalUri = $principalUri;
  31. }
  32. /**
  33. * Returns the name of the node.
  34. *
  35. * This is used to generate the url.
  36. *
  37. * @return string
  38. */
  39. function getName() {
  40. return 'outbox';
  41. }
  42. /**
  43. * Returns an array with all the child nodes
  44. *
  45. * @return \Sabre\DAV\INode[]
  46. */
  47. function getChildren() {
  48. return [];
  49. }
  50. /**
  51. * Returns the owner principal
  52. *
  53. * This must be a url to a principal, or null if there's no owner
  54. *
  55. * @return string|null
  56. */
  57. function getOwner() {
  58. return $this->principalUri;
  59. }
  60. /**
  61. * Returns a group principal
  62. *
  63. * This must be a url to a principal, or null if there's no owner
  64. *
  65. * @return string|null
  66. */
  67. function getGroup() {
  68. return null;
  69. }
  70. /**
  71. * Returns a list of ACE's for this node.
  72. *
  73. * Each ACE has the following properties:
  74. * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
  75. * currently the only supported privileges
  76. * * 'principal', a url to the principal who owns the node
  77. * * 'protected' (optional), indicating that this ACE is not allowed to
  78. * be updated.
  79. *
  80. * @return array
  81. */
  82. function getACL() {
  83. return [
  84. [
  85. 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-query-freebusy',
  86. 'principal' => $this->getOwner(),
  87. 'protected' => true,
  88. ],
  89. [
  90. 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-post-vevent',
  91. 'principal' => $this->getOwner(),
  92. 'protected' => true,
  93. ],
  94. [
  95. 'privilege' => '{DAV:}read',
  96. 'principal' => $this->getOwner(),
  97. 'protected' => true,
  98. ],
  99. [
  100. 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-query-freebusy',
  101. 'principal' => $this->getOwner() . '/calendar-proxy-write',
  102. 'protected' => true,
  103. ],
  104. [
  105. 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-post-vevent',
  106. 'principal' => $this->getOwner() . '/calendar-proxy-write',
  107. 'protected' => true,
  108. ],
  109. [
  110. 'privilege' => '{DAV:}read',
  111. 'principal' => $this->getOwner() . '/calendar-proxy-read',
  112. 'protected' => true,
  113. ],
  114. [
  115. 'privilege' => '{DAV:}read',
  116. 'principal' => $this->getOwner() . '/calendar-proxy-write',
  117. 'protected' => true,
  118. ],
  119. ];
  120. }
  121. /**
  122. * Updates the ACL
  123. *
  124. * This method will receive a list of new ACE's.
  125. *
  126. * @param array $acl
  127. * @return void
  128. */
  129. function setACL(array $acl) {
  130. throw new DAV\Exception\MethodNotAllowed('You\'re not allowed to update the ACL');
  131. }
  132. /**
  133. * Returns the list of supported privileges for this node.
  134. *
  135. * The returned data structure is a list of nested privileges.
  136. * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple
  137. * standard structure.
  138. *
  139. * If null is returned from this method, the default privilege set is used,
  140. * which is fine for most common usecases.
  141. *
  142. * @return array|null
  143. */
  144. function getSupportedPrivilegeSet() {
  145. $default = DAVACL\Plugin::getDefaultSupportedPrivilegeSet();
  146. $default['aggregates'][] = [
  147. 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-query-freebusy',
  148. ];
  149. $default['aggregates'][] = [
  150. 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-post-vevent',
  151. ];
  152. return $default;
  153. }
  154. }