diff --git a/include/class.ticket.php b/include/class.ticket.php index d31ceffe2eefb51d779aac68fdfda2c43f5a78b2..f1fb1f3bbadec4c7273fd5c9c855f8dfb7de125c 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -151,9 +151,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 checkUserAccess($user) {