diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-09-26 00:09:35 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-09-26 00:09:35 -0400 |
commit | b4e40b1c21fc3cd465a467278b4960565e07ca0d (patch) | |
tree | 35572553babd438bd38ee63b3fb741ccfc1fe6da | |
parent | 00103d730fe2ce57ee389fd7d219847d8cb015a3 (diff) | |
download | nextcloud-server-b4e40b1c21fc3cd465a467278b4960565e07ca0d.tar.gz nextcloud-server-b4e40b1c21fc3cd465a467278b4960565e07ca0d.zip |
Fix unsetting share expiration date
-rw-r--r-- | core/js/share.js | 9 | ||||
-rw-r--r-- | lib/public/share.php | 8 |
2 files changed, 14 insertions, 3 deletions
diff --git a/core/js/share.js b/core/js/share.js index e45dc7dd424..36ee39d8eab 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -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(); + }); } }); diff --git a/lib/public/share.php b/lib/public/share.php index 6ef984732b9..1039d6f0dbf 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -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'])); |