From 8e6b55d20b09a8a986fe229d120660004f6f9647 Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@osticket.com>
Date: Wed, 5 Feb 2014 19:31:47 +0000
Subject: [PATCH] Only import collaborators when delivered-to email is known.
 This is necessary to avoid adding internal virtual address as a collaborator.

Store delivered-to email ID - giving us the ability to reply FROM specific
email address as opposed to the department's email.
---
 include/class.ticket.php | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/include/class.ticket.php b/include/class.ticket.php
index fe114a29d..827f6d944 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -1521,8 +1521,10 @@ class Ticket {
 
         $this->setLastMsgId($message->getId());
 
-        //Add email recipients as collaborators
-        if ($vars['recipients']) {
+        //Add email recipients as collaborators...
+        if ($vars['recipients']
+                //Only add if we have a matched local address
+                && $vars['emailId']) {
             //New collaborators added by other collaborators are disable --
             // requires staff approval.
             $info = array(
@@ -2280,6 +2282,9 @@ class Ticket {
             .' ,ip_address='.db_input($ipaddress)
             .' ,source='.db_input($source);
 
+        if (isset($vars['emailId']) && $vars['emailId'])
+            $sql.=', email_id='.db_input($vars['emailId']);
+
         //Make sure the origin is staff - avoid firebug hack!
         if($vars['duedate'] && !strcasecmp($origin,'staff'))
              $sql.=' ,duedate='.db_input(date('Y-m-d G:i',Misc::dbtime($vars['duedate'].' '.$vars['time'])));
-- 
GitLab