Backport r29733 - Multi select filter matches any record with that value selected

This commit is contained in:
Nathan Gray 2010-04-08 23:11:35 +00:00
parent da872fae0c
commit 69938436a9

View File

@ -478,10 +478,24 @@ class so_sql_cf extends so_sql
$sql_filter = 'extra_filter.'.$this->extra_value.'!='.$this->db->quote(substr($val,1));
}
else // using egw_db::expression to allow to use array() with possible values or NULL
{
if($this->customfields[$this->get_cf_name($name)]['type'] == 'select' &&
$this->customfields[$this->get_cf_name($name)]['rows'] > 1)
{
// Multi-select - any entry with the filter value selected matches
$sql_filter = str_replace($this->extra_value,'extra_filter.'.
$this->extra_value,$this->db->expression($this->extra_table,array(
"CONCAT(',',{$this->extra_value},',') LIKE '%,$val,%'"
))
);
}
else
{
$sql_filter = str_replace($this->extra_value,'extra_filter.'.
$this->extra_value,$this->db->expression($this->extra_table,array($this->extra_value => $val)));
}
}
// need to use a LEFT JOIN for negative search or to allow NULL values
$need_left_join = $val[0] === '!' || strpos($sql_filter,'IS NULL') !== false ? ' LEFT ' : '';
$join .= str_replace('extra_filter','extra_filter'.$extra_filter,$need_left_join.$this->extra_join_filter.