Пример #1
0
 /**
  * Send an email to the user that a threshold was crossed.
  *
  * @param array $params associative array of parameters including the keys "notification" and "scalar"
  */
 public function sendEmail($params)
 {
     /** @var array $notification */
     $notification = $params['notification'];
     /** @var UserDao $userDao */
     $userDao = $this->User->load($notification['recipient_id']);
     if ($userDao === false) {
         $this->getLogger()->warn('Attempting to send threshold notification to user id ' . $notification['recipient_id'] . ': No such user.');
         return;
     }
     /** @var array $scalar */
     $scalar = $params['scalar'];
     /** @var Tracker_TrendDao $trendDao */
     $trendDao = $this->Tracker_Trend->load($scalar['trend_id']);
     if ($trendDao === false) {
         $this->getLogger()->warn('Attempting to send threshold notification for trend id ' . $scalar['trend_id'] . ': No such trend.');
         return;
     }
     $producerDao = $trendDao->getProducer();
     $fullUrl = UtilityComponent::getServerURL() . $this->webroot;
     $email = $userDao->getEmail();
     $subject = 'Tracker Dashboard Threshold Notification';
     $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->getMetric()->getDisplayName(), ENT_QUOTES, 'UTF-8') . '</a><br/>';
     $body .= '<b>Value:</b> ' . htmlspecialchars($scalar['value'], ENT_QUOTES, 'UTF-8');
     Zend_Registry::get('notifier')->callback('CALLBACK_CORE_SEND_MAIL_MESSAGE', array('to' => $email, 'subject' => $subject, 'html' => $body, 'event' => 'tracker_threshold_crossed'));
 }
Пример #2
0
 /**
  * Return the URL of the server.
  *
  * @return string
  */
 public function getServerURL()
 {
     return UtilityComponent::getServerURL();
 }