From a1a9db0bf7bafc26541f2b2c4e6873737dce74ad Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Wed, 27 Nov 2013 14:56:45 -0600 Subject: [PATCH] cc: Fixup handling of collaborators for emails --- include/class.mailparse.php | 14 +++++++++----- include/class.thread.php | 2 ++ include/class.ticket.php | 6 ++++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/include/class.mailparse.php b/include/class.mailparse.php index dfc4c6b3f..42d4abe24 100644 --- a/include/class.mailparse.php +++ b/include/class.mailparse.php @@ -140,11 +140,15 @@ class Mail_Parse { function getToAddressList(){ // Delivered-to incase it was a BBC mail. - if (!($header = $this->struct->headers['to'])) - if (!($header = $this->struct->headers['delivered-to'])) - return null; - - return Mail_Parse::parseAddressList($header); + $tolist = array(); + if ($header = $this->struct->headers['to']) + $tolist = array_merge($tolist, + Mail_Parse::parseAddressList($header)); + if ($header = $this->struct->headers['delivered-to']) + $tolist = array_merge($tolist, + Mail_Parse::parseAddressList($header)); + + return $tolist ? $tolist : null; } function getCcAddressList(){ diff --git a/include/class.thread.php b/include/class.thread.php index a68db4ddf..f797e6465 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -574,6 +574,7 @@ Class ThreadEntry { 'source' => 'Email', 'ip' => '', 'reply_to' => $this, + 'recipients' => $mailinfo['recipients'], ); if (isset($mailinfo['attachments'])) @@ -588,6 +589,7 @@ Class ThreadEntry { $vars['message'] = $body; return $ticket->postMessage($vars, 'Email'); } + // XXX: Consider collaborator role elseif ($staff_id = Staff::getIdByEmail($mailinfo['email'])) { $vars['staffId'] = $staff_id; $poster = Staff::lookup($staff_id); diff --git a/include/class.ticket.php b/include/class.ticket.php index b51269ccf..0f7d7e752 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -65,8 +65,10 @@ class Ticket { return false; $sql='SELECT ticket.*, lock_id, dept_name ' - .' ,IF(sla.id IS NULL, NULL, DATE_ADD(ticket.created, INTERVAL sla.grace_period HOUR)) as sla_duedate ' - .' ,count(attach.attach_id) as attachments, count(collab.id) as collaborators ' + .' ,IF(sla.id IS NULL, NULL, ' + .'DATE_ADD(ticket.created, INTERVAL sla.grace_period HOUR)) as sla_duedate ' + .' ,count(distinct attach.attach_id) as attachments' + .' ,count(distinct collab.id) as collaborators ' .' FROM '.TICKET_TABLE.' ticket ' .' LEFT JOIN '.DEPT_TABLE.' dept ON (ticket.dept_id=dept.dept_id) ' .' LEFT JOIN '.SLA_TABLE.' sla ON (ticket.sla_id=sla.id AND sla.isactive=1) ' -- GitLab