l10n->t('Files'); } public function getIconSvg(): string { return ''; } public function getSharedWith(string $teamId): array { if (!$this->circlesManager) { return []; } $shares = $this->shareByCircleProvider->getSharesToCircle($teamId); return $this->convertWrappedShareToResource($shares); } /** * @return array */ public function getSharedWithList(array $teams): array { $data = $shares = []; foreach ($this->shareByCircleProvider->getSharesToCircles($teams) as $share) { if (!array_key_exists($share->getId(), $shares)) { $shares[$share->getSharedWith()] = []; } $shares[$share->getSharedWith()][] = $share; } foreach ($teams as $teamId) { $data[$teamId] = $this->convertWrappedShareToResource($shares[$teamId]); } return $data; } /** * convert list of ShareWrapper to TeamResource * * @param ShareWrapper[] $shares * @return TeamResource[] */ private function convertWrappedShareToResource(array $shares): array { usort($shares, function ($a, $b) { return (int)($b->getItemType() === 'folder') - (int)($a->getItemType() === 'folder'); }); return array_map(function (ShareWrapper $shareWrapper) { $isFolder = $shareWrapper->getItemType() === 'folder'; return new TeamResource( $this, (string)$shareWrapper->getFileSource(), basename($shareWrapper->getFileTarget()), $this->urlGenerator->getAbsoluteURL('/index.php/f/' . $shareWrapper->getFileSource()), iconSvg: $isFolder ? '' : null, iconURL: !$isFolder ? $this->urlGenerator->linkToRouteAbsolute('core.preview.getPreviewByFileId', ['fileId' => $shareWrapper->getFileSource(), 'mimeFallback' => true, ]) : null, ); }, $shares); } public function isSharedWithTeam(string $teamId, string $resourceId): bool { if (!$this->circlesManager) { return false; } return count(array_filter($this->getSharedWith($teamId), function (TeamResource $resource) use ($resourceId) { return $resource->getId() === $resourceId; })) !== 0; } public function getTeamsForResource(string $resourceId): array { if (!$this->circlesManager) { return []; } $shares = $this->shareByCircleProvider->getSharesByFileId((int)$resourceId); return array_map(function ($share) { return $share->getSharedWith(); }, $shares); } }