Пример #1
0
 /**
  * Trigger point actions for page hits.
  *
  * @param Events\PageHitEvent $event
  */
 public function onPageHit(Events\PageHitEvent $event)
 {
     $hit = $event->getHit();
     $redirect = $hit->getRedirect();
     if ($redirect && ($email = $hit->getEmail())) {
         // Check for an email stat
         $clickthrough = $event->getClickthroughData();
         if (isset($clickthrough['stat'])) {
             $stat = $this->emailModel->getEmailStatus($clickthrough['stat']);
         }
         if (empty($stat)) {
             if ($lead = $hit->getLead()) {
                 // Try searching by email and lead IDs
                 $stats = $this->emailModel->getEmailStati($hit->getSourceId(), $lead->getId());
                 if (count($stats)) {
                     $stat = $stats[0];
                 }
             }
         }
         if (!empty($stat)) {
             // Check to see if it has been marked as opened
             if (!$stat->isRead()) {
                 // Mark it as read
                 $this->emailModel->hitEmail($stat, $this->request);
             }
         }
     }
 }