Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport: Hide disabled users when adding a connected group and when displaying the group #1145

Merged
merged 3 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/Group/GroupBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public function getUserGroups($uid) {
$avoid = $this->avoidRecurse_groups;
$this->avoidRecurse_groups = true;
$user = $this->userManager->get($uid);

if (!$user->isEnabled()) {
return [];
}

if ($user) {
$groupIds = $this->groupManager->getUserGroupIds($user);
} else {
Expand Down Expand Up @@ -144,7 +149,9 @@ public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
foreach ($groups as $group) {
if (!is_null($group)) {
foreach ($group->getUsers() as $user) {
$users[] = $user->getUID();
if ($user->isEnabled()) {
$users[] = $user->getUID();
}
};
}
}
Expand Down
5 changes: 4 additions & 1 deletion lib/Service/Group/GroupFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ public static function formatGroups(array $groups): array {
$backendnames
);

$users = $group->getUsers();
$users = array_filter($users, fn ($user) => $user->isEnabled());

$groupsFormat[$group->getGID()] = [
'gid' => $group->getGID(),
'displayName' => $group->getDisplayName(),
'types' => $group->getBackendNames(),
'usersCount' => $group->count(),
'usersCount' => count($users),
'slug' => Slugger::slugger($group->getGID())
];
}
Expand Down
11 changes: 0 additions & 11 deletions tests/Unit/Space/SpaceManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,23 +195,12 @@ public function testArrayAfterCreatedTheEspace01Workspace(): void {
->willReturn('WM-Espace01')
;

$workspaceManagerGroupMock
->expects($this->once())
->method('count')
->willReturn(0)
;

$userGroupMock = $this->createMock(IGroup::class);
$userGroupMock
->expects($this->any())
->method('getGID')
->willReturn('SPACE-U-1')
;
$userGroupMock
->expects($this->once())
->method('count')
->willReturn(0)
;

$userGroupMock
->expects($this->any())
Expand Down
Loading