From 1876ef16cc0c8c043bb1d45f7595968567655574 Mon Sep 17 00:00:00 2001 From: Abhishek Gupta Date: Wed, 31 May 2023 16:10:59 +0530 Subject: [PATCH 1/2] Admin can not create ticket when email is bloked --- Controller/Ticket.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Controller/Ticket.php b/Controller/Ticket.php index af6f51ae1..9c844d75d 100755 --- a/Controller/Ticket.php +++ b/Controller/Ticket.php @@ -31,6 +31,8 @@ use Webkul\UVDesk\CoreFrameworkBundle\Entity\User; use Webkul\UVDesk\CoreFrameworkBundle\Entity\TicketPriority; use Webkul\UVDesk\CoreFrameworkBundle\Entity\TicketStatus; +use Webkul\UVDesk\CoreFrameworkBundle\Entity as CoreEntites; + class Ticket extends AbstractController { @@ -172,11 +174,11 @@ public function saveTicket(Request $request) $requestParams = $request->request->all(); $entityManager = $this->getDoctrine()->getManager(); $response = $this->redirect($this->generateUrl('helpdesk_member_ticket_collection')); - + if ($request->getMethod() != 'POST' || false == $this->userService->isAccessAuthorized('ROLE_AGENT_CREATE_TICKET')) { return $response; } - + // Get referral ticket if any $ticketValidationGroup = 'CreateTicket'; $referralURL = $request->headers->get('referer'); @@ -185,16 +187,23 @@ public function saveTicket(Request $request) $iterations = explode('/', $referralURL); $referralId = array_pop($iterations); $expectedReferralURL = $this->generateUrl('helpdesk_member_ticket', ['ticketId' => $referralId], UrlGeneratorInterface::ABSOLUTE_URL); - + if ($referralURL === $expectedReferralURL) { $referralTicket = $entityManager->getRepository(CoreBundleTicket::class)->findOneById($referralId); - + if (!empty($referralTicket)) { $ticketValidationGroup = 'CustomerCreateTicket'; } } } + $email = $request->request->get('from'); + $website = $entityManager->getRepository(CoreEntites\Website::class)->findOneByCode('knowledgebase'); + if(!empty($email) && $this->ticketService->isEmailBlocked($email, $website)) { + $request->getSession()->getFlashBag()->set('warning', $this->translator->trans('Warning ! Cannot create ticket, given email is blocked.')); + return $this->redirect($this->generateUrl('helpdesk_member_ticket_collection')); + } + $ticketType = $entityManager->getRepository(TicketType::class)->findOneById($requestParams['type']); try { From 80a4e27d192cb92ce9e3c2f517a778760932fd81 Mon Sep 17 00:00:00 2001 From: Abhishek Gupta Date: Wed, 28 Jun 2023 18:48:13 +0530 Subject: [PATCH 2/2] Changes in agent dashboard to permission to access reports section after privileges :#644 --- Controller/Report.php | 8 +++- Services/UVDeskService.php | 1 + .../Dashboard/Homepage/Sections/Reports.php | 4 +- UIComponents/Dashboard/Navigation/Reports.php | 2 +- .../Panel/Items/Reports/AgentActivity.php | 2 +- .../Dashboard/Panel/Items/Reports/Kudos.php | 2 +- UIComponents/Dashboard/Search/Report.php | 41 +++++++++++++++++++ 7 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 UIComponents/Dashboard/Search/Report.php diff --git a/Controller/Report.php b/Controller/Report.php index 8e8fc0bfc..5271bfbc9 100755 --- a/Controller/Report.php +++ b/Controller/Report.php @@ -41,7 +41,7 @@ public function __construct(UserService $userService, UVDeskService $uvdeskServi public function listAgentActivity(Request $request) { - if (!$this->userService->isAccessAuthorized('ROLE_AGENT_MANAGE_AGENT_ACTIVITY')){ + if (!$this->userService->isAccessAuthorized('ROLE_AGENT_MANAGE_REPORTS')){ return $this->redirect($this->generateUrl('helpdesk_member_dashboard')); } @@ -63,7 +63,7 @@ public function agentActivityXHR(Request $request) public function agentActivityData(Request $request) { - if (!$this->userService->isAccessAuthorized('ROLE_AGENT_MANAGE_AGENT_ACTIVITY')){ + if (!$this->userService->isAccessAuthorized('ROLE_AGENT_MANAGE_REPORTS')){ throw new \Exception('Access Denied', 403); } @@ -145,6 +145,10 @@ public function agentActivityData(Request $request) public function achievementInsightsAction() { + if (!$this->userService->isAccessAuthorized('ROLE_AGENT_MANAGE_REPORTS')){ + return $this->redirect($this->generateUrl('helpdesk_member_dashboard')); + } + $this->userService->forceFormat = true; $startDate = $this->userService->convertToTimezone(new \DateTime("-7 days"), 'Y-m-d'); $endDate = $this->userService->convertToTimezone(new \DateTime("now"), 'Y-m-d'); diff --git a/Services/UVDeskService.php b/Services/UVDeskService.php index 1c081d740..73ec21bd4 100644 --- a/Services/UVDeskService.php +++ b/Services/UVDeskService.php @@ -298,6 +298,7 @@ public function getSupportPrivelegesResources() 'ROLE_AGENT_MANAGE_KNOWLEDGEBASE' => $translator->trans('Can manage knowledgebase'), 'ROLE_AGENT_MANAGE_AGENT_ACTIVITY' => $translator->trans("Can manage agent activity"), 'ROLE_AGENT_MANAGE_MARKETING_ANNOUNCEMENT' => $translator->trans("Can manage marketing announcement"), + 'ROLE_AGENT_MANAGE_REPORTS' => $translator->trans("Can manage reports"), ] ]; } diff --git a/UIComponents/Dashboard/Homepage/Sections/Reports.php b/UIComponents/Dashboard/Homepage/Sections/Reports.php index a208821b7..7a0736094 100644 --- a/UIComponents/Dashboard/Homepage/Sections/Reports.php +++ b/UIComponents/Dashboard/Homepage/Sections/Reports.php @@ -18,8 +18,6 @@ public static function getDescription() : string public static function getRoles() : array { - return [ - 'ROLE_AGENT_MANAGE_AGENT_ACTIVITY' - ]; + return ['ROLE_AGENT_MANAGE_REPORTS']; } } diff --git a/UIComponents/Dashboard/Navigation/Reports.php b/UIComponents/Dashboard/Navigation/Reports.php index 00092c1c1..824cdb976 100644 --- a/UIComponents/Dashboard/Navigation/Reports.php +++ b/UIComponents/Dashboard/Navigation/Reports.php @@ -32,7 +32,7 @@ public static function getRouteName() : string public static function getRoles() : array { - return []; + return ['ROLE_AGENT_MANAGE_REPORTS']; } public function getChildrenRoutes() : array diff --git a/UIComponents/Dashboard/Panel/Items/Reports/AgentActivity.php b/UIComponents/Dashboard/Panel/Items/Reports/AgentActivity.php index b0a6855ac..1cfbef6bb 100644 --- a/UIComponents/Dashboard/Panel/Items/Reports/AgentActivity.php +++ b/UIComponents/Dashboard/Panel/Items/Reports/AgentActivity.php @@ -24,7 +24,7 @@ public static function getSupportedRoutes() : array public static function getRoles() : array { - return ['ROLE_AGENT_MANAGE_AGENT_ACTIVITY']; + return ['ROLE_AGENT_MANAGE_REPORTS']; } public static function getSidebarReferenceId() : string diff --git a/UIComponents/Dashboard/Panel/Items/Reports/Kudos.php b/UIComponents/Dashboard/Panel/Items/Reports/Kudos.php index c249b9bb9..44e1b42d7 100644 --- a/UIComponents/Dashboard/Panel/Items/Reports/Kudos.php +++ b/UIComponents/Dashboard/Panel/Items/Reports/Kudos.php @@ -24,7 +24,7 @@ public static function getSupportedRoutes() : array public static function getRoles() : array { - return ['ROLE_AGENT_MANAGE_KUDOS']; + return ['ROLE_AGENT_MANAGE_REPORTS']; } public static function getSidebarReferenceId() : string diff --git a/UIComponents/Dashboard/Search/Report.php b/UIComponents/Dashboard/Search/Report.php new file mode 100644 index 000000000..435834f86 --- /dev/null +++ b/UIComponents/Dashboard/Search/Report.php @@ -0,0 +1,41 @@ + + + + SVG; + + public static function getIcon() : string + { + return self::SVG; + } + + public static function getTitle() : string + { + return "Reports"; + } + + public static function getRouteName() : string + { + return 'helpdesk_member_agent_activity'; + } + + public static function getRoles() : array + { + return ['ROLE_AGENT_MANAGE_REPORTS']; + } + + public function getChildrenRoutes() : array + { + return []; + } +} \ No newline at end of file