Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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