, array{}> * * 200: All groups returned */ #[RequireGroupFolderAdmin] #[NoAdminRequired] #[FrontpageRoute(verb: 'GET', url: '/delegation/groups')] public function getAllGroups(): DataResponse { // Get all groups $groups = $this->groupManager->search(''); // transform in a format suitable for the app $data = []; foreach ($groups as $group) { $data[] = [ 'gid' => $group->getGID(), 'displayName' => $group->getDisplayName(), ]; } return new DataResponse($data); } /** * Returns the list of all visible circles * * @return DataResponse, array{}> * * 200: All circles returned */ #[RequireGroupFolderAdmin] #[NoAdminRequired] #[FrontpageRoute(verb: 'GET', url: '/delegation/circles')] public function getAllCircles(): DataResponse { $circlesEnabled = $this->appManager->isEnabledForUser('circles'); if (!$circlesEnabled) { return new DataResponse([]); } try { $circlesManager = Server::get(CirclesManager::class); } catch (ContainerExceptionInterface) { return new DataResponse([]); } // As admin, get all circles, // As non-admin, only returns circles current user is members of. /** @psalm-suppress PossiblyNullReference current user cannot be null */ if ($this->groupManager->isAdmin($this->userSession->getUser()->getUID())) { $circlesManager->startSuperSession(); } else { $circlesManager->startSession(); } $circles = $circlesManager->probeCircles(); // transform in a format suitable for the app $data = []; foreach ($circles as $circle) { $data[] = [ 'singleId' => $circle->getSingleId(), 'displayName' => $circle->getDisplayName(), ]; } return new DataResponse($data); } /** * Get the list Groups related to classname. * @param string $classname If the classname is * - OCA\GroupFolders\Settings\Admin : It's reference to fields in Admin Privileges. * - OCA\GroupFolders\Controller\DelegationController : It's just to specific the subadmins. * They can only manage groupfolders in which they are added in the Advanced Permissions (groups only) * * @return DataResponse, array{}> * * 200: Authorized groups returned */ #[RequireGroupFolderAdmin] #[NoAdminRequired] #[FrontpageRoute(verb: 'GET', url: '/delegation/authorized-groups')] public function getAuthorizedGroups(string $classname = ''): DataResponse { $data = []; $authorizedGroups = $this->authorizedGroupService->findExistingGroupsForClass($classname); foreach ($authorizedGroups as $authorizedGroup) { $group = $this->groupManager->get($authorizedGroup->getGroupId()); if ($group !== null) { $data[] = [ 'gid' => $group->getGID(), 'displayName' => $group->getDisplayName(), ]; } } return new DataResponse($data); } }