From 03e1f324d080ac3c276a86aeecc0ea4029576dd2 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Mon, 20 Jan 2014 20:29:35 +0000 Subject: [PATCH] On ownership change remove the user as a collaborator A ticket owner can't be a collaborator. --- include/class.ticket.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/include/class.ticket.php b/include/class.ticket.php index a815cb932..a891f11f9 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -1479,11 +1479,20 @@ class Ticket { $this->ht['user_id'] = $user->getId(); $this->user = null; + $this->collaborators = null; + $this->recipients = null; - $this->logNote('Ticket ownership changed', - Format::htmlchars( sprintf('%s changed ticket ownership to %s', - $thisstaff->getName(), $user->getName())) - ); + //Log an internal note + $note = sprintf('%s changed ticket ownership to %s', + $thisstaff->getName(), $user->getName()); + + //Remove the new owner from list of collaborators + $c = Collaborator::lookup(array('userId' => $user->getId(), + 'ticketId' => $this->getId())); + if ($c && $c->remove()) + $note.= ' (removed as collaborator)'; + + $this->logNote('Ticket ownership changed', $note); return true; } -- GitLab