diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-04-08 14:44:17 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-04-08 14:44:17 +0200 |
commit | 103d451459efe539f13e0bebf968cf94c322ec0e (patch) | |
tree | 5ed22f078da852d709ed65c3bc3304ac8547ca5f /apps | |
parent | d01a2acbcf2aa0dbea56bc1ad7cb855dfabdd746 (diff) | |
parent | 3b1f0e60194aea021433031bd62b3173b912d712 (diff) | |
download | nextcloud-server-103d451459efe539f13e0bebf968cf94c322ec0e.tar.gz nextcloud-server-103d451459efe539f13e0bebf968cf94c322ec0e.zip |
Merge pull request #14987 from rullzer/ocs_password_fix2
OCS Fixes to allow setting of password without removing additional settings
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/api/local.php | 43 |
1 files changed, 9 insertions, 34 deletions
diff --git a/apps/files_sharing/api/local.php b/apps/files_sharing/api/local.php index 571982d153b..1a5edbfd070 100644 --- a/apps/files_sharing/api/local.php +++ b/apps/files_sharing/api/local.php @@ -343,7 +343,7 @@ class Local { if(isset($params['_put']['permissions'])) { return self::updatePermissions($share, $params); } elseif (isset($params['_put']['password'])) { - return self::updatePassword($share, $params); + return self::updatePassword($params['id'], (int)$share['share_type'], $params['_put']['password']); } elseif (isset($params['_put']['publicUpload'])) { return self::updatePublicUpload($share, $params); } elseif (isset($params['_put']['expireDate'])) { @@ -457,47 +457,22 @@ class Local { /** * update password for public link share - * @param array $share information about the share - * @param array $params 'password' + * @param int $shareId + * @param int $shareType + * @param string $password * @return \OC_OCS_Result */ - private static function updatePassword($share, $params) { - - $itemSource = $share['item_source']; - $itemType = $share['item_type']; - - if( (int)$share['share_type'] !== \OCP\Share::SHARE_TYPE_LINK) { + private static function updatePassword($shareId, $shareType, $password) { + if($shareType !== \OCP\Share::SHARE_TYPE_LINK) { return new \OC_OCS_Result(null, 400, "password protection is only supported for public shares"); } - $shareWith = isset($params['_put']['password']) ? $params['_put']['password'] : null; - - if($shareWith === '') { - $shareWith = null; - } - - $items = \OCP\Share::getItemShared($itemType, $itemSource); - - $checkExists = false; - foreach ($items as $item) { - if($item['share_type'] === \OCP\Share::SHARE_TYPE_LINK) { - $checkExists = true; - $permissions = $item['permissions']; - } - } - - if (!$checkExists) { - return new \OC_OCS_Result(null, 404, "share doesn't exists, can't change password"); + if($password === '') { + $password = null; } try { - $result = \OCP\Share::shareItem( - $itemType, - $itemSource, - \OCP\Share::SHARE_TYPE_LINK, - $shareWith, - $permissions - ); + $result = \OCP\Share::setPassword($shareId, $password); } catch (\Exception $e) { return new \OC_OCS_Result(null, 403, $e->getMessage()); } |