From 89c6ecf8d410324348ad0c449e870a144a7b1f5e Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@enhancesoft.com>
Date: Mon, 30 Oct 2017 05:13:23 +0000
Subject: [PATCH] queue: Department Quick Filter Choices

Limit the departments based on Agent's access
---
 include/class.search.php | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/include/class.search.php b/include/class.search.php
index ffdf9a46e..c2e4f93d1 100644
--- a/include/class.search.php
+++ b/include/class.search.php
@@ -702,10 +702,27 @@ class HelpTopicChoiceField extends ChoiceField {
 
 require_once INCLUDE_DIR . 'class.dept.php';
 class DepartmentChoiceField extends ChoiceField {
+    var $_choices = null;
+
     function getChoices($verbose=false) {
         return Dept::getDepartments();
     }
 
+   function getQuickFilterChoices() {
+       global $thisstaff;
+
+       if (!isset($this->_choices)) {
+         $this->_choices = array();
+         $depts = $thisstaff ? $thisstaff->getDepts() : array();
+         foreach ($this->getChoices() as $id => $name) {
+           if (!$depts || in_array($id, $depts))
+               $this->_choices[$id] = $name;
+         }
+       }
+
+       return $this->_choices;
+   }
+
     function getSearchMethods() {
         return array(
             'includes' =>   __('is'),
-- 
GitLab