initCurrentUser(); } else { $federatedUserService->setLocalCurrentUserId($userId); } $circleService = Server::get(CircleService::class); $probe = new CircleProbe(); $probe->includePersonalCircles($personalCircle); $probe->filterHiddenCircles(); return $circleService->getCircles($probe); } /** * @param string $userId * @param bool $forceAll * * @return Circle[] * @throws FederatedUserException * @throws FederatedUserNotFoundException * @throws InitiatorNotFoundException * @throws InvalidIdException * @throws RequestBuilderException * @throws SingleCircleNotFoundException * * @deprecated - used by apps/dav/lib/Connector/Sabre/Principal.php * * Circles::joinedCircles(); * * Return all the circle the current user is a member. */ public static function joinedCircles($userId = '', $forceAll = false) { $federatedUserService = Server::get(FederatedUserService::class); $personalCircle = false; if ($forceAll) { $personalCircle = true; } if ($userId === '') { $federatedUserService->initCurrentUser(); } else { $federatedUserService->setLocalCurrentUserId($userId); } $circleService = Server::get(CircleService::class); $probe = new CircleProbe(); $probe->mustBeMember(); $probe->includePersonalCircles($personalCircle); $probe->filterHiddenCircles(); return $circleService->probeCircles($probe); } /** * @param string $circleUniqueId * @param bool $forceAll * * @return Circle * @throws CircleNotFoundException * @throws FederatedUserException * @throws FederatedUserNotFoundException * @throws InitiatorNotFoundException * @throws InvalidIdException * @throws RequestBuilderException * @throws SingleCircleNotFoundException * * @deprecated - used by apps/dav/lib/Connector/Sabre/Principal.php * - used by apps/files_sharing/lib/Controller/ShareAPIController.php * - used by lib/private/Share20/Manager.php * * Circles::detailsCircle(); * * WARNING - This function is called by the core - WARNING * Do not change it * * Returns details on the circle. If the current user is a member, the members list will be * return as well. * */ public static function detailsCircle(string $circleUniqueId, bool $forceAll = false): Circle { $federatedUserService = Server::get(FederatedUserService::class); if ($forceAll || \OC::$CLI) { $federatedUserService->bypassCurrentUserCondition(true); } else { $federatedUserService->initCurrentUser(); } $circleService = Server::get(CircleService::class); return $circleService->getCircle($circleUniqueId); } /** * @param string $circleUniqueId * @param string $ident * @param int $type * @param bool $forceAll * * @return Membership * * @deprecated - used by apps/files_sharing/lib/Controller/ShareAPIController.php * * Circles::getMember(); * * This function will return information on a member of the circle. Current user need at least * to be Member. * */ public static function getMember($circleUniqueId, $ident, $type, $forceAll = false) { $circlesManager = Server::get(CirclesManager::class); $federatedUser = $circlesManager->getFederatedUser($ident, $type); return $circlesManager->getLink($circleUniqueId, $federatedUser->getSingleId()); } /** * @param array $circleUniqueIds * * @return int[] array of object ids or empty array if none found * * @deprecated - used by apps/dav/lib/Connector/Sabre/FilesReportPlugin.php * * Get a list of objects which are shred with $circleUniqueId. * * @since 0.14.0 * */ public static function getFilesForCircles(array $circleUniqueIds): array { try { $circleService = Server::get(CircleService::class); $federatedUserService = Server::get(FederatedUserService::class); $shareWrapperService = Server::get(ShareWrapperService::class); $federatedUserService->initCurrentUser(); } catch (\Exception $e) { return []; } $result = []; foreach ($circleUniqueIds as $uniqueId) { try { $circleService->getCircle($uniqueId); // checking current user have access to said circle $files = array_map( function (ShareWrapper $wrapper): int { return $wrapper->getFileSource(); }, $shareWrapperService->getSharesToCircle($uniqueId) ); } catch (\Exception $e) { $files = []; } $result = array_merge($files, $result); } return array_values(array_unique($result)); } }