Outbox.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. declare(strict_types=1);
  3. namespace Sabre\CalDAV\Schedule;
  4. use Sabre\CalDAV;
  5. use Sabre\DAV;
  6. use Sabre\DAVACL;
  7. /**
  8. * The CalDAV scheduling outbox.
  9. *
  10. * The outbox is mainly used as an endpoint in the tree for a client to do
  11. * free-busy requests. This functionality is completely handled by the
  12. * Scheduling plugin, so this object is actually mostly static.
  13. *
  14. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  15. * @author Evert Pot (http://evertpot.com/)
  16. * @license http://sabre.io/license/ Modified BSD License
  17. */
  18. class Outbox extends DAV\Collection implements IOutbox
  19. {
  20. use DAVACL\ACLTrait;
  21. /**
  22. * The principal Uri.
  23. *
  24. * @var string
  25. */
  26. protected $principalUri;
  27. /**
  28. * Constructor.
  29. *
  30. * @param string $principalUri
  31. */
  32. public function __construct($principalUri)
  33. {
  34. $this->principalUri = $principalUri;
  35. }
  36. /**
  37. * Returns the name of the node.
  38. *
  39. * This is used to generate the url.
  40. *
  41. * @return string
  42. */
  43. public function getName()
  44. {
  45. return 'outbox';
  46. }
  47. /**
  48. * Returns an array with all the child nodes.
  49. *
  50. * @return \Sabre\DAV\INode[]
  51. */
  52. public function getChildren()
  53. {
  54. return [];
  55. }
  56. /**
  57. * Returns the owner principal.
  58. *
  59. * This must be a url to a principal, or null if there's no owner
  60. *
  61. * @return string|null
  62. */
  63. public function getOwner()
  64. {
  65. return $this->principalUri;
  66. }
  67. /**
  68. * Returns a list of ACE's for this node.
  69. *
  70. * Each ACE has the following properties:
  71. * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
  72. * currently the only supported privileges
  73. * * 'principal', a url to the principal who owns the node
  74. * * 'protected' (optional), indicating that this ACE is not allowed to
  75. * be updated.
  76. *
  77. * @return array
  78. */
  79. public function getACL()
  80. {
  81. return [
  82. [
  83. 'privilege' => '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-send',
  84. 'principal' => $this->getOwner(),
  85. 'protected' => true,
  86. ],
  87. [
  88. 'privilege' => '{DAV:}read',
  89. 'principal' => $this->getOwner(),
  90. 'protected' => true,
  91. ],
  92. [
  93. 'privilege' => '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-send',
  94. 'principal' => $this->getOwner().'/calendar-proxy-write',
  95. 'protected' => true,
  96. ],
  97. [
  98. 'privilege' => '{DAV:}read',
  99. 'principal' => $this->getOwner().'/calendar-proxy-read',
  100. 'protected' => true,
  101. ],
  102. [
  103. 'privilege' => '{DAV:}read',
  104. 'principal' => $this->getOwner().'/calendar-proxy-write',
  105. 'protected' => true,
  106. ],
  107. ];
  108. }
  109. }