Ejemplo n.º 1
0
 /**
  * @return array
  */
 protected function createChoices()
 {
     $user = $this->securityFacade->getLoggedUser();
     if (!$user instanceof User) {
         return [];
     }
     $emails = array_merge(array_values($this->relatedEmailsProvider->getEmails($user, 1, true)), $this->mailboxManager->findAvailableMailboxEmails($user, $this->securityFacade->getOrganization()));
     return array_combine($emails, $emails);
 }
Ejemplo n.º 2
0
 public function testFilterQueryByUserIdWhenNoMailboxesFound()
 {
     $user = new User();
     $organization = new Organization();
     $em = $this->getTestEntityManager();
     $qb = $em->createQueryBuilder();
     $this->securityFacade->expects($this->once())->method('getLoggedUser')->will($this->returnValue($user));
     $this->securityFacade->expects($this->once())->method('getOrganization')->will($this->returnValue($organization));
     $this->mailboxManager->expects($this->any())->method('findAvailableMailboxIds')->with($user, $organization)->will($this->returnValue([1, 3, 5]));
     $qb->select('eu')->from('EmailUser', 'eu');
     $this->factory->applyAcl($qb, 1);
     $this->assertEquals("SELECT eu FROM EmailUser eu" . " WHERE (eu.owner = :owner AND eu.organization  = :organization) OR eu.mailboxOwner IN(:mailboxIds)", $qb->getQuery()->getDQL());
 }
Ejemplo n.º 3
0
 /**
  * Returns array of mailbox choices.
  *
  * @return array
  */
 public function getChoiceList()
 {
     /** @var Mailbox[] $systemMailboxes */
     $systemMailboxes = $this->mailboxManager->findAvailableMailboxes($this->securityFacade->getLoggedUser(), $this->getOrganization());
     $origins = $this->mailboxManager->findAvailableOrigins($this->securityFacade->getLoggedUser(), $this->getOrganization());
     $choiceList = [];
     foreach ($origins as $origin) {
         $mailbox = $origin->getMailboxName();
         if (count($origin->getFolders()) > 0) {
             $choiceList[$origin->getId()] = str_replace('@', '\\@', $mailbox);
         }
     }
     foreach ($systemMailboxes as $mailbox) {
         if ($mailbox->getOrigin() !== null) {
             $choiceList[$mailbox->getOrigin()->getId()] = $mailbox->getLabel();
         }
     }
     return $choiceList;
 }
Ejemplo n.º 4
0
 /**
  * Returns mailboxes available to currently logged in user.
  *
  * @return Mailbox[]
  */
 public function getMailboxes()
 {
     $mailboxes = $this->mailboxManager->findAvailableMailboxes($this->getUser(), $this->getOrganization());
     return $mailboxes;
 }