diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2015-04-17 09:36:50 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2015-05-18 09:35:47 +0200 |
commit | efd6fec57dcac0b4b9d79a9d98940329b40e6343 (patch) | |
tree | 6bc85ab8684dcb641034546a10dd14bd1c567799 /core/js/share.js | |
parent | 73a3086945b41afa39debd89481c021934dedb67 (diff) | |
download | nextcloud-server-efd6fec57dcac0b4b9d79a9d98940329b40e6343.tar.gz nextcloud-server-efd6fec57dcac0b4b9d79a9d98940329b40e6343.zip |
Fix to make sure expiration date is properly set
This did not happen correctly when the password was enforced since a
different code path was taken.
* moved generation of the default date string to separate function
* added unit test
Diffstat (limited to 'core/js/share.js')
-rw-r--r-- | core/js/share.js | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/core/js/share.js b/core/js/share.js index 6723b829ca5..9f01a5fc6e5 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -839,6 +839,24 @@ OC.Share={ $('#defaultExpireMessage').slideDown(OC.menuSpeed); } $.datepicker.setDefaults(datePickerOptions); + }, + /** + * Get the default Expire date + * + * @return {String} The expire date + */ + getDefaultExpirationDate:function() { + var expireDateString = ''; + if (oc_appconfig.core.defaultExpireDateEnabled) { + var date = new Date().getTime(); + var expireAfterMs = oc_appconfig.core.defaultExpireDate * 24 * 60 * 60 * 1000; + var expireDate = new Date(date + expireAfterMs); + var month = expireDate.getMonth() + 1; + var year = expireDate.getFullYear(); + var day = expireDate.getDate(); + expireDateString = year + "-" + month + '-' + day + ' 00:00:00'; + } + return expireDateString; } }; @@ -987,17 +1005,9 @@ $(document).ready(function() { // Reset link $('#linkText').val(''); var expireDateString = ''; - if (oc_appconfig.core.defaultExpireDateEnabled) { - var date = new Date().getTime(); - var expireAfterMs = oc_appconfig.core.defaultExpireDate * 24 * 60 * 60 * 1000; - var expireDate = new Date(date + expireAfterMs); - var month = expireDate.getMonth() + 1; - var year = expireDate.getFullYear(); - var day = expireDate.getDate(); - expireDateString = year + "-" + month + '-' + day + ' 00:00:00'; - } // Create a link if (oc_appconfig.core.enforcePasswordForPublicLink === false) { + expireDateString = OC.Share.getDefaultExpirationDate(); $loading.removeClass('hidden'); $button.addClass('hidden'); $button.prop('disabled', true); @@ -1135,8 +1145,10 @@ $(document).ready(function() { permissions = OC.PERMISSION_READ; } + var expireDateString = OC.Share.getDefaultExpirationDate(); + $loading.removeClass('hidden'); - OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $('#linkPassText').val(), permissions, itemSourceName, function(data) { + OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $('#linkPassText').val(), permissions, itemSourceName, expireDateString, function(data) { $loading.addClass('hidden'); linkPassText.val(''); linkPassText.attr('placeholder', t('core', 'Password protected')); @@ -1145,8 +1157,12 @@ $(document).ready(function() { OC.Share.showLink(data.token, "password set", itemSource); OC.Share.updateIcon(itemType, itemSource); } + $('#dropdown').trigger(new $.Event('sharesChanged', {shares: OC.Share.currentShares})); }); + if (expireDateString !== '') { + OC.Share.showExpirationDate(expireDateString); + } } }); |