From 6feb31bf96215101e314ce2f0c03644495ad095c Mon Sep 17 00:00:00 2001
From: Stephen Colebrook <scolebrook@mac.com>
Date: Fri, 10 Oct 2014 09:29:38 -0400
Subject: [PATCH] Allow separate templates for internal and external share
 notifications

---
 core/templates/internalaltmail.php      | 13 +++++++++
 core/templates/internalmail.php         | 39 +++++++++++++++++++++++++
 lib/private/share/mailnotifications.php | 10 +++----
 3 files changed, 57 insertions(+), 5 deletions(-)
 create mode 100644 core/templates/internalaltmail.php
 create mode 100644 core/templates/internalmail.php

diff --git a/core/templates/internalaltmail.php b/core/templates/internalaltmail.php
new file mode 100644
index 0000000000..38531d109b
--- /dev/null
+++ b/core/templates/internalaltmail.php
@@ -0,0 +1,13 @@
+<?php
+print_unescaped($l->t("Hey there,\n\njust letting you know that %s shared %s with you.\nView it: %s\n\n", array($_['user_displayname'], $_['filename'], $_['link'])));
+if ( isset($_['expiration']) ) {
+	print_unescaped($l->t("The share will expire on %s.", array($_['expiration'])));
+	print_unescaped("\n\n");
+}
+// TRANSLATORS term at the end of a mail
+p($l->t("Cheers!"));
+?>
+
+--
+<?php p($theme->getName() . ' - ' . $theme->getSlogan()); ?>
+<?php print_unescaped("\n".$theme->getBaseUrl());
diff --git a/core/templates/internalmail.php b/core/templates/internalmail.php
new file mode 100644
index 0000000000..0e73a60185
--- /dev/null
+++ b/core/templates/internalmail.php
@@ -0,0 +1,39 @@
+<table cellspacing="0" cellpadding="0" border="0" width="100%">
+<tr><td>
+<table cellspacing="0" cellpadding="0" border="0" width="600px">
+<tr>
+<td bgcolor="<?php p($theme->getMailHeaderColor());?>" width="20px">&nbsp;</td>
+<td bgcolor="<?php p($theme->getMailHeaderColor());?>">
+<img src="<?php p(OC_Helper::makeURLAbsolute(image_path('', 'logo-mail.gif'))); ?>" alt="<?php p($theme->getName()); ?>"/>
+</td>
+</tr>
+<tr><td colspan="2">&nbsp;</td></tr>
+<tr>
+<td width="20px">&nbsp;</td>
+<td 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 <strong>%s</strong> with you.<br><a href="%s">View it!</a><br><br>', array($_['user_displayname'], $_['filename'], $_['link'])));
+if ( isset($_['expiration']) ) {
+	p($l->t("The share will expire on %s.", array($_['expiration'])));
+	print_unescaped('<br><br>');
+}
+// TRANSLATORS term at the end of a mail
+p($l->t('Cheers!'));
+?>
+</td>
+</tr>
+<tr><td colspan="2">&nbsp;</td></tr>
+<tr>
+<td width="20px">&nbsp;</td>
+<td 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 p($theme->getBaseUrl()); ?>"><?php p($theme->getBaseUrl());?></a>
+</td>
+</tr>
+<tr>
+<td colspan="2">&nbsp;</td>
+</tr>
+</table>
+</td></tr>
+</table>
diff --git a/lib/private/share/mailnotifications.php b/lib/private/share/mailnotifications.php
index 8056260bf1..2797e5ed99 100644
--- a/lib/private/share/mailnotifications.php
+++ b/lib/private/share/mailnotifications.php
@@ -136,7 +136,7 @@ class MailNotifications {
 
 			$link = \OCP\Util::linkToAbsolute('files', 'index.php', $args);
 
-			list($htmlBody, $textBody) = $this->createMailBody($filename, $link, $expiration);
+			list($htmlBody, $textBody) = $this->createMailBody($filename, $link, $expiration, 'internal');
 
 			// send it out now
 			try {
@@ -210,20 +210,20 @@ class MailNotifications {
 	 * @param string $filename the shared file
 	 * @param string $link link to the shared file
 	 * @param int $expiration expiration date (timestamp)
+	 * @param bool $prefix prefix of mail template files
 	 * @return array an array of the html mail body and the plain text mail body
 	 */
-	private function createMailBody($filename, $link, $expiration) {
-
+	private function createMailBody($filename, $link, $expiration, $prefix = '') {
 		$formattedDate = $expiration ? $this->l->l('date', $expiration) : null;
 
-		$html = new \OC_Template("core", "mail", "");
+		$html = new \OC_Template('core', $prefix . 'mail', '');
 		$html->assign ('link', $link);
 		$html->assign ('user_displayname', $this->senderDisplayName);
 		$html->assign ('filename', $filename);
 		$html->assign('expiration',  $formattedDate);
 		$htmlMail = $html->fetchPage();
 
-		$plainText = new \OC_Template("core", "altmail", "");
+		$plainText = new \OC_Template('core', $prefix . 'altmail', '');
 		$plainText->assign ('link', $link);
 		$plainText->assign ('user_displayname', $this->senderDisplayName);
 		$plainText->assign ('filename', $filename);
-- 
GitLab