Improve search for users with a word-based query (#4558)
Attention! This requires the following change in Roundcube core: https://github.com/roundcube/roundcubemail/commit/83eeec6c
This commit is contained in:
parent
03dd4b60b3
commit
ae2bd00732
1 changed files with 8 additions and 28 deletions
|
@ -210,7 +210,7 @@ class kolab_auth_ldap extends rcube_ldap_generic
|
||||||
/**
|
/**
|
||||||
* Search records (simplified version of rcube_ldap::search)
|
* Search records (simplified version of rcube_ldap::search)
|
||||||
*
|
*
|
||||||
* @param mixed $fields The field name or array of field names to search in
|
* @param string $fields The field name or array of field names to search in
|
||||||
* @param mixed $value Search value (or array of values when $fields is array)
|
* @param mixed $value Search value (or array of values when $fields is array)
|
||||||
* @param int $mode Matching mode:
|
* @param int $mode Matching mode:
|
||||||
* 0 - partial (*abc*),
|
* 0 - partial (*abc*),
|
||||||
|
@ -230,35 +230,15 @@ class kolab_auth_ldap extends rcube_ldap_generic
|
||||||
|
|
||||||
$mode = intval($mode);
|
$mode = intval($mode);
|
||||||
|
|
||||||
// use AND operator for advanced searches
|
// compose a full-text-search-like filter
|
||||||
$filter = is_array($value) ? '(&' : '(|';
|
if (is_array($fields) && (count($fields) > 1 || $mode != 1)) {
|
||||||
|
$filter = self::fulltext_search_filter($value, $fields, $mode);
|
||||||
// set wildcards
|
|
||||||
$wp = $ws = '';
|
|
||||||
if (!empty($this->config['fuzzy_search']) && $mode != 1) {
|
|
||||||
$ws = '*';
|
|
||||||
if (!$mode) {
|
|
||||||
$wp = '*';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// direct search
|
||||||
foreach ((array)$fields as $idx => $field) {
|
else {
|
||||||
$val = is_array($value) ? $value[$idx] : $value;
|
$field = is_array($fields) ? $fields[0] : strval($fields);
|
||||||
$attrs = (array) $this->fieldmap[$field];
|
$filter = "($field=" . self::quote_string($value) . ")";
|
||||||
|
|
||||||
if (empty($attrs)) {
|
|
||||||
$filter .= "($field=$wp" . rcube_ldap_generic::quote_string($val) . "$ws)";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (count($attrs) > 1)
|
|
||||||
$filter .= '(|';
|
|
||||||
foreach ($attrs as $f)
|
|
||||||
$filter .= "($f=$wp" . rcube_ldap_generic::quote_string($val) . "$ws)";
|
|
||||||
if (count($attrs) > 1)
|
|
||||||
$filter .= ')';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$filter .= ')';
|
|
||||||
|
|
||||||
// add required (non empty) fields filter
|
// add required (non empty) fields filter
|
||||||
$req_filter = '';
|
$req_filter = '';
|
||||||
|
|
Loading…
Add table
Reference in a new issue