diff options
author | Björn Schießle <bjoern@schiessle.org> | 2013-09-23 01:20:09 -0700 |
---|---|---|
committer | Björn Schießle <bjoern@schiessle.org> | 2013-09-23 01:20:09 -0700 |
commit | 9851f0f4f2a97dc6ac1382bcd533eb23feffa4e0 (patch) | |
tree | 9c9af0d9320acdaa51cd3fa79ef443f2cec374bb | |
parent | 03eedb58fc3529d27238959415b0f2904a0695e6 (diff) | |
parent | 71e129f295996a65e2e7d73c5e6a964ba9f8bebf (diff) | |
download | nextcloud-server-9851f0f4f2a97dc6ac1382bcd533eb23feffa4e0.tar.gz nextcloud-server-9851f0f4f2a97dc6ac1382bcd533eb23feffa4e0.zip |
Merge pull request #4896 from owncloud/sharing_allow_disable_password
sharing, allow user to disable password protection
-rw-r--r-- | core/js/share.js | 13 | ||||
-rw-r--r-- | lib/public/share.php | 22 |
2 files changed, 25 insertions, 10 deletions
diff --git a/core/js/share.js b/core/js/share.js index 5b93dd30740..f54f13c95e3 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -603,7 +603,18 @@ $(document).ready(function() { if (!$('#showPassword').is(':checked') ) { var itemType = $('#dropdown').data('item-type'); var itemSource = $('#dropdown').data('item-source'); - OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', OC.PERMISSION_READ); + var allowPublicUpload = $('#sharingDialogAllowPublicUpload').is(':checked'); + var permissions = 0; + + // Calculate permissions + if (allowPublicUpload) { + permissions = OC.PERMISSION_UPDATE + OC.PERMISSION_CREATE + OC.PERMISSION_READ; + } else { + permissions = OC.PERMISSION_READ; + } + + + OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', permissions); } else { $('#linkPassText').focus(); } diff --git a/lib/public/share.php b/lib/public/share.php index 9ab956d84b9..91b0ef6dc69 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -106,22 +106,22 @@ class Share { } return false; } - + /** * @brief Prepare a path to be passed to DB as file_target * @return string Prepared path */ public static function prepFileTarget( $path ) { - + // Paths in DB are stored with leading slashes, so add one if necessary if ( substr( $path, 0, 1 ) !== '/' ) { - + $path = '/' . $path; - + } - + return $path; - + } /** @@ -256,7 +256,7 @@ class Share { return self::getItems($itemType, $itemTarget, self::$shareTypeUserAndGroups, \OC_User::getUser(), null, $format, $parameters, 1, $includeCollections); } - + /** * @brief Get the item of item type shared with the current user by source * @param string Item type @@ -450,6 +450,7 @@ class Share { $uidOwner, self::FORMAT_NONE, null, 1)) { // remember old token $oldToken = $checkExists['token']; + $oldPermissions = $checkExists['permissions']; //delete the old share self::delete($checkExists['id']); } @@ -460,8 +461,11 @@ class Share { $hasher = new \PasswordHash(8, $forcePortable); $shareWith = $hasher->HashPassword($shareWith.\OC_Config::getValue('passwordsalt', '')); } else { - // reuse the already set password - $shareWith = $checkExists['share_with']; + // reuse the already set password, but only if we change permissions + // otherwise the user disabled the password protection + if ($checkExists && (int)$permissions !== (int)$oldPermissions) { + $shareWith = $checkExists['share_with']; + } } // Generate token |