From 95044fba4d721d0c8f8a7a75fdfc5c51d9c8dc51 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Mon, 8 Sep 2014 17:13:07 -0500
Subject: [PATCH] search: Fixup hits on assignee and closed-by

This fixes hits when using the MySQL full text search backend
---
 include/ajax.tickets.php | 6 +++---
 include/class.search.php | 4 ++++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php
index d481e1c7c..f509ad5e8 100644
--- a/include/ajax.tickets.php
+++ b/include/ajax.tickets.php
@@ -167,12 +167,10 @@ class TicketsAjaxAPI extends AjaxController {
                 $where.=' AND ticket.team_id='.db_input($id);
                 $criteria['team_id'] = $id;
             }
-            elseif($assignee[0]=='s') {
+            elseif($assignee[0]=='s' || is_numeric($id)) {
                 $where.=' AND ticket.staff_id='.db_input($id);
                 $criteria['staff_id'] = $id;
             }
-            elseif(is_numeric($id))
-                $where.=' AND ticket.staff_id='.db_input($id);
 
             $where.=')';
 
@@ -186,6 +184,8 @@ class TicketsAjaxAPI extends AjaxController {
         } elseif($req['staffId']) { # closed-by
             $where.=' AND (ticket.staff_id='.db_input($req['staffId']).' AND
                 status.state IN("resolved", "closed")) ';
+            $criteria['state__in'] = array('resolved','closed');
+            $criteria['staff_id'] = $req['staffId'];
         }
 
         //dates
diff --git a/include/class.search.php b/include/class.search.php
index 9e3a380ef..c3b2b2c1e 100644
--- a/include/class.search.php
+++ b/include/class.search.php
@@ -308,8 +308,12 @@ class MysqlSearchBackend extends SearchBackend {
                     case 'state':
                         $where[] = 'A2.state = '.db_input($value);
                         break;
+                    case 'state__in':
+                        $where[] = 'A2.state IN ('.implode(',',db_input($value)).')';
+                        break;
                     case 'topic_id':
                     case 'staff_id':
+                    case 'team_id':
                     case 'dept_id':
                     case 'user_id':
                     case 'isanswered':
-- 
GitLab