mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-23 07:09:20 +01:00
"allow a negative filter (eg. '!xyz'), NULL or array with possible values as custom field filter"
This commit is contained in:
parent
2a4e1a95cb
commit
b400e8d880
@ -467,9 +467,20 @@ class so_sql_cf extends so_sql
|
|||||||
{
|
{
|
||||||
if (!empty($val)) // empty -> dont filter
|
if (!empty($val)) // empty -> dont filter
|
||||||
{
|
{
|
||||||
$join .= str_replace('extra_filter','extra_filter'.$extra_filter,$this->extra_join_filter.
|
if ($val[0] === '!') // negative filter
|
||||||
|
{
|
||||||
|
$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
|
||||||
|
{
|
||||||
|
$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.
|
||||||
' AND extra_filter.'.$this->extra_key.'='.$this->db->quote($this->get_cf_name($name)).
|
' AND extra_filter.'.$this->extra_key.'='.$this->db->quote($this->get_cf_name($name)).
|
||||||
' AND extra_filter.'.$this->extra_value.'='.$this->db->quote($val));
|
' AND '.$sql_filter);
|
||||||
++$extra_filter;
|
++$extra_filter;
|
||||||
}
|
}
|
||||||
unset($filter[$name]);
|
unset($filter[$name]);
|
||||||
|
Loading…
Reference in New Issue
Block a user