/** *searchLdap * *searches database and returns the information on the matches consistant with the search term * *@param integer $which *@param integer $search_type *@param string $search_term *@param mixed $max_result *@return array * */ function searchLdap($which, $search_type, $search_term, $max_results = 0) { /* which is 0=>all 1=>fac/staff 2=>student 3=>department search_type is what to search on, valid search types: 1=>first_name 2=>last_name 3=>username 4=>extention 5=>exact username 6=>department 7=>full_name 8=>all */ if (empty($search_term) || $search_type < 1 || $search_type > 8) { return 0; } //end if switch ($search_type) { case 1: // first_name $type = 'givenName'; $search = $search_term . '*'; break; case 2: // last_name $type = 'sn'; $search = '*' . $search_term . '*'; break; case 3: // username $type = 'pdsLoginId'; $search = $search_term . '*'; break; case 4: // extention $type = 'telephonenumber'; $search = '*' . $search_term . '*'; break; case 5: // complete username $type = 'pdsLoginId'; $search = $search_term; break; case 6: // department $type = 'ou'; $search = $search_term; break; case 7: // full name $type = 'cn'; $search = '*' . $search_term . '*'; break; case 8: // any (slow) return 'Error: invalid search type'; break; } //end switch $info = array(); require_once 'portal.class.php'; $portal = new Portal(); $data = $portal->getUserInfo($search, $type, true); if (is_array($data)) { foreach ($data as $person) { $i++; if ($which == 0 || $which == 1 && is_array($person['pdsrole']) && in_array('employee', $person['pdsrole']) || $which == 2 && is_array($person['pdsrole']) && in_array('student_active', $person['pdsrole']) || $which == 3 && is_array($person['pdsrole']) && in_array('employee', $person['pdsrole'])) { $info[$person['last_name'] . $person['first_name'] . $person['username']] = $person; } //end if } //end foreach ksort($info); } //end if return $info; }