diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-08-16 22:45:49 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-08-17 20:45:27 +0200 |
commit | 22e23f304570e3eef1e56f73b7c15ba29025bcdd (patch) | |
tree | 5169b0836e6217e956817044825ebf89997cd167 /apps/files_sharing/lib/API | |
parent | c40fa479447ac602887f25715bdb103ab8bab0ce (diff) | |
download | nextcloud-server-22e23f304570e3eef1e56f73b7c15ba29025bcdd.tar.gz nextcloud-server-22e23f304570e3eef1e56f73b7c15ba29025bcdd.zip |
Use parameters in createShare
* Fix tests
Diffstat (limited to 'apps/files_sharing/lib/API')
-rw-r--r-- | apps/files_sharing/lib/API/Share20OCS.php | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/apps/files_sharing/lib/API/Share20OCS.php b/apps/files_sharing/lib/API/Share20OCS.php index 2c0ed03f880..b8b259ee430 100644 --- a/apps/files_sharing/lib/API/Share20OCS.php +++ b/apps/files_sharing/lib/API/Share20OCS.php @@ -246,17 +246,32 @@ class Share20OCS extends OCSController { /** * @NoAdminRequired * + * @param string $path + * @param int $permissions + * @param int $shareType + * @param string $shareWith + * @param string $publicUpload + * @param string $password + * @param string $expireDate + * * @return DataResponse * @throws OCSNotFoundException * @throws OCSForbiddenException * @throws OCSBadRequestException * @throws OCSException */ - public function createShare() { + public function createShare( + $path = null, + $permissions = \OCP\Constants::PERMISSION_ALL, + $shareType = -1, + $shareWith = null, + $publicUpload = 'false', + $password = '', + $expireDate = '' + ) { $share = $this->shareManager->newShare(); // Verify path - $path = $this->request->getParam('path', null); if ($path === null) { throw new OCSNotFoundException($this->l->t('Please specify a file or folder path')); } @@ -276,14 +291,6 @@ class Share20OCS extends OCSController { throw new OCSNotFoundException($this->l->t('Could not create share')); } - // Parse permissions (if available) - $permissions = $this->request->getParam('permissions', null); - if ($permissions === null) { - $permissions = \OCP\Constants::PERMISSION_ALL; - } else { - $permissions = (int)$permissions; - } - if ($permissions < 0 || $permissions > \OCP\Constants::PERMISSION_ALL) { throw new OCSNotFoundException($this->l->t('invalid permissions')); } @@ -306,9 +313,6 @@ class Share20OCS extends OCSController { $permissions &= ~($permissions & ~$path->getPermissions()); } - $shareWith = $this->request->getParam('shareWith', null); - $shareType = (int)$this->request->getParam('shareType', '-1'); - if ($shareType === \OCP\Share::SHARE_TYPE_USER) { // Valid user is required to share if ($shareWith === null || !$this->userManager->userExists($shareWith)) { @@ -342,7 +346,6 @@ class Share20OCS extends OCSController { return new DataResponse($this->formatShare($existingShares[0])); } - $publicUpload = $this->request->getParam('publicUpload', null); if ($publicUpload === 'true') { // Check if public upload is allowed if (!$this->shareManager->shareApiLinkAllowPublicUpload()) { @@ -365,15 +368,11 @@ class Share20OCS extends OCSController { } // Set password - $password = $this->request->getParam('password', ''); - if ($password !== '') { $share->setPassword($password); } //Expire date - $expireDate = $this->request->getParam('expireDate', ''); - if ($expireDate !== '') { try { $expireDate = $this->parseDate($expireDate); |