summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2013-09-19 16:41:29 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2013-09-19 16:41:29 +0200
commitc9f1538c1f5d9f950da77c869d16b3dfec8e46d8 (patch)
tree5b7e92ad0c91e6a54eaad010711b890609da2a4d /apps
parent8cf8c0b16168c2bc13d5593abcf7958ed39d27cb (diff)
downloadnextcloud-server-c9f1538c1f5d9f950da77c869d16b3dfec8e46d8.tar.gz
nextcloud-server-c9f1538c1f5d9f950da77c869d16b3dfec8e46d8.zip
extend API to get the shares from all files in a given folder
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/api.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/api.php b/apps/files_sharing/lib/api.php
index 8ed9b4e2345..06da492ba15 100644
--- a/apps/files_sharing/lib/api.php
+++ b/apps/files_sharing/lib/api.php
@@ -35,6 +35,11 @@ class Api {
// if a file is specified, get the share for this file
if (isset($_GET['file'])) {
$params['itemSource'] = self::getFileId($_GET['file']);
+ $params['path'] = $_GET['file'];
+ if (isset($_GET['subfiles']) && $_GET['subfiles'] === 'yes') {
+ error_log("get shares from folder");
+ return self::getSharesFromFolder($params);
+ }
return self::getShare($params);
}
@@ -89,6 +94,33 @@ class Api {
}
/**
+ * @brief get share from all files in a given folder (non-recursive)
+ * @param array $params contains 'path' to the folder
+ * @return \OC_OCS_Result
+ */
+ private static function getSharesFromFolder($params) {
+ $path = $params['path'];
+ $view = new \OC\Files\View('/'.\OCP\User::getUser().'/files');
+
+ if(!$view->is_dir($path)) {
+ return new \OC_OCS_Result(null, 404, "not a directory");
+ }
+
+ $content = $view->getDirectoryContent($path);
+
+ $result = array();
+ foreach ($content as $file) {
+ $share = \OCP\Share::getItemShared('file', $file['fileid']);
+ if ($share) {
+ $share['filename'] = $file['name'];
+ $result[] = $share;
+ }
+ }
+
+ return new \OC_OCS_Result($result);
+ }
+
+ /**
* @breif create a new share
* @param array $params
* @return \OC_OCS_Result