[Pkg-owncloud-commits] [owncloud] 10/145: add expire date to link share if possible

David Prévot taffit at moszumanska.debian.org
Wed Feb 26 16:27:38 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit e00f48323818f228e0a680c9327719af0751f971
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date:   Thu Jan 23 11:18:23 2014 +0100

    add expire date to link share if possible
---
 core/ajax/share.php | 21 +++++++++++++++++++--
 core/js/share.js    |  6 +++++-
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/core/ajax/share.php b/core/ajax/share.php
index be02c05..268cd4f 100644
--- a/core/ajax/share.php
+++ b/core/ajax/share.php
@@ -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');
diff --git a/core/js/share.js b/core/js/share.js
index 3637d2e..0939259 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -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);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list