diff --git a/include/class.ticket.php b/include/class.ticket.php index 578cbeeeb7e064b89bd928748637dc8bc9accd8e..d046a85f71aa065027161ce53cdc7c42470aae4a 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -147,9 +147,24 @@ class Ticket { if(!is_object($staff) && !($staff=Staff::lookup($staff))) return false; - return ((!$staff->showAssignedOnly() && $staff->canAccessDept($this->getDeptId())) - || ($this->getTeamId() && $staff->isTeamMember($this->getTeamId())) - || $staff->getId()==$this->getStaffId()); + // Staff has access to the department. + if (!$staff->showAssignedOnly() + && $staff->canAccessDept($this->getDeptId())) + return true; + + // Only consider assignment if the ticket is open + if (!$this->isOpen()) + return false; + + // Check ticket access based on direct or team assignment + if ($staff->getId() == $this->getStaffId() + || ($this->getTeamId() + && $staff->isTeamMember($this->getTeamId()) + )) + return true; + + // No access bro! + return false; } function checkClientAccess($client) {