Skip to content

Commit

Permalink
fixup! Fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlSchwan committed May 3, 2022
1 parent 1909145 commit 121e074
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion apps/user_ldap/lib/GroupPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function countUsersInGroup(string $gid, string $search = ''): int {
if ($plugin) {
$count = $plugin->countUsersInGroup($gid,$search);
if ($count === false) {
return -1;
return 0; // no entry found
}
return $count;
}
Expand Down
1 change: 1 addition & 0 deletions apps/user_ldap/lib/Group_LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class Group_LDAP extends ABackend implements GroupInterface, IGroupLDAP,
protected $ldapGroupMemberAssocAttr;

public function __construct(Access $access, GroupPluginManager $groupPluginManager) {
parent::__construct();
$this->access = $access;
$filter = $this->access->connection->ldapGroupFilter;
$gAssoc = $this->access->connection->ldapGroupMemberAssocAttr;
Expand Down
4 changes: 1 addition & 3 deletions apps/user_ldap/lib/Group_Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,7 @@ public function searchInGroup(string $gid, string $search = '', int $limit = -1,

foreach ($this->backends as $backend) {
$backendUsers = $backend->searchInGroup($gid, $search, $limit, $offset);
if (is_array($backendUsers)) {
$users = array_merge($users, $backendUsers);
}
$users = array_merge($users, $backendUsers);
}

return $users;
Expand Down
7 changes: 1 addition & 6 deletions lib/private/Group/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,7 @@ public function searchInGroup(string $gid, string $search = '', int $limit = -1,
$userManager = \OC::$server->get(IUserManager::class);
$displayNameCache = \OC::$server->get(DisplayNameCache::class);
while ($row = $result->fetch()) {
if (isset($row['displayname'])) {
$users[$row['uid']] = new LazyUser($row['uid'], $displayNameCache, $userManager, $row['displayname']);
} else {
// TODO maybe also fetch the displayname directly here
$users[$row['uid']] = new LazyUser($row['uid'], $displayNameCache, $userManager);
}
$users[$row['uid']] = new LazyUser($row['uid'], $displayNameCache, $userManager, $row['displayname'] ?? null);
}
$result->closeCursor();

Expand Down
1 change: 1 addition & 0 deletions lib/private/Group/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ public function removeUser(IUser $user): void {

/**
* Search for users in the group by userid or display name
* @return IUser[]
*/
public function searchUsers(string $search, ?int $limit = null, ?int $offset = null): array {
$users = [];
Expand Down
8 changes: 8 additions & 0 deletions lib/public/Group/Backend/IGroupDetailsBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @copyright Copyright (c) 2018 Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Carl Schwan <carl@carlschwan.eu>
*
* @license GNU AGPL version 3 or any later version
*
Expand All @@ -26,11 +27,18 @@
namespace OCP\Group\Backend;

/**
* @brief Optional interface for group backends
* @since 14.0.0
*/
interface IGroupDetailsBackend {

/**
* @brief Get additional details for a group, for example the display name.
*
* The array returned can be empty when no additional information is available
* for the group.
*
* @return array{displayName?: string}
* @since 14.0.0
*/
public function getGroupDetails(string $gid): array;
Expand Down

0 comments on commit 121e074

Please sign in to comment.