From 884fdc636fdec1f6e15763cd0f48f60753daa5c8 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Wed, 25 Feb 2015 18:52:36 +0530 Subject: [PATCH] QA fixes --- CRM/Contact/BAO/Query.php | 2 +- CRM/Contact/Form/Search/Advanced.php | 2 -- CRM/Event/BAO/Query.php | 7 +++++-- CRM/Event/Form/Search.php | 23 +++++++++++++---------- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 5b3740658d..1cd5f00faf 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -5669,7 +5669,7 @@ AND displayRelType.is_active = 1 } elseif (is_array($fieldValue)) { $qillString = array(); - if (in_array(key($fieldValue), CRM_Core_DAO::acceptedSQLOperators())) { + if (in_array(key($fieldValue), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) { $op = key($fieldValue); $fieldValue = $fieldValue[$op]; } diff --git a/CRM/Contact/Form/Search/Advanced.php b/CRM/Contact/Form/Search/Advanced.php index 09ce18cbf4..df59f52f99 100644 --- a/CRM/Contact/Form/Search/Advanced.php +++ b/CRM/Contact/Form/Search/Advanced.php @@ -372,8 +372,6 @@ class CRM_Contact_Form_Search_Advanced extends CRM_Contact_Form_Search { 'activity_type_id', 'status_id', 'activity_subject', - 'participant_status_id', - 'participant_role_id', ); foreach ($specialParams as $element) { $value = CRM_Utils_Array::value($element, $this->_formValues); diff --git a/CRM/Event/BAO/Query.php b/CRM/Event/BAO/Query.php index 41b291528d..a71b9d0d22 100644 --- a/CRM/Event/BAO/Query.php +++ b/CRM/Event/BAO/Query.php @@ -333,10 +333,13 @@ class CRM_Event_BAO_Query { ); return; - case 'participant_status': case 'participant_status_id': - case 'participant_role': case 'participant_role_id': + if ($value && is_array($value) && strpos($op , 'IN') === FALSE) { + $op = 'IN'; + } + case 'participant_status': + case 'participant_role': case 'participant_source': case 'participant_id': case 'participant_contact_id': diff --git a/CRM/Event/Form/Search.php b/CRM/Event/Form/Search.php index cd99eb484a..9c77329ff6 100644 --- a/CRM/Event/Form/Search.php +++ b/CRM/Event/Form/Search.php @@ -193,16 +193,26 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { if (count($eventIds) == 1) { //convert form values to clause. $seatClause = array(); + if (CRM_Utils_Array::value('participant_test', $this->_formValues) == '1' || CRM_Utils_Array::value('participant_test', $this->_formValues) == '0') { + $seatClause[] = "( participant.is_test = {$this->_formValues['participant_test']} )"; + } + if (!empty($this->_formValues['participant_status_id'])) { + $seatClause[] = '( participant.status_id IN ( ' . implode(' , ', $this->_formValues['participant_status_id']) . ' ) )'; + } + if (!empty($this->_formValues['participant_role_id'])) { + $seatClause[] = '( participant.role_id IN ( ' . implode(' , ', $this->_formValues['participant_role_id']) . ' ) )'; + } + // CRM-15379 - $clause = NULL; if (!empty($this->_formValues['participant_fee_id'])) { $participant_fee_id = $this->_formValues['participant_fee_id']; $feeLabel = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $participant_fee_id, 'label'); $feeLabel = CRM_Core_DAO::escapeString(trim($feeLabel)); - $clause = " ( participant.fee_level LIKE '%$feeLabel%' ) "; + $seatClause[] = "( participant.fee_level LIKE '%$feeLabel%' )"; } - $participantCount = CRM_Event_BAO_Event::eventTotalSeats(array_pop($eventIds), $clause); + $seatClause = implode(' AND ', $seatClause); + $participantCount = CRM_Event_BAO_Event::eventTotalSeats(array_pop($eventIds), $seatClause); } $this->assign('participantCount', $participantCount); $this->assign('lineItems', $lineItems); @@ -402,13 +412,6 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { $this->_formValues['participant_role_id'] = $roleTypes; } - foreach (array('participant_status_id', 'participant_role_id') as $element) { - $value = CRM_Utils_Array::value($element, $this->_formValues); - if ($value && is_array($value)) { - $this->_formValues[$element] = array('IN' => $value); - } - } - $type = CRM_Utils_Request::retrieve('type', 'Positive', CRM_Core_DAO::$_nullObject ); -- 2.25.1