IPrincipalBackend.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. /**
  3. * Implement this interface to create your own principal backends.
  4. *
  5. * Creating backends for principals is entirely optional. You can also
  6. * implement Sabre_DAVACL_IPrincipal directly. This interface is used solely by
  7. * Sabre_DAVACL_AbstractPrincipalCollection.
  8. *
  9. * @package Sabre
  10. * @subpackage DAVACL
  11. * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
  12. * @author Evert Pot (http://www.rooftopsolutions.nl/)
  13. * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
  14. */
  15. interface Sabre_DAVACL_IPrincipalBackend {
  16. /**
  17. * Returns a list of principals based on a prefix.
  18. *
  19. * This prefix will often contain something like 'principals'. You are only
  20. * expected to return principals that are in this base path.
  21. *
  22. * You are expected to return at least a 'uri' for every user, you can
  23. * return any additional properties if you wish so. Common properties are:
  24. * {DAV:}displayname
  25. * {http://sabredav.org/ns}email-address - This is a custom SabreDAV
  26. * field that's actually injected in a number of other properties. If
  27. * you have an email address, use this property.
  28. *
  29. * @param string $prefixPath
  30. * @return array
  31. */
  32. function getPrincipalsByPrefix($prefixPath);
  33. /**
  34. * Returns a specific principal, specified by it's path.
  35. * The returned structure should be the exact same as from
  36. * getPrincipalsByPrefix.
  37. *
  38. * @param string $path
  39. * @return array
  40. */
  41. function getPrincipalByPath($path);
  42. /**
  43. * Updates one ore more webdav properties on a principal.
  44. *
  45. * The list of mutations is supplied as an array. Each key in the array is
  46. * a propertyname, such as {DAV:}displayname.
  47. *
  48. * Each value is the actual value to be updated. If a value is null, it
  49. * must be deleted.
  50. *
  51. * This method should be atomic. It must either completely succeed, or
  52. * completely fail. Success and failure can simply be returned as 'true' or
  53. * 'false'.
  54. *
  55. * It is also possible to return detailed failure information. In that case
  56. * an array such as this should be returned:
  57. *
  58. * array(
  59. * 200 => array(
  60. * '{DAV:}prop1' => null,
  61. * ),
  62. * 201 => array(
  63. * '{DAV:}prop2' => null,
  64. * ),
  65. * 403 => array(
  66. * '{DAV:}prop3' => null,
  67. * ),
  68. * 424 => array(
  69. * '{DAV:}prop4' => null,
  70. * ),
  71. * );
  72. *
  73. * In this previous example prop1 was successfully updated or deleted, and
  74. * prop2 was succesfully created.
  75. *
  76. * prop3 failed to update due to '403 Forbidden' and because of this prop4
  77. * also could not be updated with '424 Failed dependency'.
  78. *
  79. * This last example was actually incorrect. While 200 and 201 could appear
  80. * in 1 response, if there's any error (403) the other properties should
  81. * always fail with 423 (failed dependency).
  82. *
  83. * But anyway, if you don't want to scratch your head over this, just
  84. * return true or false.
  85. *
  86. * @param string $path
  87. * @param array $mutations
  88. * @return array|bool
  89. */
  90. function updatePrincipal($path, $mutations);
  91. /**
  92. * This method is used to search for principals matching a set of
  93. * properties.
  94. *
  95. * This search is specifically used by RFC3744's principal-property-search
  96. * REPORT. You should at least allow searching on
  97. * http://sabredav.org/ns}email-address.
  98. *
  99. * The actual search should be a unicode-non-case-sensitive search. The
  100. * keys in searchProperties are the WebDAV property names, while the values
  101. * are the property values to search on.
  102. *
  103. * If multiple properties are being searched on, the search should be
  104. * AND'ed.
  105. *
  106. * This method should simply return an array with full principal uri's.
  107. *
  108. * If somebody attempted to search on a property the backend does not
  109. * support, you should simply return 0 results.
  110. *
  111. * You can also just return 0 results if you choose to not support
  112. * searching at all, but keep in mind that this may stop certain features
  113. * from working.
  114. *
  115. * @param string $prefixPath
  116. * @param array $searchProperties
  117. * @return array
  118. */
  119. function searchPrincipals($prefixPath, array $searchProperties);
  120. /**
  121. * Returns the list of members for a group-principal
  122. *
  123. * @param string $principal
  124. * @return array
  125. */
  126. function getGroupMemberSet($principal);
  127. /**
  128. * Returns the list of groups a principal is a member of
  129. *
  130. * @param string $principal
  131. * @return array
  132. */
  133. function getGroupMembership($principal);
  134. /**
  135. * Updates the list of group members for a group principal.
  136. *
  137. * The principals should be passed as a list of uri's.
  138. *
  139. * @param string $principal
  140. * @param array $members
  141. * @return void
  142. */
  143. function setGroupMemberSet($principal, array $members);
  144. }