aboutsummaryrefslogtreecommitdiffstats
path: root/core/js/share.js
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2014-07-28 17:58:26 +0200
committerBjörn Schießle <schiessle@owncloud.com>2014-07-28 17:58:26 +0200
commit0dc649f3914c4917cbc679827fb4f080e4679b35 (patch)
tree57833e68b2baa456d922d86fd7bb1f4e778094b4 /core/js/share.js
parentc53b56e3139e517af4bca2aca631f625f435f74e (diff)
parent4fea52110265617b971f848475ed9e94ffa068d8 (diff)
downloadnextcloud-server-0dc649f3914c4917cbc679827fb4f080e4679b35.tar.gz
nextcloud-server-0dc649f3914c4917cbc679827fb4f080e4679b35.zip
Merge pull request #9758 from owncloud/share-expdatefix
Fix enforced share expiration date to be based on share time
Diffstat (limited to 'core/js/share.js')
-rw-r--r--core/js/share.js28
1 files changed, 23 insertions, 5 deletions
diff --git a/core/js/share.js b/core/js/share.js
index e8d486055b0..14abdf18ade 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -436,7 +436,7 @@ OC.Share={
}
}
if (share.expiration != null) {
- OC.Share.showExpirationDate(share.expiration);
+ OC.Share.showExpirationDate(share.expiration, share.stime);
}
});
}
@@ -716,7 +716,24 @@ OC.Share={
dirname:function(path) {
return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, '');
},
- showExpirationDate:function(date) {
+ /**
+ * Displays the expiration date field
+ *
+ * @param {Date} date current expiration date
+ * @param {int} [shareTime] share timestamp in seconds, defaults to now
+ */
+ showExpirationDate:function(date, shareTime) {
+ var now = new Date();
+ var datePickerOptions = {
+ minDate: now,
+ maxDate: null
+ };
+ if (_.isNumber(shareTime)) {
+ shareTime = new Date(shareTime * 1000);
+ }
+ if (!shareTime) {
+ shareTime = now;
+ }
$('#expirationCheckbox').attr('checked', true);
$('#expirationDate').val(date);
$('#expirationDate').show('blind');
@@ -726,13 +743,14 @@ OC.Share={
});
if (oc_appconfig.core.defaultExpireDateEnforced) {
$('#expirationCheckbox').attr('disabled', true);
- $.datepicker.setDefaults({
- maxDate : new Date(date.replace(' 00:00:00', ''))
- });
+ shareTime = OC.Util.stripTime(shareTime).getTime();
+ // max date is share date + X days
+ datePickerOptions.maxDate = new Date(shareTime + oc_appconfig.core.defaultExpireDate * 24 * 3600 * 1000);
}
if(oc_appconfig.core.defaultExpireDateEnabled) {
$('#defaultExpireMessage').show('blind');
}
+ $.datepicker.setDefaults(datePickerOptions);
}
};