settings updates
This commit is contained in:
@@ -16,15 +16,10 @@ final class TicketPolicy
|
||||
|
||||
public function view(User $user, Ticket $ticket): bool
|
||||
{
|
||||
if ($this->isHelpdeskAdmin($user)) {
|
||||
if ($this->isAdmin($user) || $this->isAgent($user)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->isHelpdeskAgent($user)) {
|
||||
return (int) $ticket->agent_id === (int) $user->id
|
||||
|| (int) $ticket->user_id === (int) $user->id;
|
||||
}
|
||||
|
||||
return (int) $ticket->user_id === (int) $user->id;
|
||||
}
|
||||
|
||||
@@ -33,29 +28,13 @@ final class TicketPolicy
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helpdesk workflow updates.
|
||||
*
|
||||
* Admins can update every Helpdesk ticket.
|
||||
*
|
||||
* Agents can update any ticket that is visible to them under the Helpdesk
|
||||
* visibility rules. This is important for Kanban drag/drop: a card must
|
||||
* never be displayed as movable and then fail authorization on drop.
|
||||
*
|
||||
* Normal requesters cannot change workflow/status/assignment data.
|
||||
*/
|
||||
public function update(User $user, Ticket $ticket): bool
|
||||
{
|
||||
if ($this->isHelpdeskAdmin($user)) {
|
||||
if ($this->isAdmin($user) || $this->isAgent($user)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (! $this->isHelpdeskAgent($user)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (int) $ticket->agent_id === (int) $user->id
|
||||
|| (int) $ticket->user_id === (int) $user->id;
|
||||
return (int) $ticket->user_id === (int) $user->id;
|
||||
}
|
||||
|
||||
public function comment(User $user, Ticket $ticket): bool
|
||||
@@ -65,36 +44,20 @@ final class TicketPolicy
|
||||
|
||||
public function delete(User $user, Ticket $ticket): bool
|
||||
{
|
||||
return $this->isHelpdeskAdmin($user);
|
||||
return $this->isAdmin($user);
|
||||
}
|
||||
|
||||
private function isHelpdeskAdmin(User $user): bool
|
||||
private function isAdmin(User $user): bool
|
||||
{
|
||||
if (method_exists($user, 'isHelpdeskAdmin')) {
|
||||
return $user->isHelpdeskAdmin();
|
||||
}
|
||||
|
||||
if ((bool) ($user->helpdesk_admin ?? false)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (method_exists($user, 'isAdmin')) {
|
||||
return $user->isAdmin();
|
||||
}
|
||||
|
||||
if (method_exists($user, 'isMpbaPlatformAdmin')) {
|
||||
return $user->isMpbaPlatformAdmin();
|
||||
}
|
||||
|
||||
return false;
|
||||
return (method_exists($user, 'isHelpdeskAdmin') && $user->isHelpdeskAdmin())
|
||||
|| (bool) ($user->helpdesk_admin ?? false)
|
||||
|| (method_exists($user, 'isAdmin') && $user->isAdmin());
|
||||
}
|
||||
|
||||
private function isHelpdeskAgent(User $user): bool
|
||||
private function isAgent(User $user): bool
|
||||
{
|
||||
if (method_exists($user, 'isHelpdeskAgent')) {
|
||||
return $user->isHelpdeskAgent();
|
||||
}
|
||||
|
||||
return (bool) ($user->helpdesk_agent ?? false);
|
||||
return (method_exists($user, 'isHelpdeskAgent') && $user->isHelpdeskAgent())
|
||||
|| (bool) ($user->helpdesk_agent ?? false)
|
||||
|| (method_exists($user, 'isAgent') && $user->isAgent());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user