From 4bbefdf608fdf930fa6fd1f783d6f58267752394 Mon Sep 17 00:00:00 2001
From: Bjoern Schiessle <schiessle@owncloud.com>
Date: Fri, 30 Aug 2013 17:20:10 +0200
Subject: [PATCH] add expiration date if it is already set

---
 core/ajax/share.php     |  8 ++++++--
 lib/defaults.php        | 11 ++++++++---
 lib/public/defaults.php |  5 +++--
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/core/ajax/share.php b/core/ajax/share.php
index 0cf4b246f9..8b5191e655 100644
--- a/core/ajax/share.php
+++ b/core/ajax/share.php
@@ -114,7 +114,11 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
 				if ($email !== '') {
 					$displayName = \OCP\User::getDisplayName($recipient);
 					$items = \OCP\Share::getItemSharedWithUser($itemType, $itemSource, $recipient);
-					$filename = $items[0]['file_target'];
+					$filename = trim($items[0]['file_target'], '/');
+					$expiration = null;
+					if (isset($items[0]['expiration'])) {
+						$expiration = $items[0]['expiration'];
+					}
 
 					if ($itemType === 'folder') {
 						$foldername = "/Shared/" . $filename;
@@ -125,7 +129,7 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
 					}
 
 					$url = \OCP\Util::linkToAbsolute('files', 'index.php', array("dir" => $foldername));
-					$text = $defaults->getShareNotificationText(\OCP\User::getDisplayName(), $filename, $itemType, $url);
+					$text = $defaults->getShareNotificationText(\OCP\User::getDisplayName(), $filename, $itemType, $url, $expiration);
 
 					try {
 						OCP\Util::sendMail(
diff --git a/lib/defaults.php b/lib/defaults.php
index 26f417ae2a..0685fbb16c 100644
--- a/lib/defaults.php
+++ b/lib/defaults.php
@@ -65,12 +65,17 @@ class OC_Defaults {
 	 * @param string $itemName name of the file/folder
 	 * @param string $itemType typically "file" or "folder"
 	 * @param string $link link directly to the file/folder in your ownCloud
+	 * @param string $expiration expiration date
 	 */
-	public function getShareNotificationText($sender, $itemName, $itemType, $link) {
+	public function getShareNotificationText($sender, $itemName, $itemType, $link, $expiration=null) {
 		if ($this->themeExist('getShareNotificationText')) {
-			return $this->theme->getShareNotificationText($sender, $itemName, $itemType, $link);
+			return $this->theme->getShareNotificationText($sender, $itemName, $itemType, $link, $expiration);
 		} else {
-			return $this->l->t("%s shared a %s called %s with you. You can find the %s here: %s", array($sender, $itemType, $itemName, $itemType, $link));
+			if ($expiration) {
+				return $this->l->t("%s shared a %s called %s with you. The share will expire at %s. You can find the %s here: %s", array($sender, $itemType, $itemName, $expiration, $itemType, $link));
+			} else {
+				return $this->l->t("%s shared a %s called %s with you. You can find the %s here: %s", array($sender, $itemType, $itemName, $itemType, $link));
+			}
 		}
 	}
 
diff --git a/lib/public/defaults.php b/lib/public/defaults.php
index 9c8c3c0bda..573831e8ea 100644
--- a/lib/public/defaults.php
+++ b/lib/public/defaults.php
@@ -48,9 +48,10 @@ class Defaults {
 	 * @param string $itemName name of the file/folder
 	 * @param string $itemType typically "file" or "folder"
 	 * @param string $link link directly to the file/folder in your ownCloud
+	 * @param string $expiration expiration date
 	 */
-	public function getShareNotificationText($sender, $itemName, $itemType, $link) {
-		return $this->defaults->getShareNotificationText($sender, $itemName, $itemType, $link);
+	public function getShareNotificationText($sender, $itemName, $itemType, $link, $expiration) {
+		return $this->defaults->getShareNotificationText($sender, $itemName, $itemType, $link, $expiration);
 	}
 
 	/**
-- 
GitLab