Skip to content

Commit

Permalink
Misc. mailbox updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Akshay Kumar committed Dec 17, 2022
1 parent b8fe362 commit ef08bbf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
24 changes: 20 additions & 4 deletions Controller/Ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use Webkul\UVDesk\CoreFrameworkBundle\Entity\User;
use Webkul\UVDesk\CoreFrameworkBundle\Entity\TicketPriority;
use Webkul\UVDesk\CoreFrameworkBundle\Entity\TicketStatus;
use Webkul\UVDesk\MailboxBundle\Services\MailboxService;

class Ticket extends AbstractController
{
Expand All @@ -51,14 +52,29 @@ public function __construct(UserService $userService, TranslatorInterface $trans
$this->kernel = $kernel;
}

public function listTicketCollection(Request $request)
public function listTicketCollection(Request $request, MailboxService $mailboxService)
{
$entityManager = $this->getDoctrine()->getManager();

$mailboxCollection = [];
$mailboxConfiguration = $mailboxService->parseMailboxConfigurations();

foreach ($mailboxConfiguration->getMailboxes() as $mailbox) {
$imapConfiguration = $mailbox->getImapConfiguration();

if (!empty($imapConfiguration)) {
$mailboxCollection[] = [
'name' => $mailbox->getName(),
'email' => $imapConfiguration->getUsername(),
];
}
}

return $this->render('@UVDeskCoreFramework//ticketList.html.twig', [
'ticketStatusCollection' => $entityManager->getRepository(TicketStatus::class)->findAll(),
'ticketTypeCollection' => $entityManager->getRepository(TicketType::class)->findByIsActive(true),
'ticketPriorityCollection' => $entityManager->getRepository(TicketPriority::class)->findAll(),
'mailboxCollection' => $mailboxCollection,
'ticketStatusCollection' => $entityManager->getRepository(TicketStatus::class)->findAll(),
'ticketTypeCollection' => $entityManager->getRepository(TicketType::class)->findByIsActive(true),
'ticketPriorityCollection' => $entityManager->getRepository(TicketPriority::class)->findAll(),
]);
}

Expand Down
5 changes: 4 additions & 1 deletion Resources/views/ticketList.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -788,15 +788,18 @@
<label>{{ 'Filter With'|trans }}</label>
<ul class="">
{% set options = [] %}
{% for mailbox in ticket_service.getAllMailboxes() %}
{% for mailbox in mailboxCollection %}
{% set options = options|merge([{'id': mailbox.email, 'name': mailbox.name}]) %}

<li data-id="{{mailbox.email}}">
{{ mailbox.name|trans }}
</li>
{% endfor %}

<li class="uv-no-results" style="display: none;">
{{ 'No result found'|trans }}
</li>

{% set filterContext = filterContext|merge({'mailbox': options}) %}
</ul>
</div>
Expand Down
16 changes: 1 addition & 15 deletions Services/TicketService.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,6 @@ public function __construct(
$this->mailboxService = $mailboxService;
}

public function getAllMailboxes()
{
$collection = array_map(function ($mailbox) {
return [
'id' => $mailbox->getId(),
'name' => $mailbox->getName(),
'isEnabled' => $mailbox->getIsEnabled(),
'email' => $mailbox->getImapConfiguration()->getUsername(),
];
}, $this->mailboxService->parseMailboxConfigurations()->getMailboxes());

return $collection;
}

public function getPathToConfigurationFile()
{
return $this->container->get('kernel')->getProjectDir() . self::PATH_TO_CONFIG;
Expand Down Expand Up @@ -220,7 +206,7 @@ public function createTicketBase(array $ticketData = [])
if ('email' == $ticketData['source']) {
try {
if (array_key_exists('UVDeskMailboxBundle', $this->container->getParameter('kernel.bundles'))) {
$mailbox = $this->container->get('uvdesk.mailbox')->getMailboxByEmail($ticketData['mailboxEmail']);
$mailbox = $this->mailboxService->getMailboxByEmail($ticketData['mailboxEmail']);
$ticketData['mailboxEmail'] = $mailbox['email'];
}
} catch (\Exception $e) {
Expand Down

0 comments on commit ef08bbf

Please sign in to comment.