From 28c666be422cdc2af9af17482070081be1cae2ec Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 22 May 2013 22:10:11 -0500 Subject: [PATCH] Fix the same thing in 4 other places CRM-12610 --- CRM/Activity/BAO/Query.php | 22 +++++++--------------- CRM/Activity/Form/Search.php | 4 +++- CRM/Event/BAO/Query.php | 32 ++++++++++++-------------------- CRM/Event/Form/Search.php | 5 +---- CRM/Member/BAO/Query.php | 22 +++++++--------------- CRM/Member/Form/Search.php | 5 +---- CRM/Pledge/BAO/Query.php | 32 ++++++++++++-------------------- CRM/Pledge/Form/Search.php | 7 ++----- 8 files changed, 45 insertions(+), 84 deletions(-) diff --git a/CRM/Activity/BAO/Query.php b/CRM/Activity/BAO/Query.php index 6ce9ff8464..9339d1f126 100644 --- a/CRM/Activity/BAO/Query.php +++ b/CRM/Activity/BAO/Query.php @@ -153,27 +153,16 @@ class CRM_Activity_BAO_Query { * @access public */ static function where(&$query) { - $grouping = $testCondition = NULL; + $grouping = NULL; foreach (array_keys($query->_params) as $id) { if (substr($query->_params[$id][0], 0, 9) == 'activity_') { if ($query->_mode == CRM_Contact_BAO_QUERY::MODE_CONTACTS) { $query->_useDistinct = TRUE; } - if ($query->_params[$id][0] == 'activity_test') { - $testCondition = $id; - continue; - } $grouping = $query->_params[$id][3]; self::whereClauseSingle($query->_params[$id], $query); } } - // Only add test condition if other fields are selected - if ($grouping !== NULL && $testCondition && - // we dont want to include all tests for sql OR CRM-7827 - $query->getOperator() != 'OR' - ) { - self::whereClauseSingle($query->_params[$testCondition], $query); - } } /** @@ -306,9 +295,12 @@ class CRM_Activity_BAO_Query { break; case 'activity_test': - $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_activity.is_test", $op, $value, "Boolean"); - if ($value) { - $query->_qill[$grouping][] = ts('Activity is a Test'); + // We dont want to include all tests for sql OR CRM-7827 + if (!$value || $query->getOperator() != 'OR') { + $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_activity.is_test", $op, $value, "Boolean"); + if ($value) { + $query->_qill[$grouping][] = ts('Activity is a Test'); + } } break; diff --git a/CRM/Activity/Form/Search.php b/CRM/Activity/Form/Search.php index ef29b02505..da7e5efe90 100644 --- a/CRM/Activity/Form/Search.php +++ b/CRM/Activity/Form/Search.php @@ -327,9 +327,11 @@ class CRM_Activity_Form_Search extends CRM_Core_Form { $this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID); } - if (!CRM_Utils_Array::value('activity_test', $this->_formValues)) { + // we don't show test activities in Contact Summary / User Dashboard + if (empty($this->_formValues['activity_test']) && $this->_single) { $this->_formValues["activity_test"] = 0; } + if (!CRM_Utils_Array::value('activity_contact_name', $this->_formValues) && !CRM_Utils_Array::value('contact_id', $this->_formValues)) { $this->_formValues['activity_role'] = NULL; } diff --git a/CRM/Event/BAO/Query.php b/CRM/Event/BAO/Query.php index ed6edf9e2f..d2cdc3f9b9 100644 --- a/CRM/Event/BAO/Query.php +++ b/CRM/Event/BAO/Query.php @@ -207,7 +207,7 @@ class CRM_Event_BAO_Query { } static function where(&$query) { - $testCondition = $grouping = NULL; + $grouping = NULL; foreach (array_keys($query->_params) as $id) { if (!CRM_Utils_Array::value(0, $query->_params[$id])) { continue; @@ -218,21 +218,10 @@ class CRM_Event_BAO_Query { if ($query->_mode == CRM_Contact_BAO_QUERY::MODE_CONTACTS) { $query->_useDistinct = TRUE; } - if ($query->_params[$id][0] == 'participant_test') { - $testCondition = $id; - continue; - } $grouping = $query->_params[$id][3]; self::whereClauseSingle($query->_params[$id], $query); } } - // Only add test condition if other fields are selected - if ($grouping !== NULL && $testCondition && - // we dont want to include all tests for sql OR CRM-7827 - $query->getOperator() != 'OR' - ) { - self::whereClauseSingle($query->_params[$testCondition], $query); - } } static function whereClauseSingle(&$values, &$query) { @@ -268,15 +257,18 @@ class CRM_Event_BAO_Query { return; case 'participant_test': - $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_participant.is_test", - $op, - $value, - "Boolean" - ); - if ($value) { - $query->_qill[$grouping][] = ts("Participant is a Test"); + // We dont want to include all tests for sql OR CRM-7827 + if (!$value || $query->getOperator() != 'OR') { + $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_participant.is_test", + $op, + $value, + "Boolean" + ); + if ($value) { + $query->_qill[$grouping][] = ts("Participant is a Test"); + } + $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1; } - $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1; return; case 'participant_fee_id': diff --git a/CRM/Event/Form/Search.php b/CRM/Event/Form/Search.php index 3a66de255b..739635e74f 100644 --- a/CRM/Event/Form/Search.php +++ b/CRM/Event/Form/Search.php @@ -383,10 +383,7 @@ class CRM_Event_Form_Search extends CRM_Core_Form { } // we don't show test registrations in Contact Summary / User Dashboard - // in Search mode by default we hide test registrations - if (!CRM_Utils_Array::value('participant_test', - $this->_formValues - )) { + if (empty($this->_formValues['participant_test']) && $this->_single) { $this->_formValues["participant_test"] = 0; } diff --git a/CRM/Member/BAO/Query.php b/CRM/Member/BAO/Query.php index 84943ae6ee..1cf550668b 100644 --- a/CRM/Member/BAO/Query.php +++ b/CRM/Member/BAO/Query.php @@ -127,7 +127,7 @@ class CRM_Member_BAO_Query { } static function where(&$query) { - $grouping = $testCondition = NULL; + $grouping = NULL; foreach (array_keys($query->_params) as $id) { if (!CRM_Utils_Array::value(0, $query->_params[$id])) { continue; @@ -136,21 +136,10 @@ class CRM_Member_BAO_Query { if ($query->_mode == CRM_Contact_BAO_QUERY::MODE_CONTACTS) { $query->_useDistinct = TRUE; } - if ($query->_params[$id][0] == 'member_test') { - $testCondition = $id; - continue; - } $grouping = $query->_params[$id][3]; self::whereClauseSingle($query->_params[$id], $query); } } - // Only add test condition if other fields are selected - if ($grouping !== NULL && $testCondition && - // we dont want to include all tests for sql OR CRM-7827 - $query->getOperator() != 'OR' - ) { - self::whereClauseSingle($query->_params[$testCondition], $query); - } } static function whereClauseSingle(&$values, &$query) { @@ -224,9 +213,12 @@ class CRM_Member_BAO_Query { return; case 'member_test': - $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_membership.is_test", $op, $value, "Boolean"); - if ($value) { - $query->_qill[$grouping][] = ts('Membership is a Test'); + // We dont want to include all tests for sql OR CRM-7827 + if (!$value || $query->getOperator() != 'OR') { + $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_membership.is_test", $op, $value, "Boolean"); + if ($value) { + $query->_qill[$grouping][] = ts('Membership is a Test'); + } } return; diff --git a/CRM/Member/Form/Search.php b/CRM/Member/Form/Search.php index 1adba6ca19..19f277cbed 100644 --- a/CRM/Member/Form/Search.php +++ b/CRM/Member/Form/Search.php @@ -310,10 +310,7 @@ class CRM_Member_Form_Search extends CRM_Core_Form { $this->fixFormValues(); // we don't show test memberships in Contact Summary / User Dashboard - // in Search mode by default we hide test memberships - if (!CRM_Utils_Array::value('member_test', - $this->_formValues - )) { + if (empty($this->_formValues['member_test']) && $this->_single) { $this->_formValues["member_test"] = 0; } diff --git a/CRM/Pledge/BAO/Query.php b/CRM/Pledge/BAO/Query.php index 6dc0daa49e..ace7bab8bf 100644 --- a/CRM/Pledge/BAO/Query.php +++ b/CRM/Pledge/BAO/Query.php @@ -199,7 +199,7 @@ class CRM_Pledge_BAO_Query { } static function where(&$query) { - $testCondition = $grouping = NULL; + $grouping = NULL; foreach (array_keys($query->_params) as $id) { if (!CRM_Utils_Array::value(0, $query->_params[$id])) { continue; @@ -208,21 +208,10 @@ class CRM_Pledge_BAO_Query { if ($query->_mode == CRM_Contact_BAO_QUERY::MODE_CONTACTS) { $query->_useDistinct = TRUE; } - if ($query->_params[$id][0] == 'participant_test') { - $testCondition = $id; - continue; - } $grouping = $query->_params[$id][3]; self::whereClauseSingle($query->_params[$id], $query); } } - // Only add test condition if other fields are selected - if ($grouping !== NULL && $testCondition && - // we dont want to include all tests for sql OR CRM-7827 - $query->getOperator() != 'OR' - ) { - self::whereClauseSingle($query->_params[$testCondition], $query); - } } static function whereClauseSingle(&$values, &$query) { @@ -352,15 +341,18 @@ class CRM_Pledge_BAO_Query { case 'pledge_test': case 'pledge_is_test': - $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_pledge.is_test', - $op, - $value, - 'Boolean' - ); - if ($value) { - $query->_qill[$grouping][] = ts('Pledge is a Test'); + // We dont want to include all tests for sql OR CRM-7827 + if (!$value || $query->getOperator() != 'OR') { + $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_pledge.is_test', + $op, + $value, + 'Boolean' + ); + if ($value) { + $query->_qill[$grouping][] = ts('Pledge is a Test'); + } + $query->_tables['civicrm_pledge'] = $query->_whereTables['civicrm_pledge'] = 1; } - $query->_tables['civicrm_pledge'] = $query->_whereTables['civicrm_pledge'] = 1; return; case 'pledge_financial_type_id': diff --git a/CRM/Pledge/Form/Search.php b/CRM/Pledge/Form/Search.php index eb82310f55..a4d350db6f 100644 --- a/CRM/Pledge/Form/Search.php +++ b/CRM/Pledge/Form/Search.php @@ -308,11 +308,8 @@ class CRM_Pledge_Form_Search extends CRM_Core_Form { $this->fixFormValues(); - // we don't show test contributions in Contact Summary / User Dashboard - // in Search mode by default we hide test contributions - if (!CRM_Utils_Array::value('pledge_test', - $this->_formValues - )) { + // we don't show test pledges in Contact Summary / User Dashboard + if (empty($this->_formValues['pledge_test']) && $this->_single) { $this->_formValues["pledge_test"] = 0; } -- 2.25.1