Fix the same thing in 4 other places CRM-12610
authorColeman Watts <coleman@civicrm.org>
Thu, 23 May 2013 03:10:11 +0000 (22:10 -0500)
committerColeman Watts <coleman@civicrm.org>
Thu, 23 May 2013 03:10:11 +0000 (22:10 -0500)
CRM/Activity/BAO/Query.php
CRM/Activity/Form/Search.php
CRM/Event/BAO/Query.php
CRM/Event/Form/Search.php
CRM/Member/BAO/Query.php
CRM/Member/Form/Search.php
CRM/Pledge/BAO/Query.php
CRM/Pledge/Form/Search.php

index 6ce9ff846454658ba9fd62aabd77f9b9eff1751e..9339d1f126b8bbf9a5f0cf940fe0f038916cf472 100644 (file)
@@ -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;
 
index ef29b02505d6eb85945ee2dc761eb09617b3ba7c..da7e5efe902e374d3278fdc4e2b1194708c11754 100644 (file)
@@ -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;
     }
index ed6edf9e2fc3905f88dbf603e4fec31ac48b28de..d2cdc3f9b910c90b09164b9c168c6029e56a3774 100644 (file)
@@ -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':
index 3a66de255b5ad3a6fd36cecf53d0ccb6b1d55248..739635e74f289f16d6216c1f9f4c07f21cc81b9d 100644 (file)
@@ -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;
     }
 
index 84943ae6ee6bdbb4775c04c9cdae15844f78b5e2..1cf550668b3ec785db65f61ec8e4532e8fbd0310 100644 (file)
@@ -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;
 
index 1adba6ca1935e2de1d031ef5c723f131bd9a86a6..19f277cbed5c695ace2b51f55c09f4b0771d2e55 100644 (file)
@@ -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;
     }
 
index 6dc0daa49e0b998ec8afa301e99ec448973a618a..ace7bab8bf3e4fcd27a54c1be98e4f26c8e3d033 100644 (file)
@@ -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':
index eb82310f552a0909a03912d604916be70fbabe84..a4d350db6ffb0ef6c65a9493828432f349bc38bd 100644 (file)
@@ -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;
     }