Merge pull request #1515 from pdelbar/fixgencode
[civicrm-core.git] / CRM / Pledge / BAO / Query.php
index 51dd3756b7ebceb497bc696633abbd5919fe1228..57fb1a1ae5b1bfd4d41353b994bd813fb4dd3861 100644 (file)
@@ -2,7 +2,7 @@
 
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.4                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2013                                |
  +--------------------------------------------------------------------+
@@ -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':