diff --git a/phpgwapi/inc/class.contacts_ldap.inc.php b/phpgwapi/inc/class.contacts_ldap.inc.php index fd070d4f2f..10490a2625 100644 --- a/phpgwapi/inc/class.contacts_ldap.inc.php +++ b/phpgwapi/inc/class.contacts_ldap.inc.php @@ -308,7 +308,7 @@ } /* send this the range, query, sort, order and whatever fields you want to see */ - function read($start=0,$limit=0,$fields='',$query='',$filter='',$sort='',$order='') + function read($start=0,$limit=0,$fields='',$query='',$filter='',$sort='',$order='',$cquery='') { if(!$start) { @@ -406,7 +406,16 @@ $ldap_fields = array(); $myfilter = ''; - if($query) + if($cquery) + { + $cfields = array( + 'fn' => 'cn', + 'n_family' => 'sn', + 'org_name' => 'o' + ); + $myfilter = $this->makefilter($filterfields,$cfields,$cquery,$DEBUG,True); + } + elseif($query) { reset($this->stock_contact_fields); $myfilter = $this->makefilter($filterfields,$this->stock_contact_fields,$query,$DEBUG); @@ -498,7 +507,7 @@ } /* Used by read() above to build the ldap filter string */ - function makefilter($qarray,$extra='',$query='', $DEBUG=False) + function makefilter($qarray,$extra='',$query='', $DEBUG=False,$first=False) { if(!is_array($qarray)) { @@ -547,7 +556,14 @@ } else { - $oquery .= '(' . $x . '=*' . $y . '*)'; + if($first) + { + $oquery .= '(' . $x . '=' . $y . '*)'; + } + else + { + $oquery .= '(' . $x . '=*' . $y . '*)'; + } $hasor = True; } } diff --git a/phpgwapi/inc/class.contacts_sql.inc.php b/phpgwapi/inc/class.contacts_sql.inc.php index 97935d4e68..bfa61de714 100644 --- a/phpgwapi/inc/class.contacts_sql.inc.php +++ b/phpgwapi/inc/class.contacts_sql.inc.php @@ -301,7 +301,7 @@ } /* send this the range, query, sort, order and whatever fields you want to see */ - function read($start=0,$limit=0,$fields='',$query='',$filter='',$sort='',$order='') + function read($start=0,$limit=0,$fields='',$query='',$filter='',$sort='',$order='',$cquery='') { if(!$start) { $start = 0; } if(!$limit) { $limit = 0; } @@ -482,7 +482,21 @@ $filtermethod = ''; - if($query) + if($cquery) + { + $cfields = array( + 'fn' => 'cn', + 'n_family' => 'sn', + 'org_name' => 'o' + ); + while(list($f,$x) = each($cfields)) + { + $sql .= " $f LIKE '$cquery%' OR "; + } + $sql = substr($sql,0,-3) . ') ' . $fand . $filtermethod . $ordermethod; + unset($f); unset($x); + } + elseif($query) { $query = ereg_replace("'",'',$query); $query = ereg_replace('"','',$query);