Improve contacts search by matching words against contact properties instead of the entire search string
This commit is contained in:
parent
ae2bd00732
commit
ac96c929dd
1 changed files with 10 additions and 10 deletions
|
@ -467,27 +467,27 @@ class rcube_kolab_contacts extends rcube_addressbook
|
||||||
}
|
}
|
||||||
|
|
||||||
$found = array();
|
$found = array();
|
||||||
|
$contents = '';
|
||||||
foreach (preg_grep($regexp, array_keys($contact)) as $col) {
|
foreach (preg_grep($regexp, array_keys($contact)) as $col) {
|
||||||
$pos = strpos($col, ':');
|
$pos = strpos($col, ':');
|
||||||
$colname = $pos ? substr($col, 0, $pos) : $col;
|
$colname = $pos ? substr($col, 0, $pos) : $col;
|
||||||
$search = $advanced ? $value[array_search($colname, $fields)] : $value;
|
|
||||||
|
|
||||||
foreach ((array)$contact[$col] as $val) {
|
foreach ((array)$contact[$col] as $val) {
|
||||||
if ($this->compare_search_value($colname, $val, $search, $mode)) {
|
if ($advanced) {
|
||||||
if (!$advanced) {
|
$found[$colname] = $this->compare_search_value($colname, $val, $value[array_search($colname, $fields)], $mode);
|
||||||
$this->filter['ids'][] = $id;
|
|
||||||
break 2;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$found[$colname] = true;
|
$contents .= ' ' . join(' ', (array)$val);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($found) >= $scount) // && $advanced
|
// compare matches
|
||||||
|
if (($advanced && count($found) >= $scount) ||
|
||||||
|
(!$advanced && rcube_utils::words_match(mb_strtolower($contents), $value))) {
|
||||||
$this->filter['ids'][] = $id;
|
$this->filter['ids'][] = $id;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// dummy result with contacts count
|
// dummy result with contacts count
|
||||||
if (!$select) {
|
if (!$select) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue