Merge pull request #4896 from owncloud/sharing_allow_disable_password

sharing, allow user to disable password protection
This commit is contained in:
Björn Schießle 2013-09-23 01:20:09 -07:00
commit 9851f0f4f2
2 changed files with 25 additions and 10 deletions

View File

@ -603,7 +603,18 @@ $(document).ready(function() {
if (!$('#showPassword').is(':checked') ) { if (!$('#showPassword').is(':checked') ) {
var itemType = $('#dropdown').data('item-type'); var itemType = $('#dropdown').data('item-type');
var itemSource = $('#dropdown').data('item-source'); 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 { } else {
$('#linkPassText').focus(); $('#linkPassText').focus();
} }

View File

@ -450,6 +450,7 @@ class Share {
$uidOwner, self::FORMAT_NONE, null, 1)) { $uidOwner, self::FORMAT_NONE, null, 1)) {
// remember old token // remember old token
$oldToken = $checkExists['token']; $oldToken = $checkExists['token'];
$oldPermissions = $checkExists['permissions'];
//delete the old share //delete the old share
self::delete($checkExists['id']); self::delete($checkExists['id']);
} }
@ -460,8 +461,11 @@ class Share {
$hasher = new \PasswordHash(8, $forcePortable); $hasher = new \PasswordHash(8, $forcePortable);
$shareWith = $hasher->HashPassword($shareWith.\OC_Config::getValue('passwordsalt', '')); $shareWith = $hasher->HashPassword($shareWith.\OC_Config::getValue('passwordsalt', ''));
} else { } else {
// reuse the already set password // reuse the already set password, but only if we change permissions
$shareWith = $checkExists['share_with']; // otherwise the user disabled the password protection
if ($checkExists && (int)$permissions !== (int)$oldPermissions) {
$shareWith = $checkExists['share_with'];
}
} }
// Generate token // Generate token