diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-01-19 14:35:16 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-01-21 15:56:44 +0100 |
commit | 0a9cd91e1d9baa8247fc2bbe1d02ede8340f2906 (patch) | |
tree | cd7ba2b58cea6bf75bfc69d3e13aa1bb0b1855a7 /apps | |
parent | 247b2ee0aa08664885aef2580b21c8b248b4424b (diff) | |
download | nextcloud-server-0a9cd91e1d9baa8247fc2bbe1d02ede8340f2906.tar.gz nextcloud-server-0a9cd91e1d9baa8247fc2bbe1d02ede8340f2906.zip |
[Share 2.0] Add subfiles=x
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/api/share20ocs.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/apps/files_sharing/api/share20ocs.php b/apps/files_sharing/api/share20ocs.php index 56cc50d34fa..2190582f3f4 100644 --- a/apps/files_sharing/api/share20ocs.php +++ b/apps/files_sharing/api/share20ocs.php @@ -342,6 +342,46 @@ class Share20OCS { return new \OC_OCS_Result($formatted); } + /** + * @param \OCP\Files\Folder $folder + * @return \OC_OCS_Result + */ + private function getSharesInDir($folder) { + if (!($folder instanceof \OCP\Files\Folder)) { + return new \OC_OCS_Result(null, 400, "not a directory"); + } + + $nodes = $folder->getDirectoryListing(); + /** @var IShare[] $shares */ + $shares = []; + foreach ($nodes as $node) { + $userShares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $node, false, -1, 0)); + $groupShares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $node, false, -1, 0)); + $linkShares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_LINK, $node, false, -1, 0)); + //TODO: Add federated shares + + $shares = array_merge($shares, $userShares, $groupShares, $linkShares); + } + + $formatted = []; + foreach ($shares as $share) { + $formatted[] = $this->formatShare($share); + } + + return new \OC_OCS_Result($formatted); + } + + /** + * The getShares function. + * + * - Get shares by the current user + * - Get shares by the current user and reshares (?reshares=true) + * - Get shares with the current user (?shared_with_me=true) + * - Get shares for a specific path (?path=...) + * - Get all shares in a folder (?subfiles=true&path=..) + * + * @return \OC_OCS_Result + */ public function getShares() { $sharedWithMe = $this->request->getParam('shared_with_me', null); $reshares = $this->request->getParam('reshares', null); @@ -361,6 +401,10 @@ class Share20OCS { } } + if ($subfiles === 'true') { + return $this->getSharesInDir($path); + } + if ($reshares === 'true') { $reshares = true; } else { |