summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files_sharing/api/share20ocs.php44
-rw-r--r--lib/private/share20/defaultshareprovider.php2
-rw-r--r--lib/private/share20/manager.php12
3 files changed, 45 insertions, 13 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 {
diff --git a/lib/private/share20/defaultshareprovider.php b/lib/private/share20/defaultshareprovider.php
index 4d1a72f6a13..e3e5909e901 100644
--- a/lib/private/share20/defaultshareprovider.php
+++ b/lib/private/share20/defaultshareprovider.php
@@ -279,9 +279,9 @@ class DefaultShareProvider implements IShareProvider {
if ($limit !== -1) {
$qb->setMaxResults($limit);
- $qb->setFirstResult($offset);
}
+ $qb->setFirstResult($offset);
$qb->orderBy('id');
$cursor = $qb->execute();
diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php
index 7d454b26f00..3935307b977 100644
--- a/lib/private/share20/manager.php
+++ b/lib/private/share20/manager.php
@@ -679,18 +679,6 @@ class Manager {
}
/**
- * Get all shares that are shared with the current user
- *
- * @param int $shareType
- * @param int $page
- * @param int $perPage
- *
- * @return Share[]
- */
- public function getSharedWithMe($shareType = null, $page=0, $perPage=50) {
- }
-
- /**
* Get the share by token possible with password
*
* @param string $token