Skip to content

Commit 3c0c6c9

Browse files
authored
Merge pull request #672 from topcoder-platform/issues-670
Added a self-service email template
2 parents 290624a + 6a598f0 commit 3c0c6c9

File tree

2 files changed

+188
-2
lines changed

2 files changed

+188
-2
lines changed

vanilla/applications/dashboard/models/class.activitymodel.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,9 +1061,14 @@ public function email(&$activity, $options = []) {
10611061
$url = externalUrl(val('Route', $activity) == '' ? '/' : val('Route', $activity));
10621062
}
10631063

1064+
$emailTemplate = $email->getEmailTemplate();
1065+
// Set Custom Email View
1066+
if($activity['Data']['EmailTemplate']) {
1067+
$view = strval($activity['Data']['EmailTemplate']);
1068+
$emailTemplate->setView($view, 'email', 'dashboard');
1069+
}
10641070

1065-
$emailTemplate = $email->getEmailTemplate()
1066-
->setButton($url, val('ActionText', $activity, t('Check it out')))
1071+
$emailTemplate->setButton($url, val('ActionText', $activity, t('Check it out')))
10671072
->setTitle($subject);
10681073

10691074
if ($message = $this->getEmailMessage($activity)) {
@@ -1096,12 +1101,14 @@ public function email(&$activity, $options = []) {
10961101
}
10971102
}
10981103
} catch (phpmailerException $pex) {
1104+
logException($pex);
10991105
if ($pex->getCode() == PHPMailer::STOP_CRITICAL && !$email->PhpMailer->isServerError($pex)) {
11001106
$emailed = self::SENT_FAIL;
11011107
} else {
11021108
$emailed = self::SENT_ERROR;
11031109
}
11041110
} catch (Exception $ex) {
1111+
logException($ex);
11051112
switch ($ex->getCode()) {
11061113
case Gdn_Email::ERR_SKIPPED:
11071114
$emailed = self::SENT_SKIPPED;
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5+
<!--[if !mso]><!-->
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7+
<!--<![endif]-->
8+
{literal}
9+
<style type="text/css">
10+
.notification {
11+
margin: 0 0;
12+
padding: 0 0;
13+
font-size: 10pt;
14+
font-weight: normal;
15+
font-style: normal;
16+
font-family: "\48\65\6C\76\65\74\69\63\61", "\41\72\69\61", sans-serif;
17+
}
18+
.notification hr {
19+
border-top: 1px dashed #8c8b8b;
20+
border-bottom: 1px dashed #fff;
21+
}
22+
23+
.notification table td {
24+
border-collapse: collapse;
25+
}
26+
27+
.notification td {
28+
margin-top: 0px;
29+
margin-right: 0px;
30+
margin-bottom: 0px;
31+
margin-left: 0px;
32+
}
33+
34+
.notification td img {
35+
display: block;
36+
}
37+
38+
.notification a {
39+
font-size: 10pt;
40+
text-decoration: underline;
41+
}
42+
43+
.notification a img {
44+
text-decoration: none;
45+
}
46+
47+
.notification h1, h2, h3, h4, h5, h6 {
48+
font-weight: normal;
49+
font-style: normal;
50+
font-family: "\48\65\6C\76\65\74\69\63\61", "\41\72\69\61", sans-serif;
51+
margin: 2px 0;
52+
padding: 4px 0;
53+
}
54+
55+
.notification h1 {
56+
font-size: 14pt;
57+
font-weight: 700;
58+
}
59+
60+
.notification h2 {
61+
font-size: 12pt;
62+
font-weight: 700;
63+
}
64+
65+
.notification h3 {
66+
font-size: 10pt;
67+
font-weight: 600;
68+
}
69+
70+
.notification h4 {
71+
font-size: 10pt;
72+
font-weight: 500;
73+
}
74+
75+
.notification h5 {
76+
font-size: 10pt;
77+
font-weight: 400;
78+
}
79+
80+
.notification h6 {
81+
font-size: 10pt;
82+
font-weight: 300;
83+
}
84+
85+
.notification blockquote {
86+
padding: 1ex 16px;
87+
margin: 1em 0;
88+
background: #f3f3f3;
89+
background: rgba(0, 0, 0, 0.05);
90+
border-left: 4px solid #eee;
91+
border-left: 4px solid rgba(0, 0, 0, 0.1);
92+
min-width: 200px;
93+
overflow-y: initial;
94+
}
95+
.notification code {
96+
padding: 5px 20px;
97+
display: block;
98+
background-color: #f7f7f7;
99+
}
100+
101+
.notification p, span {
102+
padding: 0 0;
103+
margin: 0;
104+
}
105+
.footer a {
106+
text-decoration: underline;
107+
}
108+
</style>
109+
{/literal}
110+
</head>
111+
<body style="margin: 0; padding: 0; background-color: {$email.backgroundColor} !important; color: {$email.textColor};">
112+
<center>
113+
<div class="notification" style="max-width: 600px;color: {$email.textColor};background-color: {$email.containerBackgroundColor}">
114+
<!--[if (gte mso 9)|(IE)]>
115+
<table width="600" align="center" cellpadding="0" cellspacing="0" border="0" style="color: {$email.textColor};background-color: {$email.containerBackgroundColor}">
116+
<tr>
117+
<td>
118+
<![endif]-->
119+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="margin: auto;color: {$email.textColor};background-color: {$email.containerBackgroundColor}">
120+
<tbody>
121+
<tr>
122+
<td align="left" style="padding-bottom:15px;">
123+
{if $email.image}
124+
<a href="https://www.topcoder.com/" rel=" noopener noreferrer"
125+
target="_blank">
126+
{if $email.image.link != ''}
127+
<img alt="Topcoder"
128+
border="0"
129+
src="{$email.image.source}"
130+
style="width:120px">
131+
{/if}
132+
</a>
133+
{/if}
134+
</td>
135+
<td align="right">
136+
</td>
137+
</tr>
138+
</tbody>
139+
</table>
140+
<!--[if (gte mso 9)|(IE)]>
141+
</td>
142+
</tr>
143+
</table>
144+
<![endif]-->
145+
<!--[if (gte mso 9)|(IE)]>
146+
<table width="600" align="center" cellpadding="0" cellspacing="0" border="0">
147+
<tr>
148+
<td>
149+
<![endif]-->
150+
<table class="content" width="100%" border="0" cellpadding="5" cellspacing="0" style="margin: auto;color: {$email.textColor};background-color: {$email.containerBackgroundColor}">
151+
<tbody>
152+
<tr>
153+
<td>
154+
{if $email.title}<h1 style='color: {$email.textColor};'>{$email.title}</h1>{/if}
155+
{if $email.lead}<p style='color: {$email.textColor}'>{$email.lead}</p>{/if}
156+
<p class="message" style='margin: 0;Margin-bottom: 10px;padding: 0;color: {$email.textColor};text-align: left;margin-top: 10px;
157+
margin-bottom: 15px'>{$email.message}</p>
158+
{if $email.button}
159+
<div style="margin: 5px 0px;padding: 0;text-align: center">
160+
<a class="button" href="{$email.button.url}" style="font-size: 12px;
161+
border: 1px solid #137D60;min-width: 36px;background: #137D60;color: #FAFAFB;line-height: 30px;min-height: 30px;text-decoration: none;
162+
white-space: nowrap;text-align: center;font-weight: 700 !important;letter-spacing: .69px !important; text-transform: uppercase;
163+
border-radius: 20px !important; padding: 10px 20px !important;" rel=" noopener noreferrer" target="_blank">{$email.button.text}</a>
164+
</div>
165+
{/if}
166+
167+
</td>
168+
</tr>
169+
</tbody>
170+
</table>
171+
<!--[if (gte mso 9)|(IE)]>
172+
</td>
173+
</tr>
174+
</table>
175+
<![endif]-->
176+
</div>
177+
</center>
178+
</body>
179+
</html>

0 commit comments

Comments
 (0)