aboutsummaryrefslogtreecommitdiffstats
path: root/core/js/share.js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-07-14 16:05:46 +0200
committerVincent Petry <pvince81@owncloud.com>2014-07-21 15:01:20 +0200
commit4fea52110265617b971f848475ed9e94ffa068d8 (patch)
tree30ab24ece6bfec0bde8d55ca9e59289079e1e12a /core/js/share.js
parent61598e7bb51de58bf48fa4e1b358440ac8cf1774 (diff)
downloadnextcloud-server-4fea52110265617b971f848475ed9e94ffa068d8.tar.gz
nextcloud-server-4fea52110265617b971f848475ed9e94ffa068d8.zip
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);
}
};