| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentSupport\App\Http\Policies; |
| 4 |
|
| 5 |
use FluentSupport\App\Modules\PermissionManager; |
| 6 |
use FluentSupport\Framework\Request\Request; |
| 7 |
use FluentSupport\Framework\Foundation\Policy; |
| 8 |
|
| 9 |
class AgentTicketPolicy extends Policy |
| 10 |
{ |
| 11 |
/** |
| 12 |
* Check user permission for any method |
| 13 |
* @param \FluentSupport\Framework\Request\Request $request |
| 14 |
* @return Boolean |
| 15 |
*/ |
| 16 |
public function verifyRequest(Request $request) |
| 17 |
{ |
| 18 |
$permissions = PermissionManager::currentUserPermissions(); |
| 19 |
$acceptedPermissions = ['fst_manage_own_tickets', 'fst_manage_unassigned_tickets', 'fst_manage_other_tickets', 'fst_merge_tickets','fst_draft_reply']; |
| 20 |
$status = !!array_intersect($permissions, $acceptedPermissions); |
| 21 |
|
| 22 |
return apply_filters('fluent_support/agent_has_access', $status, $request); |
| 23 |
} |
| 24 |
|
| 25 |
public function doBulkActions(Request $request) |
| 26 |
{ |
| 27 |
$action = $request->get('bulk_action'); |
| 28 |
|
| 29 |
if ($action == 'delete_tickets') { |
| 30 |
return PermissionManager::currentUserCan('fst_delete_tickets'); |
| 31 |
} |
| 32 |
|
| 33 |
return $this->verifyRequest($request); |
| 34 |
} |
| 35 |
} |
| 36 |
|