BackendInterface.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. declare(strict_types=1);
  3. namespace Sabre\DAVACL\PrincipalBackend;
  4. /**
  5. * Implement this interface to create your own principal backends.
  6. *
  7. * Creating backends for principals is entirely optional. You can also
  8. * implement Sabre\DAVACL\IPrincipal directly. This interface is used solely by
  9. * Sabre\DAVACL\AbstractPrincipalCollection.
  10. *
  11. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  12. * @author Evert Pot (http://evertpot.com/)
  13. * @license http://sabre.io/license/ Modified BSD License
  14. */
  15. interface BackendInterface
  16. {
  17. /**
  18. * Returns a list of principals based on a prefix.
  19. *
  20. * This prefix will often contain something like 'principals'. You are only
  21. * expected to return principals that are in this base path.
  22. *
  23. * You are expected to return at least a 'uri' for every user, you can
  24. * return any additional properties if you wish so. Common properties are:
  25. * {DAV:}displayname
  26. * {http://sabredav.org/ns}email-address - This is a custom SabreDAV
  27. * field that's actually injected in a number of other properties. If
  28. * you have an email address, use this property.
  29. *
  30. * @param string $prefixPath
  31. *
  32. * @return array
  33. */
  34. public function getPrincipalsByPrefix($prefixPath);
  35. /**
  36. * Returns a specific principal, specified by it's path.
  37. * The returned structure should be the exact same as from
  38. * getPrincipalsByPrefix.
  39. *
  40. * @param string $path
  41. *
  42. * @return array
  43. */
  44. public function getPrincipalByPath($path);
  45. /**
  46. * Updates one or more webdav properties on a principal.
  47. *
  48. * The list of mutations is stored in a Sabre\DAV\PropPatch object.
  49. * To do the actual updates, you must tell this object which properties
  50. * you're going to process with the handle() method.
  51. *
  52. * Calling the handle method is like telling the PropPatch object "I
  53. * promise I can handle updating this property".
  54. *
  55. * Read the PropPatch documentation for more info and examples.
  56. *
  57. * @param string $path
  58. */
  59. public function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch);
  60. /**
  61. * This method is used to search for principals matching a set of
  62. * properties.
  63. *
  64. * This search is specifically used by RFC3744's principal-property-search
  65. * REPORT.
  66. *
  67. * The actual search should be a unicode-non-case-sensitive search. The
  68. * keys in searchProperties are the WebDAV property names, while the values
  69. * are the property values to search on.
  70. *
  71. * By default, if multiple properties are submitted to this method, the
  72. * various properties should be combined with 'AND'. If $test is set to
  73. * 'anyof', it should be combined using 'OR'.
  74. *
  75. * This method should simply return an array with full principal uri's.
  76. *
  77. * If somebody attempted to search on a property the backend does not
  78. * support, you should simply return 0 results.
  79. *
  80. * You can also just return 0 results if you choose to not support
  81. * searching at all, but keep in mind that this may stop certain features
  82. * from working.
  83. *
  84. * @param string $prefixPath
  85. * @param string $test
  86. *
  87. * @return array
  88. */
  89. public function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof');
  90. /**
  91. * Finds a principal by its URI.
  92. *
  93. * This method may receive any type of uri, but mailto: addresses will be
  94. * the most common.
  95. *
  96. * Implementation of this API is optional. It is currently used by the
  97. * CalDAV system to find principals based on their email addresses. If this
  98. * API is not implemented, some features may not work correctly.
  99. *
  100. * This method must return a relative principal path, or null, if the
  101. * principal was not found or you refuse to find it.
  102. *
  103. * @param string $uri
  104. * @param string $principalPrefix
  105. *
  106. * @return string|null
  107. */
  108. public function findByUri($uri, $principalPrefix);
  109. /**
  110. * Returns the list of members for a group-principal.
  111. *
  112. * @param string $principal
  113. *
  114. * @return array
  115. */
  116. public function getGroupMemberSet($principal);
  117. /**
  118. * Returns the list of groups a principal is a member of.
  119. *
  120. * @param string $principal
  121. *
  122. * @return array
  123. */
  124. public function getGroupMembership($principal);
  125. /**
  126. * Updates the list of group members for a group principal.
  127. *
  128. * The principals should be passed as a list of uri's.
  129. *
  130. * @param string $principal
  131. */
  132. public function setGroupMemberSet($principal, array $members);
  133. }