add expiration date if it is already set

This commit is contained in:
Bjoern Schiessle 2013-08-30 17:20:10 +02:00
parent e7959f4fd2
commit 4bbefdf608
3 changed files with 17 additions and 7 deletions

View File

@ -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(

View File

@ -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));
}
}
}

View File

@ -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);
}
/**