Fix up SQL errors found by dave
authorSeamus Lee <seamuslee001@gmail.com>
Mon, 29 Jun 2015 22:05:47 +0000 (22:05 +0000)
committerSeamus Lee <seamuslee001@gmail.com>
Mon, 29 Jun 2015 22:05:47 +0000 (22:05 +0000)
CRM/Contact/Form/Search/Custom/ActivitySearch.php
CRM/Contact/Form/Search/Custom/Basic.php
CRM/Contact/Form/Search/Custom/ContribSYBNT.php
CRM/Contact/Form/Search/Custom/ContributionAggregate.php
CRM/Contact/Form/Search/Custom/DateAdded.php
CRM/Contact/Form/Search/Custom/MultipleValues.php
CRM/Contact/Form/Search/Custom/PriceSet.php
CRM/Contact/Form/Search/Custom/Proximity.php
CRM/Contact/Form/Search/Custom/RandomSegment.php
CRM/Contact/Form/Search/Custom/Sample.php
CRM/Contact/Form/Search/Custom/ZipCodeRange.php

index 6072f7c18b1e94ee799c8198a1ce1efc0669ea48..b78fa15e9354dda49f48e8d96f6c4826b2b6f157 100644 (file)
@@ -363,7 +363,6 @@ ORDER BY contact_a.sort_name';
     if ($this->_aclWhere) {
       $clauses[] = " {$this->_aclWhere} ";
     }
-
     return implode(' AND ', $clauses);
   }
 
index b920a45188cdf77bcaeb8f0f492575da49646978..71c7257cceaf12d7a7b738ebb43358133646a561 100644 (file)
@@ -194,7 +194,7 @@ class CRM_Contact_Form_Search_Custom_Basic extends CRM_Contact_Form_Search_Custo
   public function where($includeContactIDs = FALSE) {
     if ($whereClause = $this->_query->whereClause()) {
       if ($this->_aclWhere) {
-        $whereCluase .= " AND {$this->_aclWhere} ";
+        $whereClause .= " AND {$this->_aclWhere} AND contact_a.is_deleted = 0";
       }
       return $whereClause;
     }
index cb9d54e226e3e0e55e82f59254144ef2bd798bb5..8c5c9114ad30f8bf3906f55ca04865fdfb04dac5 100644 (file)
@@ -200,7 +200,6 @@ ORDER BY   donation_amount desc
       $dao = CRM_Core_DAO::executeQuery($query);
       $sql = "SELECT contact_a.id as contact_id FROM CustomSearch_SYBNT_temp as contact_a";
     }
-
     return $sql;
   }
 
index fdbf2435d7583b24c7e8f014fe0b9cd10aaceae5..acf5f253c97dff4a2565e1d071af225a66b0c3ed 100644 (file)
@@ -232,11 +232,10 @@ civicrm_contact AS contact_a {$this->_aclFrom}
       $clauses[] = "contrib.financial_type_id IN ($financial_type_ids)";
     }
     if ($this->_aclWhere) {
-      return " {$this->_aclWhere} " . implode(' AND ', $clauses);
-    }
-    else {
-      return implode(' AND ', $clauses);
+      $clauses[] =  " {$this->_aclWhere} ";
     }
+
+    return implode(' AND ', $clauses);
   }
 
   /**
index a2106ff25e7539681def1b1811d79c0a14db24cc..2868318407f0cd09251856ab9b30f9631163e23a 100644 (file)
@@ -399,7 +399,8 @@ class CRM_Contact_Form_Search_Custom_DateAdded extends CRM_Contact_Form_Search_C
   public function where($includeContactIDs = FALSE) {
     $where = '(1)';
     if ($this->_aclWhere) {
-      $where = " AND {$this->_aclWhere} ";
+      $where .= " AND {$this->_aclWhere} ";
+      $where .= " AND contact_a.is_deleted = 0";
     }
     return $where;
   }
index 132392466838a57118e0be15f8e2318f2d630a6c..d9d767c0c42c0714c4de3c156e1fd8ac1eec059f 100644 (file)
@@ -274,7 +274,7 @@ contact_a.sort_name    as sort_name,
       $clause[] = "cgc.group_id = {$this->_group}";
     }
     if ($this->_aclWhere) {
-      $clause[] = " AND {$this->_aclWhere} ";
+      $clause[] = " {$this->_aclWhere} AND contact_a.is_deleted = 0";
     }
 
     $where = '( 1 )';
@@ -282,8 +282,6 @@ contact_a.sort_name    as sort_name,
       $where .= ' AND ' . implode(' AND ', $clause);
     }
 
-    $where .= "{$this->_where} ";
-
     return $this->whereClause($where, $params);
   }
 
index 01c39a5022292ebdc262bba723609146ac7aa4d3..2436b8ca50731b7f86b8ce188cb58e388d63556a 100644 (file)
@@ -326,7 +326,7 @@ INNER JOIN {$this->_tableName} tempTable ON ( tempTable.contact_id = contact_a.i
   public function where($includeContactIDs = FALSE) {
     $where = ' ( 1 ) ';
     if ($this->_aclWhere) {
-      $where = " AND {$this->_aclWhere} ";
+      $where .= " AND {$this->_aclWhere} ";
     }
     return $where;
   }
index ee97c6c1dce8f07644f183ec867d836bd09f903e..78015b2f9108842c5f5110812b9db2a9c92cc357 100644 (file)
@@ -252,7 +252,6 @@ AND cgc.group_id = {$this->_group}
     }
 
     $where .= " AND contact_a.is_deleted != 1 ";
-    $where .= "{$this->_where}";
 
     if ($this->_aclWhere) {
       $where .= " AND {$this->_aclWhere} ";
index e9b2a9e9fb10169835730c825df80d44c11767df..13bc69ea0fe4b7d8e68030ea935253cf4325da39 100644 (file)
@@ -344,7 +344,7 @@ class CRM_Contact_Form_Search_Custom_RandomSegment extends CRM_Contact_Form_Sear
     $where = '(1)';
 
     if ($this->_aclWhere) {
-      $where = " AND {$this->_aclWhere} ";
+      $where .= " AND {$this->_aclWhere} ";
     }
 
     return '(1)';
index 85ce543136d799be3ae8f37e24a9e10935b47004..0d1afb1582a69b488921dbbde00afa65fa59716b 100644 (file)
@@ -160,7 +160,6 @@ LEFT JOIN civicrm_state_province state_province ON state_province.id = address.s
   public function where($includeContactIDs = FALSE) {
     $params = array();
     $where = "contact_a.contact_type   = 'Household'";
-    $where .= "{$this->_where}";
 
     $count = 1;
     $clause = array();
@@ -191,7 +190,7 @@ LEFT JOIN civicrm_state_province state_province ON state_province.id = address.s
     }
 
     if ($this->_aclWhere) {
-      $clause[] = " AND {$this->_aclWhere} ";
+      $clause[] = " {$this->_aclWhere} ";
     }
 
     if (!empty($clause)) {
index f661731e1b4bc8cf0b01ad963b645cb7e09d6b81..1af002dd7735d321b71ae42e28195212c573082f 100644 (file)
@@ -173,9 +173,8 @@ LEFT JOIN civicrm_email   email   ON ( email.contact_id = contact_a.id AND
     );
 
     if ($this->_aclWhere) {
-      $where .= " AND {$this->_aclWhere} ";
+      $where .= " AND {$this->_aclWhere} AND contact_a.is_deleted = 0";
     }
-
     return $this->whereClause($where, $params);
   }