/**
  * Returns the context for the given email
  *
  * @param Email $email
  *
  * @return array
  */
 public function getEmailContext(Email $email)
 {
     $criteria = Criteria::create();
     $criteria->andWhere(Criteria::expr()->eq('id', $email->getId()));
     $qb = $this->activityManager->getActivityTargetsQueryBuilder($this->class, $criteria);
     if (null === $qb) {
         return [];
     }
     $result = $qb->getQuery()->getResult();
     if (empty($result)) {
         return $result;
     }
     $currentUser = $this->securityFacade->getLoggedUser();
     $currentUserClass = ClassUtils::getClass($currentUser);
     $currentUserId = $currentUser->getId();
     $result = array_values(array_filter($result, function ($item) use($currentUserClass, $currentUserId) {
         return !($item['entity'] === $currentUserClass && $item['id'] == $currentUserId);
     }));
     foreach ($result as &$item) {
         $route = $this->configManager->getEntityMetadata($item['entity'])->getRoute();
         $item['entityId'] = $email->getId();
         $item['targetId'] = $item['id'];
         $item['targetClassName'] = $this->entityClassNameHelper->getUrlSafeClassName($item['entity']);
         $item['icon'] = $this->configManager->getProvider('entity')->getConfig($item['entity'])->get('icon');
         $item['link'] = $route ? $this->router->generate($route, ['id' => $item['id']]) : null;
         unset($item['id'], $item['entity']);
     }
     return $result;
 }
 /**
  * (@inherit)
  */
 public function setFlags(EmailFolder $folder, Email $email, $flags)
 {
     $repoImapEmail = $this->em->getRepository('OroImapBundle:ImapEmail');
     $uid = $repoImapEmail->getUid($folder->getId(), $email->getId());
     $this->connector->selectFolder($folder->getFullName());
     $this->connector->setFlags($uid, $flags);
 }
Example #3
0
 /**
  * @param EmailEntity $parentEmailEntity
  *
  * @return EmailModel
  */
 public function createForwardEmailModel(EmailEntity $parentEmailEntity)
 {
     $emailModel = $this->factory->getEmail();
     $emailModel->setMailType(EmailModel::MAIL_TYPE_FORWARD);
     $emailModel->setParentEmailId($parentEmailEntity->getId());
     $emailModel->setSubject($this->helper->prependWith('Fwd: ', $parentEmailEntity->getSubject()));
     $body = $this->helper->getEmailBody($parentEmailEntity, 'OroEmailBundle:Email/Forward:parentBody.html.twig');
     $emailModel->setBodyFooter($body);
     // link attachments of forwarded email to current email instance
     if ($this->request->isMethod('GET')) {
         $this->applyAttachments($emailModel, $parentEmailEntity);
     }
     return $this->createEmailModel($emailModel);
 }
Example #4
0
 /**
  * @param Email  $email
  * @param string $refs
  */
 protected function processRefs(Email $email, $refs)
 {
     if ($email->getId()) {
         if (!$this->areRefsEqual($email->getRefs(), $refs)) {
             throw $this->createInvalidPropertyException('Refs', $this->convertRefsToString($email->getRefs()), $this->convertRefsToString($refs));
         }
     } else {
         $email->setRefs($refs);
     }
 }
 /**
  * @param Email $email
  *
  * @return array of [id, entity, title]
  */
 protected function getAssignedEntities(Email $email)
 {
     $queryBuilder = $this->activityManager->getActivityTargetsQueryBuilder($this->class, ['id' => $email->getId()]);
     return $queryBuilder->getQuery()->getArrayResult();
 }