Support rcube_addressbook::SEARCH_* constants in search mode

This commit is contained in:
Aleksander Machniak 2016-08-08 07:43:43 -04:00
parent 03cfe38a98
commit 0b59c065ad

View file

@ -417,6 +417,7 @@ class rcube_kolab_contacts extends rcube_addressbook
* 0 - partial (*abc*),
* 1 - strict (=),
* 2 - prefix (abc*)
* 4 - include groups (if supported)
* @param boolean $select True if results are requested, False if count only
* @param boolean $nocount True to skip the count query (select only)
* @param array $required List of fields that cannot be empty
@ -468,6 +469,8 @@ class rcube_kolab_contacts extends rcube_addressbook
$squery[] = array('tags', '=', 'x-has-birthday');
}
$squery[] = array('type', '=', 'contact');
// get all/matching records
$this->_fetch_contacts($squery);
@ -1177,10 +1180,14 @@ class rcube_kolab_contacts extends rcube_addressbook
}
if (count($cols) == count($fields)) {
switch ($mode) {
case 1: $prefix = '^'; $suffix = '$'; break; // strict
case 2: $prefix = '^'; $suffix = ''; break; // prefix
default: $prefix = ''; $suffix = ''; break; // substring
if ($mode & rcube_addressbook::SEARCH_STRICT) {
$prefix = '^'; $suffix = '$';
}
else if ($mode & rcube_addressbook::SEARCH_PREFIX) {
$prefix = '^'; $suffix = '';
}
else {
$prefix = ''; $suffix = '';
}
$search_string = is_array($value) ? join(' ', $value) : $value;