Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 97529ad

Browse files
author
mgrauer
committed
Add details & Gmail view action to threshold notification
1 parent ba3d47b commit 97529ad

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

modules/tracker/Notification.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,34 @@ public function sendEmail($params)
168168
$producerDao = $trendDao->getProducer();
169169
$fullUrl = UtilityComponent::getServerURL().$this->webroot;
170170
$email = $userDao->getEmail();
171-
$subject = 'Tracker Dashboard Threshold Notification';
171+
172+
$producerName = $producerDao->getDisplayName();
173+
$trendName = $trendDao->getDisplayName();
174+
$thresholdValue = $notification['value'];
175+
$thresholdComparison = $notification['comparison'];
176+
$scalarValue = $scalar['value'];
177+
$subject = 'Threshold Alert: ' . $producerName . ': ' . $trendName . ' value ' . $scalarValue . ' ' . $thresholdComparison . ' ' . $thresholdValue;
178+
172179
$body = 'Hello,<br/><br/>This email was sent because a submitted scalar value exceeded a threshold that you specified.<br/><br/>';
173180
$body .= '<b>Community:</b> <a href="'.$fullUrl.'/community/'.$producerDao->getCommunityId(
174181
).'">'.htmlspecialchars($producerDao->getCommunity()->getName(), ENT_QUOTES, 'UTF-8').'</a><br/>';
175182
$body .= '<b>Producer:</b> <a href="'.$fullUrl.'/'.$this->moduleName.'/producer/view?producerId='.$producerDao->getKey(
176183
).'">'.htmlspecialchars($producerDao->getDisplayName(), ENT_QUOTES, 'UTF-8').'</a><br/>';
177184
$body .= '<b>Trend:</b> <a href="'.$fullUrl.'/'.$this->moduleName.'/trend/view?trendId='.$trendDao->getKey(
178185
).'">'.htmlspecialchars($trendDao->getDisplayName(), ENT_QUOTES, 'UTF-8').'</a><br/>';
179-
$body .= '<b>Value:</b> '.htmlspecialchars($scalar['value'], ENT_QUOTES, 'UTF-8');
186+
$body .= 'Visit the above Trend link to change or disable notifications.<br/>';
187+
$body .= '<b>Value:</b> '.htmlspecialchars($scalarValue, ENT_QUOTES, 'UTF-8').'<br/>';
188+
$body .= '<b>Threshold:</b> '.htmlspecialchars($thresholdComparison, ENT_QUOTES, 'UTF-8').' '.htmlspecialchars($thresholdValue, ENT_QUOTES, 'UTF-8').'<br/>';
189+
190+
// Add gmail "View Action".
191+
$trendTrackerUrl = $fullUrl.'/'.$this->moduleName.'/trend/view?trendId='.$trendDao->getKey();
192+
$body .= '<div itemscope itemtype="http://schema.org/EmailMessage">';
193+
$body .= ' <div itemprop="potentialAction" itemscope itemtype="http://schema.org/ViewAction">';
194+
$body .= ' <link itemprop="target" href="'.$trendTrackerUrl.'"/>';
195+
$body .= ' <meta itemprop="name" content="View trend plot"/>';
196+
$body .= ' </div>';
197+
$body .= ' <meta itemprop="description" content="View the trend plot"/>';
198+
$body .= '</div>';
180199

181200
Zend_Registry::get('notifier')->callback(
182201
'CALLBACK_CORE_SEND_MAIL_MESSAGE',

0 commit comments

Comments
 (0)