summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/files_external/3rdparty/Dropbox/OAuth/Curl.php12
-rw-r--r--apps/files_sharing/api/local.php43
2 files changed, 16 insertions, 39 deletions
diff --git a/apps/files_external/3rdparty/Dropbox/OAuth/Curl.php b/apps/files_external/3rdparty/Dropbox/OAuth/Curl.php
index cfa33ed0e1a..2f7da1ad253 100644
--- a/apps/files_external/3rdparty/Dropbox/OAuth/Curl.php
+++ b/apps/files_external/3rdparty/Dropbox/OAuth/Curl.php
@@ -75,11 +75,13 @@ class Dropbox_OAuth_Curl extends Dropbox_OAuth {
//if (is_array($arguments))
// $arguments=http_build_query($arguments);
- foreach ($arguments as $key => $value) {
- if($value[0] === '@') {
- exit();
- }
- }
+ if(is_array($arguments)) {
+ foreach ($arguments as $key => $value) {
+ if ($value[0] === '@') {
+ exit();
+ }
+ }
+ }
curl_setopt($ch, CURLOPT_POSTFIELDS, $arguments);
// $httpHeaders['Content-Length']=strlen($arguments);
} else {
diff --git a/apps/files_sharing/api/local.php b/apps/files_sharing/api/local.php
index d9291c29f61..33b1cd0ed67 100644
--- a/apps/files_sharing/api/local.php
+++ b/apps/files_sharing/api/local.php
@@ -335,7 +335,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'])) {
@@ -446,47 +446,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());
}