Skip to content

Fix old subgroups in added groups section #1214

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

Closed
wants to merge 3 commits into from
Closed
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
13 changes: 8 additions & 5 deletions lib/Controller/WorkspaceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function findAll(): JSONResponse {
$this->logger->warning(
"Be careful, the $gid group does not exist in the oc_groups table."
. " But, it's present in the oc_group_folders_groups table."
. " You should recreate it with the occ command."
. ' You should recreate it with the occ command.'
);
continue;
}
Expand All @@ -177,7 +177,10 @@ public function findAll(): JSONResponse {
$gids = array_keys($space['groups'] ?? []);
$groups = [];

$gids = array_filter($gids, fn ($gid) => str_starts_with($gid, 'SPACE-'));
$gids = array_filter($gids, function ($gid) {
$group = $this->groupManager->get($gid);
return str_starts_with($group->getGID(), 'SPACE-') || str_starts_with($group->getDisplayName(), 'G-');
});

$space['users'] = [];
foreach ($gids as $gid) {
Expand Down Expand Up @@ -251,19 +254,19 @@ public function getAdmins(int $spaceId): JSONResponse {
if ($groupfolder === false) {
return new JSONResponse(
[
'message' => 'Failed loading groupfolder '.$space->getGroupfolderId(),
'message' => 'Failed loading groupfolder ' . $space->getGroupfolderId(),
'success' => false
],
Http::STATUS_BAD_REQUEST);
}

$adminUsers = [];
foreach($groupfolder['groups'] as $gid => $groupInfo) {
foreach ($groupfolder['groups'] as $gid => $groupInfo) {
if (str_starts_with($gid, 'SPACE-GE')) {
$group = $this->groupManager->get($gid);
if ($group !== null) {
$users = $group->getUsers();
$adminUsers = $this->userFormatter->formatUsers($users, $groupfolder, (string) $spaceId);
$adminUsers = $this->userFormatter->formatUsers($users, $groupfolder, (string)$spaceId);
}
break;
}
Expand Down
25 changes: 24 additions & 1 deletion lib/Db/GroupFoldersGroupsMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,22 @@ public function findAllAddedGroups() : array {
'gf_groups.folder_id'
)
)
->innerJoin(
'gf_groups',
'groups',
'g',
$qb->expr()->eq(
'gf_groups.group_id',
'g.gid'
)
)
->where('group_id not like :wmGroup') // G and GE
->andWhere('group_id not like :uGroup')
->andWhere('displayname not like :displayname')
->setParameter('wmGroup', 'SPACE-G%')
->setParameter('uGroup', 'SPACE-U%');
->setParameter('uGroup', 'SPACE-U%')
->setParameter('displayname', 'G-%')
;

return $this->findEntities($query);
}
Expand All @@ -110,14 +122,25 @@ public function findAddedGroups($groupfolderId) : array|false {
'gf_groups.folder_id'
)
)
->innerJoin(
'gf_groups',
'groups',
'g',
$qb->expr()->eq(
'gf_groups.group_id',
'g.gid'
)
)
->where('group_id not like :wmGroup')
->andWhere('group_id not like :uGroup')
->andWhere('folder_id = :folderId')
->andWhere('displayname not like :displayname')
->setParameters([
'wmGroup' => 'SPACE-G%',
'uGroup' => 'SPACE-U%',
'folderId' => $groupfolderId
])
->setParameter('displayname', 'G-%')
;

$result = $query->executeQuery()->fetch();
Expand Down
Loading