/**
  * @param EmailBodyAdded $event
  */
 public function linkToScope(EmailBodyAdded $event)
 {
     if ($this->securityFacade->getToken() !== null && !$this->securityFacade->isGranted('CREATE', 'entity:' . AttachmentScope::ATTACHMENT)) {
         return;
     }
     $email = $event->getEmail();
     $entities = $this->activityListProvider->getTargetEntities($email);
     foreach ($entities as $entity) {
         if ((bool) $this->configProvider->getConfig(ClassUtils::getClass($entity))->get('auto_link_attachments')) {
             foreach ($email->getEmailBody()->getAttachments() as $attachment) {
                 $this->attachmentManager->linkEmailAttachmentToTargetEntity($attachment, $entity);
             }
         }
     }
 }
示例#2
0
 /**
  * @param EmailEntity $parentEmailEntity
  *
  * @return EmailModel
  */
 public function createReplyAllEmailModel(EmailEntity $parentEmailEntity)
 {
     $emailModel = $this->factory->getEmail();
     $emailModel->setMailType(EmailModel::MAIL_TYPE_REPLY);
     $emailModel->setParentEmailId($parentEmailEntity->getId());
     $fromAddress = $parentEmailEntity->getFromEmailAddress();
     if ($fromAddress->getOwner() === $this->helper->getUser()) {
         $toList = [];
         foreach ($parentEmailEntity->getTo() as $toRecipient) {
             $toEmail = $toRecipient->getEmailAddress()->getEmail();
             $this->helper->preciseFullEmailAddress($toEmail);
             $toList[] = $toEmail;
         }
         $ccList = [];
         foreach ($parentEmailEntity->getCc() as $ccRecipient) {
             $toEmail = $ccRecipient->getEmailAddress()->getEmail();
             $this->helper->preciseFullEmailAddress($toEmail);
             $ccList[] = $toEmail;
         }
         $emailModel->setTo($toList);
         $emailModel->setCc($ccList);
         $emailModel->setFrom($fromAddress->getEmail());
     } else {
         $toEmail = $fromAddress->getEmail();
         $this->helper->preciseFullEmailAddress($toEmail);
         $emailModel->setTo([$toEmail]);
         $this->initReplyAllFrom($emailModel, $parentEmailEntity);
     }
     $emailModel->setSubject($this->helper->prependWith('Re: ', $parentEmailEntity->getSubject()));
     $body = $this->helper->getEmailBody($parentEmailEntity, 'OroEmailBundle:Email/Reply:parentBody.html.twig');
     $emailModel->setBodyFooter($body);
     $emailModel->setContexts($this->activityListProvider->getTargetEntities($parentEmailEntity));
     return $this->createEmailModel($emailModel);
 }
示例#3
0
 /**
  * @param EmailEntity $parentEmailEntity
  *
  * @return EmailModel
  */
 public function createReplyEmailModel(EmailEntity $parentEmailEntity)
 {
     $emailModel = $this->factory->getEmail();
     $emailModel->setMailType(EmailModel::MAIL_TYPE_REPLY);
     $emailModel->setParentEmailId($parentEmailEntity->getId());
     $fromAddress = $parentEmailEntity->getFromEmailAddress();
     if ($fromAddress->getOwner() == $this->helper->getUser()) {
         $emailModel->setTo([$parentEmailEntity->getTo()->first()->getEmailAddress()->getEmail()]);
         $emailModel->setFrom($fromAddress->getEmail());
     } else {
         $emailModel->setTo([$fromAddress->getEmail()]);
         $this->initReplyFrom($emailModel, $parentEmailEntity);
     }
     $emailModel->setSubject($this->helper->prependWith('Re: ', $parentEmailEntity->getSubject()));
     $body = $this->helper->getEmailBody($parentEmailEntity, 'OroEmailBundle:Email/Reply:parentBody.html.twig');
     $emailModel->setBodyFooter($body);
     $emailModel->setContexts($this->activityListProvider->getTargetEntities($parentEmailEntity));
     return $this->createEmailModel($emailModel);
 }