Ejemplo n.º 1
0
 public function onEmailGenerate(EmailSendEvent $event)
 {
     $idHash = $event->getIdHash();
     if ($idHash == null) {
         // Generate a bogus idHash to prevent errors for routes that may include it
         $idHash = uniqid();
     }
     $model = $this->factory->getModel('email');
     $event->addToken('{unsubscribe_text}', $this->translator->trans('mautic.email.unsubscribe.text', array('%link%' => $model->buildUrl('mautic_email_unsubscribe', array('idHash' => $idHash)))));
     $event->addToken('{unsubscribe_url}', $model->buildUrl('mautic_email_unsubscribe', array('idHash' => $idHash)));
     $event->addToken('{webview_text}', $this->translator->trans('mautic.email.webview.text', array('%link%' => $model->buildUrl('mautic_email_webview', array('idHash' => $idHash)))));
     $event->addToken('{webview_url}', $model->buildUrl('mautic_email_webview', array('idHash' => $idHash)));
 }
Ejemplo n.º 2
0
 /**
  * @param EmailSendEvent $event
  */
 public function onEmailGenerate(EmailSendEvent $event)
 {
     $idHash = $event->getIdHash();
     $lead = $event->getLead();
     $email = $event->getEmail();
     if ($idHash == null) {
         // Generate a bogus idHash to prevent errors for routes that may include it
         $idHash = uniqid();
     }
     $model = $this->factory->getModel('email');
     $unsubscribeText = $this->factory->getParameter('unsubscribe_text');
     if (!$unsubscribeText) {
         $unsubscribeText = $this->translator->trans('mautic.email.unsubscribe.text', array('%link%' => '|URL|'));
     }
     $unsubscribeText = str_replace('|URL|', $model->buildUrl('mautic_email_unsubscribe', array('idHash' => $idHash)), $unsubscribeText);
     $event->addToken('{unsubscribe_text}', $unsubscribeText);
     $event->addToken('{unsubscribe_url}', $model->buildUrl('mautic_email_unsubscribe', array('idHash' => $idHash)));
     $webviewText = $this->factory->getParameter('webview_text');
     if (!$webviewText) {
         $webviewText = $this->translator->trans('mautic.email.webview.text', array('%link%' => '|URL|'));
     }
     $webviewText = str_replace('|URL|', $model->buildUrl('mautic_email_webview', array('idHash' => $idHash)), $webviewText);
     $event->addToken('{webview_text}', $webviewText);
     // Show public email preview if the lead is not known to prevent 404
     if (empty($lead['id']) && $email) {
         $event->addToken('{webview_url}', $model->buildUrl('mautic_email_preview', array('objectId' => $email->getId())));
     } else {
         $event->addToken('{webview_url}', $model->buildUrl('mautic_email_webview', array('idHash' => $idHash)));
     }
     $signatureText = $this->factory->getParameter('default_signature_text');
     $fromName = $this->factory->getParameter('mailer_from_name');
     if (!empty($lead['owner_id'])) {
         $owner = $this->factory->getModel('lead')->getRepository()->getLeadOwner($lead['owner_id']);
         if ($owner && !empty($owner['signature'])) {
             $fromName = $owner['first_name'] . ' ' . $owner['last_name'];
             $signatureText = $owner['signature'];
         }
     }
     $signatureText = str_replace('|FROM_NAME|', $fromName, nl2br($signatureText));
     $event->addToken('{signature}', $signatureText);
     $event->addToken('{subject}', $event->getSubject());
 }