From 71bb00039ade8cf4800faf3fb929add3af7a3338 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Mon, 8 Oct 2012 10:50:43 -0400 Subject: [PATCH] Change getDepartments to take in a "criteria" hashtable --- include/class.dept.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/class.dept.php b/include/class.dept.php index 0eae779c9..f00ba0205 100644 --- a/include/class.dept.php +++ b/include/class.dept.php @@ -308,12 +308,15 @@ class Dept { return ($cfg && $cfg->getDefaultDeptId() && ($name=Dept::getNameById($cfg->getDefaultDeptId())))?$name:null; } - function getDepartments( $publiconly=false) { + function getDepartments( $criteria=null) { $depts=array(); - $sql ='SELECT dept_id, dept_name FROM '.DEPT_TABLE; - if($publiconly) - $sql.=' WHERE ispublic=1'; + $sql='SELECT dept_id, dept_name FROM '.DEPT_TABLE.' WHERE 1'; + if($criteria['publiconly']) + $sql.=' AND ispublic=1'; + + if(($manager=$criteria['manager'])) + $sql.=' AND manager_id='.db_input(is_object($manager)?$manager->getId():$manager); if(($res=db_query($sql)) && db_num_rows($res)) { while(list($id, $name)=db_fetch_row($res)) @@ -324,7 +327,7 @@ class Dept { } function getPublicDepartments() { - return self::getDepartments(true); + return self::getDepartments(array('publiconly'=>true)); } function create($vars, &$errors) { -- GitLab