aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Group/Group.php
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-10-16 19:57:31 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-04-27 12:00:01 +0200
commita4c599c1c91dcd6e041cbf65198e1f1200513be8 (patch)
tree9a2a0f0b0ecb4c6775f7382402a147ae8ca110d2 /lib/private/Group/Group.php
parent35dc2235001bf61f07c78b50e74ca029bb9fc05d (diff)
downloadnextcloud-server-a4c599c1c91dcd6e041cbf65198e1f1200513be8.tar.gz
nextcloud-server-a4c599c1c91dcd6e041cbf65198e1f1200513be8.zip
Split new method in a new group backend interface
Better for backward compatibility, also move new interfaces to nc 26 Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'lib/private/Group/Group.php')
-rw-r--r--lib/private/Group/Group.php25
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/private/Group/Group.php b/lib/private/Group/Group.php
index b2903bcdb26..bfe985b266e 100644
--- a/lib/private/Group/Group.php
+++ b/lib/private/Group/Group.php
@@ -33,14 +33,16 @@
namespace OC\Group;
use OC\Hooks\PublicEmitter;
+use OC\User\LazyUser;
+use OCP\GroupInterface;
use OCP\Group\Backend\ICountDisabledInGroup;
use OCP\Group\Backend\IGetDisplayNameBackend;
use OCP\Group\Backend\IHideFromCollaborationBackend;
use OCP\Group\Backend\INamedBackend;
+use OCP\Group\Backend\ISearchableGroupBackend;
use OCP\Group\Backend\ISetDisplayNameBackend;
use OCP\Group\Events\BeforeGroupChangedEvent;
use OCP\Group\Events\GroupChangedEvent;
-use OCP\GroupInterface;
use OCP\IGroup;
use OCP\IUser;
use OCP\IUserManager;
@@ -248,7 +250,15 @@ class Group implements IGroup {
public function searchUsers(string $search, ?int $limit = null, ?int $offset = null): array {
$users = [];
foreach ($this->backends as $backend) {
- $users = array_merge($users, $backend->searchInGroup($this->gid, $search, $limit ?? -1, $offset ?? 0));
+ if ($backend instanceof ISearchableGroupBackend) {
+ $users = array_merge($users, $backend->searchInGroup($this->gid, $search, $limit ?? -1, $offset ?? 0));
+ } else {
+ $userIds = $backend->usersInGroup($this->gid, $search, $limit ?? -1, $offset ?? 0);
+ $userManager = \OCP\Server::get(IUserManager::class);
+ $users = array_merge($users, array_map(function (string $userId) use ($userManager): IUser {
+ return new LazyUser($userId, $userManager);
+ }, $userIds));
+ }
if (!is_null($limit) and $limit <= 0) {
return $users;
}
@@ -303,18 +313,11 @@ class Group implements IGroup {
* @param string $search
* @param int $limit
* @param int $offset
- * @return \OC\User\User[]
+ * @return IUser[]
* @deprecated 25.0.0 Use searchUsers instead (same implementation)
*/
public function searchDisplayName($search, $limit = null, $offset = null) {
- $users = [];
- foreach ($this->backends as $backend) {
- $users = array_merge($users, $backend->searchInGroup($this->gid, $search, $limit ?? -1, $offset ?? 0));
- if (!is_null($limit) and $limit <= 0) {
- return array_values($users);
- }
- }
- return array_values($users);
+ return $this->searchUsers($search, $limit, $offset);
}
/**