- Fix autocomplete shows entries without email (#1486452)

release-0.6
alecpl 14 years ago
parent 5933d98c8c
commit 25fdec592d

@ -1,6 +1,7 @@
CHANGELOG RoundCube Webmail
===========================
- Fix autocomplete shows entries without email (#1486452)
- Fix listupdate event doesn't trigger on search response (#1486708)
- Fix select_all_mode value after selecting a message (#1486720)
- Set focus to editor on reply in HTML mode (#1486632)

@ -215,28 +215,42 @@ class rcube_contacts extends rcube_addressbook
* @param boolean True for strict (=), False for partial (LIKE) matching
* @param boolean True if results are requested, False if count only
* @param boolean True to skip the count query (select only)
* @param array List of fields that cannot be empty
* @return Indexed list of contact records and 'count' value
*/
function search($fields, $value, $strict=false, $select=true, $nocount=false)
function search($fields, $value, $strict=false, $select=true, $nocount=false, $required=array())
{
if (!is_array($fields))
$fields = array($fields);
if (!is_array($required) && !empty($required))
$required = array($required);
$where = $and_where = array();
$add_where = array();
foreach ($fields as $col) {
if ($col == 'ID' || $col == $this->primary_key) {
$ids = !is_array($value) ? explode(',', $value) : $value;
$ids = $this->db->array2list($ids, 'integer');
$add_where[] = 'c.' . $this->primary_key.' IN ('.$ids.')';
$where[] = 'c.' . $this->primary_key.' IN ('.$ids.')';
}
else if ($strict)
$add_where[] = $this->db->quoteIdentifier($col).'='.$this->db->quote($value);
$where[] = $this->db->quoteIdentifier($col).' = '.$this->db->quote($value);
else
$add_where[] = $this->db->ilike($col, '%'.$value.'%');
$where[] = $this->db->ilike($col, '%'.$value.'%');
}
foreach ($required as $col) {
$and_where[] = $this->db->quoteIdentifier($col).' <> '.$this->db->quote('');
}
if (!empty($add_where)) {
$this->set_search_set(join(' OR ', $add_where));
if (!empty($where))
$where = join(' OR ', $where);
if (!empty($and_where))
$where = ($where ? "($where) AND " : '') . join(' AND ', $and_where);
if (!empty($where)) {
$this->set_search_set($where);
if ($select)
$this->list_records(null, 0, $nocount);
else

@ -306,9 +306,11 @@ class rcube_ldap extends rcube_addressbook
* @param string Search value
* @param boolean True for strict, False for partial (fuzzy) matching
* @param boolean True if results are requested, False if count only
* @param boolean (Not used)
* @param array List of fields that cannot be empty
* @return array Indexed list of contact records and 'count' value
*/
function search($fields, $value, $strict=false, $select=true)
function search($fields, $value, $strict=false, $select=true, $nocount=false, $required=array())
{
// special treatment for ID-based search
if ($fields == 'ID' || $fields == $this->primary_key)
@ -340,6 +342,15 @@ class rcube_ldap extends rcube_addressbook
}
$filter .= ')';
// add required (non empty) fields filter
$req_filter = '';
foreach ((array)$required as $field)
if ($f = $this->_map_field($field))
$req_filter .= "($f=*)";
if (!empty($req_filter))
$filter = '(&' . $req_filter . $filter . ')';
// avoid double-wildcard if $value is empty
$filter = preg_replace('/\*+/', '*', $filter);

@ -42,7 +42,7 @@ else if ($book_types && $search = get_input_value('_search', RCUBE_INPUT_GPC, tr
$abook = $RCMAIL->get_address_book($id);
$abook->set_pagesize($MAXNUM);
if ($result = $abook->search(array('email','name'), $search, false, true, true)) {
if ($result = $abook->search(array('email','name'), $search, false, true, true, 'email')) {
while ($sql_arr = $result->iterate()) {
$contacts[] = format_email_recipient($sql_arr['email'], $sql_arr['name']);
if (count($contacts) >= $MAXNUM)

Loading…
Cancel
Save