From 21e4e1ac04d5baad82bd91acb36c9f0c4698a29f Mon Sep 17 00:00:00 2001
From: Jared Hancock <gravydish@gmail.com>
Date: Sat, 25 Aug 2012 21:58:02 -0500
Subject: [PATCH] Fix help topic auto-assignment

---
 include/class.ticket.php | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/include/class.ticket.php b/include/class.ticket.php
index 8b9581d53..d15b18c50 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -1924,16 +1924,16 @@ class Ticket{
                 $errors['duedate']='Due date must be in the future';
         }
 
+        //Any error above is fatal.
+        if ($errors) return 0;
+
         # Perform email filter actions on the new ticket arguments XXX: Move filter to the top and check for reject...
-        if (!$errors && $email_filter) $email_filter->apply($vars);
+        if ($email_filter) $email_filter->apply($vars);
 
         # Some things will need to be unpacked back into the scope of this
         # function
         if (isset($vars['autorespond'])) $autorespond=$vars['autorespond'];
 
-        //Any error above is fatal.
-        if($errors)  return 0;
-        
         // OK...just do it.
         $deptId=$vars['deptId']; //pre-selected Dept if any.
         $priorityId=$vars['priorityId'];
@@ -1945,6 +1945,10 @@ class Ticket{
             $priorityId=$priorityId?$priorityId:$topic->getPriorityId();
             if($autorespond) $autorespond=$topic->autoRespond();
             $source=$vars['source']?$vars['source']:'Web';
+            if (!isset($vars['staffId']) && $topic->getStaffId())
+                $vars['staffId'] = $topic->getStaffId();
+            elseif (!isset($vars['teamId']) && $topic->getTeamId())
+                $vars['teamId'] = $topic->getTeamId();
         }elseif($vars['emailId'] && !$vars['deptId'] && ($email=Email::lookup($vars['emailId']))) { //Emailed Tickets
             $deptId=$email->getDeptId();
             $priorityId=$priorityId?$priorityId:$email->getPriorityId();
-- 
GitLab