Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report section in agent dashboard agent can access reports after privileges of access reports #662

Open
wants to merge 6 commits into
base: 1.1
Choose a base branch
from
8 changes: 6 additions & 2 deletions Controller/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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');
Expand Down
17 changes: 13 additions & 4 deletions Controller/Ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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');
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions Services/UVDeskService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
]
];
}
Expand Down
4 changes: 1 addition & 3 deletions UIComponents/Dashboard/Homepage/Sections/Reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
}
2 changes: 1 addition & 1 deletion UIComponents/Dashboard/Navigation/Reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static function getRouteName() : string

public static function getRoles() : array
{
return [];
return ['ROLE_AGENT_MANAGE_REPORTS'];
}

public function getChildrenRoutes() : array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion UIComponents/Dashboard/Panel/Items/Reports/Kudos.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 41 additions & 0 deletions UIComponents/Dashboard/Search/Report.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
namespace Webkul\UVDesk\CoreFrameworkBundle\UIComponents\Dashboard\Search;

use Webkul\UVDesk\CoreFrameworkBundle\Dashboard\Segments\SearchItemInterface;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\Loader\YamlFileLoader;
use Symfony\Component\HttpFoundation\Request;

class Report implements SearchItemInterface
{
CONST SVG = <<<SVG
<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 20 17">
<path id="activity" class="cls-1" d="M0,10v4H5L8,9l5,10h1l3-6h3V9H15l-1.364,3.854L8,2H7.015L3,10H0Z" transform="translate(0 -2)"></path>
</svg>
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 [];
}
}