summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2013-09-25 11:51:28 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2013-09-25 11:51:28 +0200
commit883d1c0df32a942d3bb07f242e8ffcd871418f60 (patch)
tree9ddfaec99ea2886d997bdcb90842a7ae9b0029fd /core
parentca47fc5f18178c88f8a4eff3de35f02b580bc6b1 (diff)
downloadnextcloud-server-883d1c0df32a942d3bb07f242e8ffcd871418f60.tar.gz
nextcloud-server-883d1c0df32a942d3bb07f242e8ffcd871418f60.zip
use template for txt and html mails to send notification mails
Diffstat (limited to 'core')
-rw-r--r--core/ajax/share.php41
-rw-r--r--core/templates/altmail.php6
-rw-r--r--core/templates/mail.php8
3 files changed, 29 insertions, 26 deletions
diff --git a/core/ajax/share.php b/core/ajax/share.php
index 8f5432a0fcb..293e140d1d5 100644
--- a/core/ajax/share.php
+++ b/core/ajax/share.php
@@ -91,8 +91,8 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
$itemType = $_POST['itemType'];
$itemSource = $_POST['itemSource'];
$recipient = $_POST['recipient'];
+ $ownerDisplayName = \OCP\User::getDisplayName();
$from = \OCP\Util::getDefaultEmailAddress('sharing-noreply');
- $subject = $defaults->getShareNotificationSubject($itemType);
$noMail = array();
$recipientList = array();
@@ -115,6 +115,7 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
$displayName = \OCP\User::getDisplayName($recipient);
$items = \OCP\Share::getItemSharedWithUser($itemType, $itemSource, $recipient);
$filename = trim($items[0]['file_target'], '/');
+ $subject = $defaults->getShareNotificationSubject($ownerDisplayName, $filename);
$expiration = null;
if (isset($items[0]['expiration'])) {
$expiration = $items[0]['expiration'];
@@ -128,29 +129,31 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
$foldername = "/Shared";
}
- $url = \OCP\Util::linkToAbsolute('files', 'index.php', array("dir" => $foldername));
- $text = $defaults->getShareNotificationText(
- \OCP\User::getDisplayName(),
- $filename,
- $itemType,
- $url,
- $expiration
- );
+ $link = \OCP\Util::linkToAbsolute('files', 'index.php', array("dir" => $foldername));
+
+ $content = new OC_Template("core", "mail", "");
+ $content->assign('link', $link);
+ $content->assign('user_displayname', $ownerDisplayName);
+ $content->assign('filename', $filename);
+ $content->assign('expiration', $expiration);
+ $text = $content->fetchPage();
+
+ $content = new OC_Template("core", "altmail", "");
+ $content->assign('link', $link);
+ $content->assign('user_displayname', $ownerDisplayName);
+ $content->assign('filename', $filename);
+ $content->assign('expiration', $expiration);
+ $alttext = $content->fetchPage();
+ $default_from = OCP\Util::getDefaultEmailAddress('sharing-noreply');
+ $from = OCP\Config::getUserValue(\OCP\User::getUser(), 'settings', 'email', $default_from);
+
+ // send it out now
try {
- OCP\Util::sendMail(
- $email,
- $displayName,
- $subject,
- $text,
- $from,
- \OCP\User::getDisplayName()
- );
+ OCP\Util::sendMail($email, $displayName, $subject, $text, $from, $ownerDisplayName, 1, $alttext);
} catch (Exception $exception) {
$noMail[] = \OCP\User::getDisplayName($recipient);
}
- } else {
- $noMail[] = \OCP\User::getDisplayName($recipient);
}
}
diff --git a/core/templates/altmail.php b/core/templates/altmail.php
index 2551473c6f0..f7159a021a8 100644
--- a/core/templates/altmail.php
+++ b/core/templates/altmail.php
@@ -1,7 +1,7 @@
<?php
-print_unescaped($l->t("Hey there,\n\njust letting you know that %s shared %s with you.\nView it: %s\n\nCheers!", array($_['user_displayname'], $_['filename'], $_['link'])));
+$expiration = isset($_['expiration']) ? $_['expiration'] : null;
+print_unescaped($theme->getShareNotificationTextAlt($_['user_displayname'], $_['filename'], $_['link'], $expiration));
?>
--
-<?php p($theme->getName() . ' - ' . $theme->getSlogan()); ?>
-<?php print_unescaped("\n".$theme->getBaseUrl());
+<?php print_unescaped($theme->getMailFooterAlt());
diff --git a/core/templates/mail.php b/core/templates/mail.php
index de72b136b13..5570e4caabe 100644
--- a/core/templates/mail.php
+++ b/core/templates/mail.php
@@ -12,7 +12,8 @@
<td bgcolor="#f8f8f8" width="20px">&nbsp;</td>
<td bgcolor="#f8f8f8" style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">
<?php
-print_unescaped($l->t('Hey there,<br><br>just letting you know that %s shared »%s« with you.<br><a href="%s">View it!</a><br><br>Cheers!', array($_['user_displayname'], $_['filename'], $_['link'])));
+$expiration = isset($_['expiration']) ? $_['expiration'] : null;
+print_unescaped($theme->getShareNotificationTextHtml($_['user_displayname'], $_['filename'], $_['link'], $expiration));
?>
</td>
</tr>
@@ -20,9 +21,8 @@ print_unescaped($l->t('Hey there,<br><br>just letting you know that %s shared »
<tr>
<td bgcolor="#f8f8f8" width="20px">&nbsp;</td>
<td bgcolor="#f8f8f8" style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">--<br>
-<?php p($theme->getName()); ?> -
-<?php p($theme->getSlogan()); ?>
-<br><a href="<?php print_unescaped($theme->getBaseUrl()); ?>"><?php print_unescaped($theme->getBaseUrl());?></a></td>
+<?php print_unescaped($theme->getMailFooterHtml()); ?>
+</td>
</tr>
<tr>
<td bgcolor="#f8f8f8" colspan="2">&nbsp;</td>