diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php
index d481e1c7cdedbc6c50e1ae2ce5780e74583a9095..f509ad5e8407c5ceafb8f054c790c62da224accb 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 9e3a380efbfc081c42fe27ddf5b32a95f7f244d4..c3b2b2c1e0cb2ef30aef3ddd43cadc53d2bf15d1 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':