| @@ -3,9 +3,8 @@ | ||
| 3 | 3 | namespace FluentSupport\App\Modules; |
| 4 | 4 | |
| 5 | 5 | use FluentSupport\App\Models\MailBox; |
| 6 | 6 | use FluentSupport\App\Services\Helper; |
| 7 | -use FluentSupport\App\Services\Tickets\AgentTicketAccess; | |
| 8 | 7 | use FluentSupport\Framework\Support\Arr; |
| 9 | 8 | |
| 10 | 9 | /** |
| 11 | 10 | * PermissionManager class is responsible for getting/settings data related to permission |
| @@ -340,10 +339,18 @@ | ||
| 340 | 339 | * @return array Mailbox IDs the agent cannot access, or empty array if unrestricted. |
| 341 | 340 | */ |
| 342 | 341 | public static function getRestrictedMailboxIds() |
| 343 | 342 | { |
| 344 | - return (new AgentTicketAccess())->getRestrictedMailboxIds(); | |
| 343 | + $agent = Helper::getAgentByUserId(); | |
| 344 | + $restrictions = $agent->getMeta('agent_restrictions'); | |
| 345 | 345 | |
| 346 | + // Only enforce mailbox restrictions when the toggle is explicitly enabled | |
| 347 | + if (!empty($restrictions['businessBoxRestrictions']) && !empty($restrictions['restrictedBusinessBoxes'])) { | |
| 348 | + return $restrictions['restrictedBusinessBoxes']; | |
| 349 | + } | |
| 350 | + | |
| 351 | + return []; | |
| 352 | + | |
| 346 | 353 | } |
| 347 | 354 | |
| 348 | 355 | /** |
| 349 | 356 | * Whether the current user can perform mutating ticket actions (reply, close, reopen, assign, etc.). |
| @@ -443,9 +450,22 @@ | ||
| 443 | 450 | * @return bool |
| 444 | 451 | */ |
| 445 | 452 | public static function canAccessTicket($ticket) |
| 446 | 453 | { |
| 447 | - return (new AgentTicketAccess())->currentAgentCanAccess($ticket); | |
| 454 | + $permissionLevel = self::currentTicketVisibility(); | |
| 455 | + | |
| 456 | + if ($permissionLevel == self::VISIBILITY_ALL) { | |
| 457 | + return true; | |
| 458 | + } | |
| 459 | + | |
| 460 | + $agent = Helper::getAgentByUserId(); | |
| 461 | + | |
| 462 | + if ($ticket->agent_id == $agent->id) { | |
| 463 | + return true; | |
| 464 | + } | |
| 465 | + | |
| 466 | + // Allow access to unassigned tickets for agents with assigned_and_unassigned visibility | |
| 467 | + return !$ticket->agent_id && $permissionLevel == self::VISIBILITY_ASSIGNED_AND_UNASSIGNED; | |
| 448 | 468 | } |
| 449 | 469 | |
| 450 | 470 | /** |
| 451 | 471 | * getReadablePermissionGroups method will return the permission group as array |