diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-10-31 20:26:11 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-10-31 20:26:11 +0100 |
commit | ce7eb02685940c3d8490965cfc150a591fd92762 (patch) | |
tree | 77213870519d398ccd6c284f5be58a9a992bbcca /apps/federatedfilesharing/lib/FederatedShareProvider.php | |
parent | 5a00870a2b4710c37134867d9515985ac1c88611 (diff) | |
download | nextcloud-server-ce7eb02685940c3d8490965cfc150a591fd92762.tar.gz nextcloud-server-ce7eb02685940c3d8490965cfc150a591fd92762.zip |
Add remoteprovider getsharesinfolder function
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/federatedfilesharing/lib/FederatedShareProvider.php')
-rw-r--r-- | apps/federatedfilesharing/lib/FederatedShareProvider.php | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index 86204782d19..be155ac2daf 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -27,6 +27,7 @@ namespace OCA\FederatedFileSharing; use OC\Share20\Share; +use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\IConfig; use OCP\IL10N; @@ -564,8 +565,45 @@ class FederatedShareProvider implements IShareProvider { } - public function getSharesInFolder($userId, $node, $reshares) { - return [];//TODO + 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('shareType', $qb->createNamedParameter(\OCP\Share::SHARE_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)) + ) + ); + } + + $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; } /** |