From ee12df16a490bc429b996e7dfeac9170cdf08d59 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Mon, 10 Mar 2008 21:28:15 +0000 Subject: [PATCH] Merged revisions 50805 via svnmerge from svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.2.2 ........ r50805 | ischommer | 2008-03-11 10:23:53 +1300 (Tue, 11 Mar 2008) | 2 lines added $searchable_fields in preparation for a more generic search implementation, currently limited to Member.php and MemberTableField.php (mainly to fix bugs caused by r49774 and r47856) fixed weird indentation formatting in Member.php ........ git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@50801 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/MemberTableField.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/code/MemberTableField.php b/code/MemberTableField.php index fd57f941..bc9ace41 100755 --- a/code/MemberTableField.php +++ b/code/MemberTableField.php @@ -96,8 +96,6 @@ class MemberTableField extends ComplexTableField { $fieldList["SetPassword"] = "Password"; } -// $detailFormFields = singleton(Object::getCustomClass($this->stat("data_class")))->getCMSFields(); - if(isset($_REQUEST['ctf']['childID']) && $memberID = $_REQUEST['ctf']['childID']) { $SNG_member = DataObject::get_by_id($this->stat("data_class"),$_REQUEST['ctf']['childID']); } else { @@ -125,13 +123,13 @@ class MemberTableField extends ComplexTableField { } // search - $search = isset($_REQUEST['MemberSearch']) ? Convert::raw2sql($_REQUEST['MemberSearch']) : null; + $SQL_search = isset($_REQUEST['MemberSearch']) ? Convert::raw2sql($_REQUEST['MemberSearch']) : null; if(!empty($_REQUEST['MemberSearch'])) { - //$this->sourceFilter[] = "( `Email` LIKE '%$search%' OR `FirstName` LIKE '%$search%' OR `Surname` LIKE '%$search%' )"; - $sourceF = '( '; - foreach( $fieldList as $k => $v ) - $sourceF .= '`$k` LIKE '%$search%' OR '; - $this->sourceFilter[] = substr( $sourceF, 0, -3 ) . ')'; + $searchFilters = array(); + foreach($SNG_member->stat('searchable_fields') as $fieldName => $fieldSpec) { + $searchFilters[] = "`$fieldName` LIKE '%{$SQL_search}%'"; + } + $this->sourceFilter[] = '(' . implode(' OR ', $searchFilters) . ')'; } // filter by groups