summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-01-27 09:36:41 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-01-27 09:36:41 +0100
commit5b7a1b13f3514f60650e1da41d8dc046ee0252c5 (patch)
treedb4df1735f235f153e209792be0e5bbac2693866 /apps
parentc274f03e1287b735d732396fb7d668e6b4099429 (diff)
parentd11682dcb4123c3086787e9002614de8fd3b6b08 (diff)
downloadnextcloud-server-5b7a1b13f3514f60650e1da41d8dc046ee0252c5.tar.gz
nextcloud-server-5b7a1b13f3514f60650e1da41d8dc046ee0252c5.zip
Merge pull request #21887 from owncloud/share2_updateShare
[Sharing 2.0] update share
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/api/ocssharewrapper.php3
-rw-r--r--apps/files_sharing/api/share20ocs.php66
2 files changed, 68 insertions, 1 deletions
diff --git a/apps/files_sharing/api/ocssharewrapper.php b/apps/files_sharing/api/ocssharewrapper.php
index cc52d478615..9f63e864cec 100644
--- a/apps/files_sharing/api/ocssharewrapper.php
+++ b/apps/files_sharing/api/ocssharewrapper.php
@@ -50,7 +50,8 @@ class OCSShareWrapper {
}
public function updateShare($params) {
- return \OCA\Files_Sharing\API\Local::updateShare($params);
+ $id = $params['id'];
+ return $this->getShare20OCS()->updateShare($id);
}
public function deleteShare($params) {
diff --git a/apps/files_sharing/api/share20ocs.php b/apps/files_sharing/api/share20ocs.php
index c2ff94db790..c5e7dcff824 100644
--- a/apps/files_sharing/api/share20ocs.php
+++ b/apps/files_sharing/api/share20ocs.php
@@ -426,6 +426,72 @@ class Share20OCS {
}
/**
+ * @param int $id
+ * @return \OC_OCS_Result
+ */
+ public function updateShare($id) {
+ // Try both our default and our federated provider
+ $share = null;
+
+ try {
+ $share = $this->shareManager->getShareById('ocinternal:' . $id);
+ } catch (\OC\Share20\Exception\ShareNotFound $e) {
+ //Ignore for now
+ //return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.');
+ }
+
+ // Could not find the share as internal share... maybe it is a federated share
+ if ($share === null) {
+ return \OCA\Files_Sharing\API\Local::updateShare(['id' => $id]);
+ }
+
+ if (!$this->canAccessShare($share)) {
+ return new \OC_OCS_Result(null, 404, "wrong share Id, share doesn't exist.");
+ }
+
+ $permissions = $this->request->getParam('permissions', null);
+ $password = $this->request->getParam('password', null);
+ $publicUpload = $this->request->getParam('publicUpload', null);
+ $expireDate = $this->request->getParam('expireDate', null);
+
+ if ($permissions === null && $password === null && $publicUpload === null && $expireDate === null) {
+ return new \OC_OCS_Result(null, 400, 'Wrong or no update parameter given');
+ }
+
+ if ($expireDate !== null) {
+ try {
+ $expireDate = $this->parseDate($expireDate);
+ } catch (\Exception $e) {
+ return new \OC_OCS_Result(null, 400, $e->getMessage());
+ }
+ $share->setExpirationDate($expireDate);
+ }
+
+ if ($permissions !== null) {
+ $permissions = (int)$permissions;
+ $share->setPermissions($permissions);
+ }
+
+ if ($password !== null) {
+ $share->setPassword($password);
+ }
+
+ if ($publicUpload === 'true') {
+ $share->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE);
+ } else if ($publicUpload === 'false') {
+ $share->setPermissions(\OCP\Constants::PERMISSION_READ);
+ }
+
+ try {
+ $share = $this->shareManager->updateShare($share);
+ } catch (\Exception $e) {
+ return new \OC_OCS_Result(null, 400, $e->getMessage());
+ }
+
+ return new \OC_OCS_Result($this->formatShare($share));
+ }
+
+ /**
* @param IShare $share
* @return bool
*/