diff --git a/include/class.ticket.php b/include/class.ticket.php index 172e8671823998902e5c1d4eb58f636d0437d063..78058d5483af63de3a8734255750bb81c709cf27 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; } diff --git a/include/staff/templates/collaborators.tmpl.php b/include/staff/templates/collaborators.tmpl.php index 3136cc96d29c507168cddc3f0d55bdf2d7f71f2f..20e5192ca74e2b3a372f4b9eb6981def33cbd792 100644 --- a/include/staff/templates/collaborators.tmpl.php +++ b/include/staff/templates/collaborators.tmpl.php @@ -54,4 +54,18 @@ if(($users=$ticket->getCollaborators())) {?> } else { echo "Bro, not sure how you got here!"; } + +if ($_POST && $ticket && $ticket->getNumCollaborators()) { + $recipients = sprintf('Recipients (%d of %d)', + $ticket->getNumActiveCollaborators(), + $ticket->getNumCollaborators()); + ?> + <script type="text/javascript"> + $(function() { + $('#emailcollab').show(); + $('#recipients').html('<?php echo $recipients; ?>'); + }); + </script> +<?php +} ?>