summaryrefslogtreecommitdiffstats
path: root/lib/private/Share20/DefaultShareProvider.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Share20/DefaultShareProvider.php')
-rw-r--r--lib/private/Share20/DefaultShareProvider.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php
index 56b9d5b1ee8..bdb6ac466ec 100644
--- a/lib/private/Share20/DefaultShareProvider.php
+++ b/lib/private/Share20/DefaultShareProvider.php
@@ -24,6 +24,7 @@
namespace OC\Share20;
use OCP\Files\File;
+use OCP\Files\Folder;
use OCP\Share\IShareProvider;
use OC\Share20\Exception\InvalidShare;
use OC\Share20\Exception\ProviderException;
@@ -454,6 +455,50 @@ class DefaultShareProvider implements IShareProvider {
return $share;
}
+ public function getSharesInFolder($userId, Folder $node, $reshares) {
+ $qb = $this->dbConn->getQueryBuilder();
+ $qb->select('*')
+ ->from('share', 's')
+ ->andWhere($qb->expr()->orX(
+ $qb->expr()->eq('item_type', $qb->createNamedParameter('file')),
+ $qb->expr()->eq('item_type', $qb->createNamedParameter('folder'))
+ ));
+
+ $qb->andWhere($qb->expr()->orX(
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_USER)),
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP)),
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_LINK))
+ ));
+
+ /**
+ * 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))
+ )
+ );
+ }
+
+ $qb->innerJoin('s', 'filecache' ,'f', 's.file_source = f.fileid');
+ $qb->andWhere($qb->expr()->eq('f.parent', $qb->createNamedParameter($node->getId())));
+
+ $qb->orderBy('id');
+
+ $cursor = $qb->execute();
+ $shares = [];
+ while ($data = $cursor->fetch()) {
+ $shares[$data['fileid']][] = $this->createShare($data);
+ }
+ $cursor->closeCursor();
+
+ return $shares;
+ }
+
/**
* @inheritdoc
*/