Skip to content
Snippets Groups Projects
Commit 6252c248 authored by Vincent Petry's avatar Vincent Petry
Browse files

Merge pull request #7557 from owncloud/issue/7297

Do not allow setting an expiration date in the past
parents 4f95adfb 7ab26320
No related branches found
No related tags found
No related merge requests found
......@@ -80,6 +80,14 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
break;
case 'setExpirationDate':
if (isset($_POST['date'])) {
$l = OC_L10N::get('core');
$date = new \DateTime($_POST['date']);
$today = new \DateTime('now');
if ($date < $today) {
OC_JSON::error(array('data' => array('message' => $l->t('Expiration date is in the past.'))));
return;
}
$return = OCP\Share::setExpirationDate($_POST['itemType'], $_POST['itemSource'], $_POST['date']);
($return) ? OC_JSON::success() : OC_JSON::error();
}
......
......@@ -718,9 +718,21 @@ $(document).ready(function() {
$(document).on('change', '#dropdown #expirationDate', function() {
var itemType = $('#dropdown').data('item-type');
var itemSource = $('#dropdown').data('item-source');
$(this).tipsy('hide');
$(this).removeClass('error');
$.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'setExpirationDate', itemType: itemType, itemSource: itemSource, date: $(this).val() }, function(result) {
if (!result || result.status !== 'success') {
OC.dialogs.alert(t('core', 'Error setting expiration date'), t('core', 'Error'));
var expirationDateField = $('#dropdown #expirationDate');
if (!result.data.message) {
expirationDateField.attr('original-title', t('core', 'Error setting expiration date'));
} else {
expirationDateField.attr('original-title', result.data.message);
}
expirationDateField.tipsy({gravity: 'n', fade: true});
expirationDateField.tipsy('show');
expirationDateField.addClass('error');
}
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment