From 69938436a97d463f2c8e8f26796900bfe09c792a Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Thu, 8 Apr 2010 23:11:35 +0000 Subject: [PATCH] Backport r29733 - Multi select filter matches any record with that value selected --- etemplate/inc/class.so_sql_cf.inc.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/etemplate/inc/class.so_sql_cf.inc.php b/etemplate/inc/class.so_sql_cf.inc.php index b6626c5a5a..5d78a1337f 100644 --- a/etemplate/inc/class.so_sql_cf.inc.php +++ b/etemplate/inc/class.so_sql_cf.inc.php @@ -479,8 +479,22 @@ class so_sql_cf extends so_sql } 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))); + 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 ' : '';