From cacaff872dbfcc7cd47b520b708a38b96a6f8ea3 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 7 Apr 2010 15:52:59 +0000 Subject: [PATCH] Fix filtering on a multi-select custom field. Any entry with the filter value will be included. --- infolog/inc/class.infolog_so.inc.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/infolog/inc/class.infolog_so.inc.php b/infolog/inc/class.infolog_so.inc.php index 223e9f3a34..2e00fe8815 100644 --- a/infolog/inc/class.infolog_so.inc.php +++ b/infolog/inc/class.infolog_so.inc.php @@ -760,11 +760,24 @@ class infolog_so } if ($col[0] == '#' && $query['custom_fields'] && $data) { - $filtermethod .= " AND main.info_id IN (SELECT DISTINCT info_id FROM $this->extra_table WHERE ". - $this->db->expression($this->extra_table,array( + $filtermethod .= " AND main.info_id IN (SELECT DISTINCT info_id FROM $this->extra_table WHERE "; + $custom_fields = config::get_customfields('infolog'); + + if($custom_fields[substr($col,1)]['type'] == 'select' && $custom_fields[substr($col,1)]['rows'] > 1) + { + // Multi-select - any entry with the filter value selected matches + $filtermethod .= $this->db->expression($this->extra_table, array( + 'info_extra_name' => substr($col,1), + "CONCAT(',',info_extra_value,',') LIKE '%,$data,%'" + )).')'; + } + else + { + $filtermethod .= $this->db->expression($this->extra_table,array( 'info_extra_name' => substr($col,1), 'info_extra_value' => $data, )).')'; + } $cfcolfilter++; } }