aboutsummaryrefslogtreecommitdiffstats
path: root/apps/federatedfilesharing/lib/FederatedShareProvider.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/federatedfilesharing/lib/FederatedShareProvider.php')
-rw-r--r--apps/federatedfilesharing/lib/FederatedShareProvider.php51
1 files changed, 29 insertions, 22 deletions
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php
index d993b35845c..8a2c12e0ac8 100644
--- a/apps/federatedfilesharing/lib/FederatedShareProvider.php
+++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php
@@ -26,6 +26,7 @@ use OCP\Share\Exceptions\GenericShareException;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IShare;
use OCP\Share\IShareProvider;
+use OCP\Share\IShareProviderSupportsAllSharesInFolder;
use Psr\Log\LoggerInterface;
/**
@@ -33,7 +34,7 @@ use Psr\Log\LoggerInterface;
*
* @package OCA\FederatedFileSharing
*/
-class FederatedShareProvider implements IShareProvider {
+class FederatedShareProvider implements IShareProvider, IShareProviderSupportsAllSharesInFolder {
public const SHARE_TYPE_REMOTE = 6;
/** @var string */
@@ -87,8 +88,8 @@ class FederatedShareProvider implements IShareProvider {
$shareType = $share->getShareType();
$expirationDate = $share->getExpirationDate();
- if ($shareType === IShare::TYPE_REMOTE_GROUP &&
- !$this->isOutgoingServer2serverGroupShareEnabled()
+ if ($shareType === IShare::TYPE_REMOTE_GROUP
+ && !$this->isOutgoingServer2serverGroupShareEnabled()
) {
$message = 'It is not allowed to send federated group shares from this server.';
$message_t = $this->l->t('It is not allowed to send federated group shares from this server.');
@@ -430,13 +431,7 @@ class FederatedShareProvider implements IShareProvider {
return $share;
}
- /**
- * Get all children of this share
- *
- * @param IShare $parent
- * @return IShare[]
- */
- public function getChildren(IShare $parent) {
+ public function getChildren(IShare $parent): array {
$children = [];
$qb = $this->dbConnection->getQueryBuilder();
@@ -553,7 +548,17 @@ class FederatedShareProvider implements IShareProvider {
if (!$shallow) {
throw new \Exception('non-shallow getSharesInFolder is no longer supported');
}
+ return $this->getSharesInFolderInternal($userId, $node, $reshares);
+ }
+ public function getAllSharesInFolder(Folder $node): array {
+ return $this->getSharesInFolderInternal(null, $node, null);
+ }
+
+ /**
+ * @return array<int, list<IShare>>
+ */
+ private function getSharesInFolderInternal(?string $userId, Folder $node, ?bool $reshares): array {
$qb = $this->dbConnection->getQueryBuilder();
$qb->select('*')
->from('share', 's')
@@ -562,18 +567,20 @@ class FederatedShareProvider implements IShareProvider {
$qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_REMOTE))
);
- /**
- * Reshares for this user are shares where they are the owner.
- */
- if ($reshares === false) {
- $qb->andWhere($qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)));
- } else {
- $qb->andWhere(
- $qb->expr()->orX(
- $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)),
- $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId))
- )
- );
+ if ($userId !== null) {
+ /**
+ * Reshares for this user are shares where they are the owner.
+ */
+ if ($reshares !== true) {
+ $qb->andWhere($qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)));
+ } else {
+ $qb->andWhere(
+ $qb->expr()->orX(
+ $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)),
+ $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId))
+ )
+ );
+ }
}
$qb->innerJoin('s', 'filecache', 'f', $qb->expr()->eq('s.file_source', 'f.fileid'));