fix advanced search for customfields (multiple field criteria, combined by AND) in addressbook

This commit is contained in:
Klaus Leithoff 2010-07-07 11:38:52 +00:00
parent 89ed32a022
commit 07930ecd58

View File

@ -457,21 +457,31 @@ class so_sql_cf extends so_sql
unset($criteria[$name]);
}
elseif (is_string($name) && $this->is_cf($name))
{
if ($op != 'AND')
{
$name = substr($name, 1);
if (($negate = $criteria[$name][0] === '!'))
{
$val = substr($val,1);
}
$criteria[] = '(' . $this->extra_table.'.'.$this->extra_value . ' ' .($negate ? 'NOT ' : '').
$cfcriteria[] = '(' . $this->extra_table.'.'.$this->extra_value . ' ' .($negate ? 'NOT ' : '').
$this->db->capabilities[egw_db::CAPABILITY_CASE_INSENSITIV_LIKE]. ' ' .
$this->db->quote($wildcard.$val.$wildcard) . ' AND ' .
$this->extra_table.'.'.$this->extra_key . ' = ' . $this->db->quote($name) .
')';
unset($criteria[self::CF_PREFIX.$name]);
}
else
{
// criteria operator is AND we remap the criteria to be transformed to filters
$filter[$name] = $val;
unset($criteria[$name]);
}
}
}
if ($cfcriteria && $op =='OR') $criteria[] = implode(' OR ',$cfcriteria);
}
if($only_keys === true) {
// Expand to keys here, so table_name can be prepended below
$only_keys = array_values($this->db_key_cols);