IGroupManager.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCP;
  8. /**
  9. * Class Manager
  10. *
  11. * Hooks available in scope \OC\Group:
  12. * - preAddUser(\OC\Group\Group $group, \OC\User\User $user)
  13. * - postAddUser(\OC\Group\Group $group, \OC\User\User $user)
  14. * - preRemoveUser(\OC\Group\Group $group, \OC\User\User $user)
  15. * - postRemoveUser(\OC\Group\Group $group, \OC\User\User $user)
  16. * - preDelete(\OC\Group\Group $group)
  17. * - postDelete(\OC\Group\Group $group)
  18. * - preCreate(string $groupId)
  19. * - postCreate(\OC\Group\Group $group)
  20. *
  21. * @since 8.0.0
  22. */
  23. interface IGroupManager {
  24. /**
  25. * Checks whether a given backend is used
  26. *
  27. * @param string $backendClass Full classname including complete namespace
  28. * @return bool
  29. * @since 8.1.0
  30. */
  31. public function isBackendUsed($backendClass);
  32. /**
  33. * @param \OCP\GroupInterface $backend
  34. * @since 8.0.0
  35. */
  36. public function addBackend($backend);
  37. /**
  38. * @since 8.0.0
  39. */
  40. public function clearBackends();
  41. /**
  42. * Get the active backends
  43. * @return \OCP\GroupInterface[]
  44. * @since 13.0.0
  45. */
  46. public function getBackends();
  47. /**
  48. * @param string $gid
  49. * @return \OCP\IGroup|null
  50. * @since 8.0.0
  51. */
  52. public function get($gid);
  53. /**
  54. * @param string $gid
  55. * @return bool
  56. * @since 8.0.0
  57. */
  58. public function groupExists($gid);
  59. /**
  60. * @param string $gid
  61. * @return \OCP\IGroup|null
  62. * @since 8.0.0
  63. */
  64. public function createGroup($gid);
  65. /**
  66. * @param string $search
  67. * @param ?int $limit
  68. * @param ?int $offset
  69. * @return \OCP\IGroup[]
  70. * @since 8.0.0
  71. */
  72. public function search(string $search, ?int $limit = null, ?int $offset = 0);
  73. /**
  74. * @param \OCP\IUser|null $user
  75. * @return \OCP\IGroup[]
  76. * @since 8.0.0
  77. */
  78. public function getUserGroups(?IUser $user = null);
  79. /**
  80. * @param \OCP\IUser $user
  81. * @return string[] with group names
  82. * @since 8.0.0
  83. */
  84. public function getUserGroupIds(IUser $user): array;
  85. /**
  86. * get a list of all display names in a group
  87. *
  88. * @param string $gid
  89. * @param string $search
  90. * @param int $limit
  91. * @param int $offset
  92. * @return array an array of display names (value) and user ids (key)
  93. * @since 8.0.0
  94. */
  95. public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0);
  96. /**
  97. * Checks if a userId is in the admin group
  98. * @param string $userId
  99. * @return bool if admin
  100. * @since 8.0.0
  101. */
  102. public function isAdmin($userId);
  103. /**
  104. * Checks if a userId is eligible to users administration delegation
  105. * @param string $userId
  106. * @return bool if delegated admin
  107. * @since 30.0.0
  108. */
  109. public function isDelegatedAdmin(string $userId): bool;
  110. /**
  111. * Checks if a userId is in a group
  112. * @param string $userId
  113. * @param string $group
  114. * @return bool if in group
  115. * @since 8.0.0
  116. */
  117. public function isInGroup($userId, $group);
  118. /**
  119. * Get the display name of a Nextcloud group
  120. *
  121. * @param string $groupId
  122. * @return ?string display name, if any
  123. *
  124. * @since 26.0.0
  125. */
  126. public function getDisplayName(string $groupId): ?string;
  127. }