diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2015-12-03 10:51:41 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-01-21 15:56:44 +0100 |
commit | 3666c34a197adb75c6b488f877d5b3b2279d0dea (patch) | |
tree | b44409c1e1782167c923d8cf9459beb28752445c /apps | |
parent | e2f231d05156dc382db32397e64f2df790a88a7b (diff) | |
download | nextcloud-server-3666c34a197adb75c6b488f877d5b3b2279d0dea.tar.gz nextcloud-server-3666c34a197adb75c6b488f877d5b3b2279d0dea.zip |
[Sharing 2.0] Start with getShares
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/api/ocssharewrapper.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/api/share20ocs.php | 56 |
2 files changed, 57 insertions, 1 deletions
diff --git a/apps/files_sharing/api/ocssharewrapper.php b/apps/files_sharing/api/ocssharewrapper.php index a186a34cf6a..cc52d478615 100644 --- a/apps/files_sharing/api/ocssharewrapper.php +++ b/apps/files_sharing/api/ocssharewrapper.php @@ -37,7 +37,7 @@ class OCSShareWrapper { } public function getAllShares($params) { - return \OCA\Files_Sharing\API\Local::getAllShares($params); + return $this->getShare20OCS()->getShares(); } public function createShare() { diff --git a/apps/files_sharing/api/share20ocs.php b/apps/files_sharing/api/share20ocs.php index e4cc50d9c1a..56cc50d34fa 100644 --- a/apps/files_sharing/api/share20ocs.php +++ b/apps/files_sharing/api/share20ocs.php @@ -327,6 +327,62 @@ class Share20OCS { return new \OC_OCS_Result($share); } + private function getSharedWithMe() { + $userShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_USER, -1, 0); + $groupShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, -1, 0); + //TODO add federated provider + + $shares = array_merge($userShares, $groupShares); + + $formatted = []; + foreach ($shares as $share) { + $formatted[] = $this->formatShare($share); + } + + return new \OC_OCS_Result($formatted); + } + + public function getShares() { + $sharedWithMe = $this->request->getParam('shared_with_me', null); + $reshares = $this->request->getParam('reshares', null); + $subfiles = $this->request->getParam('subfiles'); + $path = $this->request->getParam('path', null); + + if ($sharedWithMe === 'true') { + return $this->getSharedWithMe(); + } + + if ($path !== null) { + $userFolder = $this->rootFolder->getUserFolder($this->currentUser->getUID()); + try { + $path = $userFolder->get($path); + } catch (\OCP\Files\NotFoundException $e) { + return new \OC_OCS_Result(null, 404, 'wrong path, file/folder doesn\'t exist'); + } + } + + if ($reshares === 'true') { + $reshares = true; + } else { + $reshares = false; + } + + // Get all shares + $userShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $path, $reshares, -1, 0); + $groupShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $path, $reshares, -1, 0); + $linkShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_LINK, $path, $reshares, -1, 0); + //TODO: Add federated shares + + $shares = array_merge($userShares, $groupShares, $linkShares); + + $formatted = []; + foreach ($shares as $share) { + $formatted[] = $this->formatShare($share); + } + + return new \OC_OCS_Result($formatted); + } + /** * @param IShare $share * @return bool |