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

Commit

Permalink
Add details & Gmail view action to threshold notification
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrauer committed Feb 1, 2016
1 parent ba3d47b commit 97529ad
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions modules/tracker/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,34 @@ public function sendEmail($params)
$producerDao = $trendDao->getProducer();
$fullUrl = UtilityComponent::getServerURL().$this->webroot;
$email = $userDao->getEmail();
$subject = 'Tracker Dashboard Threshold Notification';

$producerName = $producerDao->getDisplayName();
$trendName = $trendDao->getDisplayName();
$thresholdValue = $notification['value'];
$thresholdComparison = $notification['comparison'];
$scalarValue = $scalar['value'];
$subject = 'Threshold Alert: ' . $producerName . ': ' . $trendName . ' value ' . $scalarValue . ' ' . $thresholdComparison . ' ' . $thresholdValue;

$body = 'Hello,<br/><br/>This email was sent because a submitted scalar value exceeded a threshold that you specified.<br/><br/>';
$body .= '<b>Community:</b> <a href="'.$fullUrl.'/community/'.$producerDao->getCommunityId(
).'">'.htmlspecialchars($producerDao->getCommunity()->getName(), ENT_QUOTES, 'UTF-8').'</a><br/>';
$body .= '<b>Producer:</b> <a href="'.$fullUrl.'/'.$this->moduleName.'/producer/view?producerId='.$producerDao->getKey(
).'">'.htmlspecialchars($producerDao->getDisplayName(), ENT_QUOTES, 'UTF-8').'</a><br/>';
$body .= '<b>Trend:</b> <a href="'.$fullUrl.'/'.$this->moduleName.'/trend/view?trendId='.$trendDao->getKey(
).'">'.htmlspecialchars($trendDao->getDisplayName(), ENT_QUOTES, 'UTF-8').'</a><br/>';
$body .= '<b>Value:</b> '.htmlspecialchars($scalar['value'], ENT_QUOTES, 'UTF-8');
$body .= 'Visit the above Trend link to change or disable notifications.<br/>';
$body .= '<b>Value:</b> '.htmlspecialchars($scalarValue, ENT_QUOTES, 'UTF-8').'<br/>';
$body .= '<b>Threshold:</b> '.htmlspecialchars($thresholdComparison, ENT_QUOTES, 'UTF-8').' '.htmlspecialchars($thresholdValue, ENT_QUOTES, 'UTF-8').'<br/>';

// Add gmail "View Action".
$trendTrackerUrl = $fullUrl.'/'.$this->moduleName.'/trend/view?trendId='.$trendDao->getKey();
$body .= '<div itemscope itemtype="http://schema.org/EmailMessage">';
$body .= ' <div itemprop="potentialAction" itemscope itemtype="http://schema.org/ViewAction">';
$body .= ' <link itemprop="target" href="'.$trendTrackerUrl.'"/>';
$body .= ' <meta itemprop="name" content="View trend plot"/>';
$body .= ' </div>';
$body .= ' <meta itemprop="description" content="View the trend plot"/>';
$body .= '</div>';

Zend_Registry::get('notifier')->callback(
'CALLBACK_CORE_SEND_MAIL_MESSAGE',
Expand Down

0 comments on commit 97529ad

Please sign in to comment.