IGroupManager.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Bernhard Posselt <dev@bernhard-posselt.com>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  9. * @author Lukas Reschke <lukas@statuscode.ch>
  10. * @author Morris Jobke <hey@morrisjobke.de>
  11. * @author Robin Appelman <robin@icewind.nl>
  12. * @author Roeland Jago Douma <roeland@famdouma.nl>
  13. * @author Thomas Müller <thomas.mueller@tmit.eu>
  14. * @author Vinicius Cubas Brand <vinicius@eita.org.br>
  15. *
  16. * @license AGPL-3.0
  17. *
  18. * This code is free software: you can redistribute it and/or modify
  19. * it under the terms of the GNU Affero General Public License, version 3,
  20. * as published by the Free Software Foundation.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU Affero General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU Affero General Public License, version 3,
  28. * along with this program. If not, see <http://www.gnu.org/licenses/>
  29. *
  30. */
  31. namespace OCP;
  32. /**
  33. * Class Manager
  34. *
  35. * Hooks available in scope \OC\Group:
  36. * - preAddUser(\OC\Group\Group $group, \OC\User\User $user)
  37. * - postAddUser(\OC\Group\Group $group, \OC\User\User $user)
  38. * - preRemoveUser(\OC\Group\Group $group, \OC\User\User $user)
  39. * - postRemoveUser(\OC\Group\Group $group, \OC\User\User $user)
  40. * - preDelete(\OC\Group\Group $group)
  41. * - postDelete(\OC\Group\Group $group)
  42. * - preCreate(string $groupId)
  43. * - postCreate(\OC\Group\Group $group)
  44. *
  45. * @since 8.0.0
  46. */
  47. interface IGroupManager {
  48. /**
  49. * Checks whether a given backend is used
  50. *
  51. * @param string $backendClass Full classname including complete namespace
  52. * @return bool
  53. * @since 8.1.0
  54. */
  55. public function isBackendUsed($backendClass);
  56. /**
  57. * @param \OCP\GroupInterface $backend
  58. * @since 8.0.0
  59. */
  60. public function addBackend($backend);
  61. /**
  62. * @since 8.0.0
  63. */
  64. public function clearBackends();
  65. /**
  66. * Get the active backends
  67. * @return \OCP\GroupInterface[]
  68. * @since 13.0.0
  69. */
  70. public function getBackends();
  71. /**
  72. * @param string $gid
  73. * @return \OCP\IGroup|null
  74. * @since 8.0.0
  75. */
  76. public function get($gid);
  77. /**
  78. * @param string $gid
  79. * @return bool
  80. * @since 8.0.0
  81. */
  82. public function groupExists($gid);
  83. /**
  84. * @param string $gid
  85. * @return \OCP\IGroup|null
  86. * @since 8.0.0
  87. */
  88. public function createGroup($gid);
  89. /**
  90. * @param string $search
  91. * @param ?int $limit
  92. * @param ?int $offset
  93. * @return \OCP\IGroup[]
  94. * @since 8.0.0
  95. */
  96. public function search(string $search, ?int $limit = null, ?int $offset = 0);
  97. /**
  98. * @param \OCP\IUser|null $user
  99. * @return \OCP\IGroup[]
  100. * @since 8.0.0
  101. */
  102. public function getUserGroups(?IUser $user = null);
  103. /**
  104. * @param \OCP\IUser $user
  105. * @return string[] with group names
  106. * @since 8.0.0
  107. */
  108. public function getUserGroupIds(IUser $user): array;
  109. /**
  110. * get a list of all display names in a group
  111. *
  112. * @param string $gid
  113. * @param string $search
  114. * @param int $limit
  115. * @param int $offset
  116. * @return array an array of display names (value) and user ids (key)
  117. * @since 8.0.0
  118. */
  119. public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0);
  120. /**
  121. * Checks if a userId is in the admin group
  122. * @param string $userId
  123. * @return bool if admin
  124. * @since 8.0.0
  125. */
  126. public function isAdmin($userId);
  127. /**
  128. * Checks if a userId is in a group
  129. * @param string $userId
  130. * @param string $group
  131. * @return bool if in group
  132. * @since 8.0.0
  133. */
  134. public function isInGroup($userId, $group);
  135. /**
  136. * Get the display name of a Nextcloud group
  137. *
  138. * @param string $groupId
  139. * @return ?string display name, if any
  140. *
  141. * @since 26.0.0
  142. */
  143. public function getDisplayName(string $groupId): ?string;
  144. }