Skip to content

Commit

Permalink
feat(Controller): Ignore the workspace groups
Browse files Browse the repository at this point in the history
Don't take into account the workspace groups when searching.

Signed-off-by: Baptiste Fotia <[email protected]>
  • Loading branch information
zak39 committed Apr 8, 2024
1 parent 689172f commit 803cd80
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions lib/Controller/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,30 @@ public function transferUsersToGroups(string $spaceId,
/**
* @NoAdminRequired
* @NoCSRFRequired
*
* @param string $pattern The pattern to search
* @param bool $ignoreSpaces (not require) Ignore the workspace groups
*/
public function search(string $pattern): JSONResponse {
public function search(string $pattern, ?bool $ignoreSpaces = null): JSONResponse {

$groups = $this->groupManager->search($pattern);

if (!is_null($ignoreSpaces) && (bool)$ignoreSpaces) {
$groups = array_filter($groups, function ($group) {
$gid = $group->getGID();

return !str_starts_with($gid, WorkspaceManagerGroup::getPrefix())
&& !str_starts_with($gid, UserGroup::getPrefix())
&& !str_starts_with($gid, 'SPACE-G')
&& $gid !== ManagersWorkspace::GENERAL_MANAGER
&& $gid !== ManagersWorkspace::WORKSPACES_MANAGERS;
});
}

$groupsFormatted = GroupFormatter::formatGroups($groups);


uksort($groupsFormatted, 'strcasecmp');

return new JSONResponse($groupsFormatted);
}
}

0 comments on commit 803cd80

Please sign in to comment.