Fix unsetting share expiration date

remotes/origin/stable45
Michael Gapczynski 12 years ago
parent 00103d730f
commit b4e40b1c21
  1. 9
      core/js/share.js
  2. 8
      lib/public/share.php

@ -482,7 +482,14 @@ $(document).ready(function() {
if (this.checked) {
OC.Share.showExpirationDate('');
} else {
$('#expirationDate').hide();
var itemType = $('#dropdown').data('item-type');
var itemSource = $('#dropdown').data('item-source');
$.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'setExpirationDate', itemType: itemType, itemSource: itemSource, date: '' }, function(result) {
if (!result || result.status !== 'success') {
OC.dialogs.alert(t('core', 'Error'), t('core', 'Error unsetting expiration date'));
}
$('#expirationDate').hide();
});
}
});

@ -420,8 +420,12 @@ class Share {
public static function setExpirationDate($itemType, $itemSource, $date) {
if ($items = self::getItems($itemType, $itemSource, null, null, \OC_User::getUser(), self::FORMAT_NONE, null, -1, false)) {
if (!empty($items)) {
$date = new \DateTime($date);
$date = date('Y-m-d H:i', $date->format('U') - $date->getOffset());
if ($date == '') {
$date = null;
} else {
$date = new \DateTime($date);
$date = date('Y-m-d H:i', $date->format('U') - $date->getOffset());
}
$query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `expiration` = ? WHERE `id` = ?');
foreach ($items as $item) {
$query->execute(array($date, $item['id']));

Loading…
Cancel
Save