ACLTrait.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. declare(strict_types=1);
  3. namespace Sabre\DAVACL;
  4. /**
  5. * This trait is a default implementation of the IACL interface.
  6. *
  7. * In many cases you only want to implement 1 or to of the IACL functions,
  8. * this trait allows you to be a bit lazier.
  9. *
  10. * By default this trait grants all privileges to the owner of the resource.
  11. *
  12. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  13. * @author Evert Pot (https://evertpot.com/)
  14. * @license http://sabre.io/license/ Modified BSD License
  15. */
  16. trait ACLTrait
  17. {
  18. /**
  19. * Returns the owner principal.
  20. *
  21. * This must be a url to a principal, or null if there's no owner
  22. *
  23. * @return string|null
  24. */
  25. public function getOwner()
  26. {
  27. return null;
  28. }
  29. /**
  30. * Returns a group principal.
  31. *
  32. * This must be a url to a principal, or null if there's no owner
  33. *
  34. * @return string|null
  35. */
  36. public function getGroup()
  37. {
  38. return null;
  39. }
  40. /**
  41. * Returns a list of ACE's for this node.
  42. *
  43. * Each ACE has the following properties:
  44. * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
  45. * currently the only supported privileges
  46. * * 'principal', a url to the principal who owns the node
  47. * * 'protected' (optional), indicating that this ACE is not allowed to
  48. * be updated.
  49. *
  50. * @return array
  51. */
  52. public function getACL()
  53. {
  54. return [
  55. [
  56. 'privilege' => '{DAV:}all',
  57. 'principal' => '{DAV:}owner',
  58. 'protected' => true,
  59. ],
  60. ];
  61. }
  62. /**
  63. * Updates the ACL.
  64. *
  65. * This method will receive a list of new ACE's as an array argument.
  66. */
  67. public function setACL(array $acl)
  68. {
  69. throw new \Sabre\DAV\Exception\Forbidden('Setting ACL is not supported on this node');
  70. }
  71. /**
  72. * Returns the list of supported privileges for this node.
  73. *
  74. * The returned data structure is a list of nested privileges.
  75. * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple
  76. * standard structure.
  77. *
  78. * If null is returned from this method, the default privilege set is used,
  79. * which is fine for most common usecases.
  80. *
  81. * @return array|null
  82. */
  83. public function getSupportedPrivilegeSet()
  84. {
  85. return null;
  86. }
  87. }