Пример #1
0
 /**
  * Add a do not contact entry for the lead
  *
  * @param Lead       $lead
  * @param string     $emailAddress
  * @param string     $reason
  * @param bool|true  $persist
  * @param bool|false $manual
  *
  * @return DoNotEmail|bool
  * @throws \Doctrine\DBAL\DBALException
  */
 public function setDoNotContact(Lead $lead, $emailAddress = '', $reason = '', $persist = true, $manual = false)
 {
     if (empty($emailAddress)) {
         $emailAddress = $lead->getEmail();
         if (empty($emailAddress)) {
             return false;
         }
     }
     $em = $this->factory->getEntityManager();
     $repo = $em->getRepository('MauticEmailBundle:Email');
     if (!$repo->checkDoNotEmail($emailAddress)) {
         $dnc = new DoNotEmail();
         $dnc->setLead($lead);
         $dnc->setEmailAddress($emailAddress);
         $dnc->setDateAdded(new \DateTime());
         $dnc->setUnsubscribed();
         $dnc->setManual($manual);
         $dnc->setComments($reason);
         if ($persist) {
             $repo->saveEntity($dnc);
         } else {
             $lead->addDoNotEmailEntry($dnc);
             return $dnc;
         }
     }
     return false;
 }
 /**
  * {@inheritDoc}
  */
 public function setUnsubscribed($unsubscribed = true)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUnsubscribed', array($unsubscribed));
     return parent::setUnsubscribed($unsubscribed);
 }
Пример #3
0
 /**
  * Add a do not contact entry for the lead
  *
  * @param Lead   $lead
  * @param string $emailAddress
  * @param string $reason
  * @param bool   $persist
  */
 public function setDoNotContact(Lead $lead, $emailAddress = '', $reason = '', $persist = true)
 {
     if (empty($emailAddress)) {
         $fields = $lead->getFields();
         $emailAddress = $fields['core']['email']['value'];
         if (empty($emailAddress)) {
             return;
         }
     }
     $em = $this->factory->getEntityManager();
     $repo = $em->getRepository('MauticEmailBundle:Email');
     if (!$repo->checkDoNotEmail($emailAddress)) {
         $dnc = new DoNotEmail();
         $dnc->setLead($lead);
         $dnc->setEmailAddress($emailAddress);
         $dnc->setDateAdded(new \DateTime());
         $dnc->setUnsubscribed();
         $dnc->setComments($reason);
         if ($persist) {
             $repo->saveEntity($dnc);
         } else {
             return $dnc;
         }
     }
 }