Simplified code

pull/5298/head
Aleksander Machniak 9 years ago
parent 7864a98f08
commit f466899d8d

@ -237,7 +237,7 @@ class rcube_contacts extends rcube_addressbook
" WHERE c.`del` <> 1" . " WHERE c.`del` <> 1" .
" AND c.`user_id` = ?" . " AND c.`user_id` = ?" .
($this->group_id ? " AND m.`contactgroup_id` = ?" : ""). ($this->group_id ? " AND m.`contactgroup_id` = ?" : "").
($this->filter ? " AND (".$this->filter.")" : "") . ($this->filter ? " AND ".$this->filter : "") .
" ORDER BY ". $this->db->concat($order_cols) . " ORDER BY ". $this->db->concat($order_cols) .
" " . $this->sort_order, " " . $this->sort_order,
$start_row, $start_row,
@ -314,25 +314,13 @@ class rcube_contacts extends rcube_addressbook
foreach ((array)$fields as $idx => $col) { foreach ((array)$fields as $idx => $col) {
$val = $value[$idx]; $val = $value[$idx];
if (!strlen($val)) if (!strlen($val)) {
continue; continue;
}
// table column // table column
if (in_array($col, $this->table_cols)) { if (in_array($col, $this->table_cols)) {
switch ($mode) { $where[] = $this->fulltext_sql_where($val, $mode, $col);
case 1: // strict
$where[] = '(' . $this->db->quote_identifier($col) . ' = ' . $this->db->quote($val)
. ' OR ' . $this->db->ilike($col, $val . $AS . '%')
. ' OR ' . $this->db->ilike($col, '%' . $AS . $val . $AS . '%')
. ' OR ' . $this->db->ilike($col, '%' . $AS . $val) . ')';
break;
case 2: // prefix
$where[] = '(' . $this->db->ilike($col, $val . '%')
. ' OR ' . $this->db->ilike($col, $AS . $val . '%') . ')';
break;
default: // partial
$where[] = $this->db->ilike($col, '%' . $val . '%');
}
} }
// vCard field // vCard field
else { else {
@ -360,7 +348,7 @@ class rcube_contacts extends rcube_addressbook
} }
foreach (array_intersect($required, $this->table_cols) as $col) { foreach (array_intersect($required, $this->table_cols) as $col) {
$and_where[] = $this->db->quote_identifier($col).' <> '.$this->db->quote(''); $where[] = $this->db->quote_identifier($col).' <> '.$this->db->quote('');
} }
$required = array_diff($required, $this->table_cols); $required = array_diff($required, $this->table_cols);
@ -369,9 +357,6 @@ class rcube_contacts extends rcube_addressbook
$where = join(" AND ", $where); $where = join(" AND ", $where);
} }
if (!empty($and_where))
$where = ($where ? "($where) AND " : '') . join(' AND ', $and_where);
// Post-searching in vCard data fields // Post-searching in vCard data fields
// we will search in all records and then build a where clause for their IDs // we will search in all records and then build a where clause for their IDs
if (!empty($post_search) || !empty($required)) { if (!empty($post_search) || !empty($required)) {

Loading…
Cancel
Save