summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2019-10-31 19:28:29 +0100
committerGitHub <noreply@github.com>2019-10-31 19:28:29 +0100
commitfd475d421232e3d83103304002bce23a0b267a60 (patch)
treef7ccb86835b1bf8b6767368be9e0d62135c1a062 /apps
parentef6806a23579c50ff9740662aec17ae2551a2f86 (diff)
parent2f49806c201c0aaaf400e84a7580d0789c90dc57 (diff)
downloadnextcloud-server-fd475d421232e3d83103304002bce23a0b267a60.tar.gz
nextcloud-server-fd475d421232e3d83103304002bce23a0b267a60.zip
Merge pull request #17739 from nextcloud/enh/share/filter
Get all shares iterable
Diffstat (limited to 'apps')
-rw-r--r--apps/federatedfilesharing/lib/FederatedShareProvider.php27
-rw-r--r--apps/sharebymail/lib/ShareByMailProvider.php25
2 files changed, 52 insertions, 0 deletions
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php
index 67089cba9d3..4d93dec18f7 100644
--- a/apps/federatedfilesharing/lib/FederatedShareProvider.php
+++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php
@@ -1100,4 +1100,31 @@ class FederatedShareProvider implements IShareProvider {
return ['remote' => $remote];
}
+
+ public function getAllShares(): iterable {
+ $qb = $this->dbConnection->getQueryBuilder();
+
+ $qb->select('*')
+ ->from('share')
+ ->where(
+ $qb->expr()->orX(
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share\IShare::TYPE_REMOTE)),
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share\IShare::TYPE_REMOTE_GROUP))
+ )
+ );
+
+ $cursor = $qb->execute();
+ while($data = $cursor->fetch()) {
+ try {
+ $share = $this->createShareObject($data);
+ } catch (InvalidShare $e) {
+ continue;
+ } catch (ShareNotFound $e) {
+ continue;
+ }
+
+ yield $share;
+ }
+ $cursor->closeCursor();
+ }
}
diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php
index 9bfe5e733f4..903df175e9c 100644
--- a/apps/sharebymail/lib/ShareByMailProvider.php
+++ b/apps/sharebymail/lib/ShareByMailProvider.php
@@ -1166,4 +1166,29 @@ class ShareByMailProvider implements IShareProvider {
return ['public' => $mail];
}
+ public function getAllShares(): iterable {
+ $qb = $this->dbConnection->getQueryBuilder();
+
+ $qb->select('*')
+ ->from('share')
+ ->where(
+ $qb->expr()->orX(
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share\IShare::TYPE_EMAIL))
+ )
+ );
+
+ $cursor = $qb->execute();
+ while($data = $cursor->fetch()) {
+ try {
+ $share = $this->createShareObject($data);
+ } catch (InvalidShare $e) {
+ continue;
+ } catch (ShareNotFound $e) {
+ continue;
+ }
+
+ yield $share;
+ }
+ $cursor->closeCursor();
+ }
}