diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2016-11-01 20:05:09 +0100 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2016-11-01 20:05:09 +0100 |
commit | 32dbf32bc57af8bbd568aded4c88aeb7da2753b9 (patch) | |
tree | b7254d0ee7c315de50f74284fc5064726e111d44 /apps/sharebymail/lib | |
parent | 16ec0f2177edf2d9dcda43e51d604a0155767f47 (diff) | |
download | nextcloud-server-32dbf32bc57af8bbd568aded4c88aeb7da2753b9.tar.gz nextcloud-server-32dbf32bc57af8bbd568aded4c88aeb7da2753b9.zip |
add new method getSharesInFolder(), see #339
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/sharebymail/lib')
-rw-r--r-- | apps/sharebymail/lib/ShareByMailProvider.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index 6be46f747e6..46e381d3319 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -22,6 +22,7 @@ namespace OCA\ShareByMail; use OC\HintException; +use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\Node; use OCP\IDBConnection; @@ -663,4 +664,45 @@ class ShareByMailProvider implements IShareProvider { return $data; } + public function getSharesInFolder($userId, Folder $node, $reshares) { + $qb = $this->dbConnection->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')) + )) + ->andWhere( + $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)) + ); + + /** + * 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->createShareObject($data); + } + $cursor->closeCursor(); + + return $shares; + } + } |