]> source.dussan.org Git - nextcloud-server.git/commitdiff
add expire date to link share if possible
authorBjoern Schiessle <schiessle@owncloud.com>
Thu, 23 Jan 2014 10:18:23 +0000 (11:18 +0100)
committerBjoern Schiessle <schiessle@owncloud.com>
Fri, 24 Jan 2014 09:46:08 +0000 (10:46 +0100)
core/ajax/share.php
core/js/share.js

index be02c056357519a89d52c2fd517b5ea64f78f61d..268cd4f53a7388b475f1d0ef41b69eec38106739 100644 (file)
@@ -119,8 +119,12 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
                                        $subject = (string)$l->t('%s shared »%s« with you', array($ownerDisplayName, $filename));
                                        $expiration = null;
                                        if (isset($items[0]['expiration'])) {
-                                               $date = new DateTime($items[0]['expiration']);
-                                               $expiration = $date->format('Y-m-d');
+                                               try {
+                                                       $date = new DateTime($items[0]['expiration']);
+                                                       $expiration = $date->format('Y-m-d');
+                                               } catch (Exception $e) {
+                                                       \OCP\Util::writeLog('sharing', "Couldn't read date: " . $e->getMessage(), \OCP\Util::ERROR);
+                                               }
                                        }
 
                                        if ($itemType === 'folder') {
@@ -191,6 +195,17 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
                        $file = $_POST['file'];
                        $to_address = $_POST['toaddress'];
 
+                       $expiration = null;
+                       if (isset($_POST['expiration']) && $_POST['expiration'] !== '') {
+                               try {
+                                       $date = new DateTime($_POST['expiration']);
+                                       $expiration = $date->format('Y-m-d');
+                               } catch (Exception $e) {
+                                       \OCP\Util::writeLog('sharing', "Couldn't read date: " . $e->getMessage(), \OCP\Util::ERROR);
+                               }
+
+                       }
+
                        // enable l10n support
                        $l = OC_L10N::get('core');
 
@@ -202,6 +217,7 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
                        $content->assign ('type', $type);
                        $content->assign ('user_displayname', $displayName);
                        $content->assign ('filename', $file);
+                       $content->assign('expiration', $expiration);
                        $text = $content->fetchPage();
 
                        $content = new OC_Template("core", "altmail", "");
@@ -209,6 +225,7 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
                        $content->assign ('type', $type);
                        $content->assign ('user_displayname', $displayName);
                        $content->assign ('filename', $file);
+                       $content->assign('expiration', $expiration);
                        $alttext = $content->fetchPage();
 
                        $default_from = OCP\Util::getDefaultEmailAddress('sharing-noreply');
index 3637d2e7e727c991b455c2a6e0c9d319e5b8ebd2..0939259b7da503b3a0eb499a380c1c5b46d1d1f0 100644 (file)
@@ -733,12 +733,16 @@ $(document).ready(function() {
                var itemSource = $('#dropdown').data('item-source');
                var file = $('tr').filterAttr('data-id', String(itemSource)).data('file');
                var email = $('#email').val();
+               var expirationDate = '';
+               if ( $('#expirationCheckbox').is(':checked') === true ) {
+                       expirationDate = $( "#expirationDate" ).val();
+               }
                if (email != '') {
                        $('#email').prop('disabled', true);
                        $('#email').val(t('core', 'Sending ...'));
                        $('#emailButton').prop('disabled', true);
 
-                       $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'email', toaddress: email, link: link, itemType: itemType, itemSource: itemSource, file: file},
+                       $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'email', toaddress: email, link: link, itemType: itemType, itemSource: itemSource, file: file, expiration: expirationDate},
                                function(result) {
                                        $('#email').prop('disabled', false);
                                        $('#emailButton').prop('disabled', false);