diff --git a/core/js/shareconfigmodel.js b/core/js/shareconfigmodel.js index 98388cbd50..1ead631db4 100644 --- a/core/js/shareconfigmodel.js +++ b/core/js/shareconfigmodel.js @@ -22,6 +22,7 @@ defaults: { publicUploadEnabled: false, enforcePasswordForPublicLink: oc_appconfig.core.enforcePasswordForPublicLink, + enableLinkPasswordByDefault: oc_appconfig.core.enableLinkPasswordByDefault, isDefaultExpireDateEnforced: oc_appconfig.core.defaultExpireDateEnforced === true, isDefaultExpireDateEnabled: oc_appconfig.core.defaultExpireDateEnabled === true, isRemoteShareAllowed: oc_appconfig.core.remoteShareAllowed, diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js index f1cbea1792..36f15a7269 100644 --- a/core/js/sharedialoglinkshareview.js +++ b/core/js/sharedialoglinkshareview.js @@ -17,6 +17,7 @@ var PASSWORD_PLACEHOLDER = '**********'; var PASSWORD_PLACEHOLDER_MESSAGE = t('core', 'Choose a password for the public link'); + var PASSWORD_PLACEHOLDER_MESSAGE_OPTIONAL = t('core', 'Choose a password for the public link or press enter'); var TEMPLATE = '{{#if shareAllowed}}' + @@ -61,7 +62,11 @@ ' {{/if}}' + '
' + ' ' + + ' {{#if showPasswordCheckBox}}' + ' ' + + ' {{else}}' + + ' ' + + ' {{/if}}' + ' ' + '
' + '{{else}}' + @@ -228,7 +233,7 @@ } if($checkBox.is(':checked')) { - if(this.configModel.get('enforcePasswordForPublicLink') === false) { + if(this.configModel.get('enforcePasswordForPublicLink') === false && this.configModel.get('enableLinkPasswordByDefault') === false) { $loading.removeClass('hidden'); // this will create it this.model.saveLinkShare(); @@ -280,9 +285,19 @@ var $input = this.$el.find('.linkPassText'); $input.removeClass('error'); var password = $input.val(); - // in IE9 the password might be the placeholder due to bugs in the placeholders polyfill - if(password === '' || password === PASSWORD_PLACEHOLDER || password === PASSWORD_PLACEHOLDER_MESSAGE) { - return; + + if (this.$el.find('.linkPassText').attr('placeholder') === PASSWORD_PLACEHOLDER_MESSAGE_OPTIONAL) { + + // in IE9 the password might be the placeholder due to bugs in the placeholders polyfill + if(password === PASSWORD_PLACEHOLDER_MESSAGE_OPTIONAL) { + password = ''; + } + } else { + + // in IE9 the password might be the placeholder due to bugs in the placeholders polyfill + if(password === '' || password === PASSWORD_PLACEHOLDER || password === PASSWORD_PLACEHOLDER_MESSAGE) { + return; + } } $loading @@ -391,6 +406,8 @@ var showPasswordCheckBox = isLinkShare && ( !this.configModel.get('enforcePasswordForPublicLink') || !this.model.get('linkShare').password); + var passwordPlaceholderInitial = this.configModel.get('enforcePasswordForPublicLink') + ? PASSWORD_PLACEHOLDER_MESSAGE : PASSWORD_PLACEHOLDER_MESSAGE_OPTIONAL; var publicEditable = !this.model.isFolder() @@ -428,6 +445,7 @@ enablePasswordLabel: t('core', 'Password protect'), passwordLabel: t('core', 'Password'), passwordPlaceholder: isPasswordSet ? PASSWORD_PLACEHOLDER : PASSWORD_PLACEHOLDER_MESSAGE, + passwordPlaceholderInitial: passwordPlaceholderInitial, isPasswordSet: isPasswordSet, showPasswordCheckBox: showPasswordCheckBox, publicUpload: publicUpload && isLinkShare, diff --git a/lib/private/Settings/Admin/Sharing.php b/lib/private/Settings/Admin/Sharing.php index 9b17efa802..8f57f77b20 100644 --- a/lib/private/Settings/Admin/Sharing.php +++ b/lib/private/Settings/Admin/Sharing.php @@ -64,6 +64,7 @@ class Sharing implements ISettings { 'shareExcludeGroups' => $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false, 'shareExcludedGroupsList' => $excludeGroupsList, 'publicShareDisclaimerText' => $this->config->getAppValue('core', 'shareapi_public_link_disclaimertext', null), + 'enableLinkPasswordByDefault' => $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'), ]; return new TemplateResponse('settings', 'admin/sharing', $parameters, ''); diff --git a/lib/private/Template/JSConfigHelper.php b/lib/private/Template/JSConfigHelper.php index ca45bbee9c..4fc2168021 100644 --- a/lib/private/Template/JSConfigHelper.php +++ b/lib/private/Template/JSConfigHelper.php @@ -112,6 +112,9 @@ class JSConfigHelper { $apps_paths[$app] = \OC_App::getAppWebPath($app); } + + $enableLinkPasswordByDefault = $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'); + $enableLinkPasswordByDefault = ($enableLinkPasswordByDefault === 'yes') ? true : false; $defaultExpireDateEnabled = $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no') === 'yes'; $defaultExpireDate = $enforceDefaultExpireDate = null; if ($defaultExpireDateEnabled) { @@ -217,6 +220,7 @@ class JSConfigHelper { 'defaultExpireDate' => $defaultExpireDate, 'defaultExpireDateEnforced' => $enforceDefaultExpireDate, 'enforcePasswordForPublicLink' => \OCP\Util::isPublicLinkPasswordRequired(), + 'enableLinkPasswordByDefault' => $enableLinkPasswordByDefault, 'sharingDisabledForUser' => \OCP\Util::isSharingDisabledForUser(), 'resharingAllowed' => \OCP\Share::isResharingAllowed(), 'remoteShareAllowed' => $outgoingServer2serverShareEnabled, diff --git a/settings/templates/admin/sharing.php b/settings/templates/admin/sharing.php index db025c8f20..9de71c5899 100644 --- a/settings/templates/admin/sharing.php +++ b/settings/templates/admin/sharing.php @@ -46,7 +46,9 @@ />
- + /> +
/>
diff --git a/tests/lib/Settings/Admin/SharingTest.php b/tests/lib/Settings/Admin/SharingTest.php index 122bf2b6ca..0bf0355968 100644 --- a/tests/lib/Settings/Admin/SharingTest.php +++ b/tests/lib/Settings/Admin/SharingTest.php @@ -104,6 +104,11 @@ class SharingTest extends TestCase { ->method('getAppValue') ->with('core', 'shareapi_public_link_disclaimertext', null) ->willReturn('Lorem ipsum'); + $this->config + ->expects($this->at(12)) + ->method('getAppValue') + ->with('core', 'shareapi_enable_link_password_by_default', 'no') + ->willReturn('yes'); $expected = new TemplateResponse( 'settings', @@ -122,7 +127,8 @@ class SharingTest extends TestCase { 'shareEnforceExpireDate' => 'no', 'shareExcludeGroups' => false, 'shareExcludedGroupsList' => '', - 'publicShareDisclaimerText' => 'Lorem ipsum', + 'publicShareDisclaimerText' => 'Lorem ipsum', + 'enableLinkPasswordByDefault' => 'yes' ], '' ); @@ -191,6 +197,11 @@ class SharingTest extends TestCase { ->method('getAppValue') ->with('core', 'shareapi_public_link_disclaimertext', null) ->willReturn('Lorem ipsum'); + $this->config + ->expects($this->at(12)) + ->method('getAppValue') + ->with('core', 'shareapi_enable_link_password_by_default', 'no') + ->willReturn('yes'); $expected = new TemplateResponse( 'settings', @@ -209,7 +220,8 @@ class SharingTest extends TestCase { 'shareEnforceExpireDate' => 'no', 'shareExcludeGroups' => true, 'shareExcludedGroupsList' => 'NoSharers|OtherNoSharers', - 'publicShareDisclaimerText' => 'Lorem ipsum', + 'publicShareDisclaimerText' => 'Lorem ipsum', + 'enableLinkPasswordByDefault' => 'yes' ], '' );