From: Seamus Lee Date: Mon, 29 Jun 2015 22:05:47 +0000 (+0000) Subject: Fix up SQL errors found by dave X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b3798d48c2833889389ede127e22f18f48ee3489;p=civicrm-core.git Fix up SQL errors found by dave --- diff --git a/CRM/Contact/Form/Search/Custom/ActivitySearch.php b/CRM/Contact/Form/Search/Custom/ActivitySearch.php index 6072f7c18b..b78fa15e93 100644 --- a/CRM/Contact/Form/Search/Custom/ActivitySearch.php +++ b/CRM/Contact/Form/Search/Custom/ActivitySearch.php @@ -363,7 +363,6 @@ ORDER BY contact_a.sort_name'; if ($this->_aclWhere) { $clauses[] = " {$this->_aclWhere} "; } - return implode(' AND ', $clauses); } diff --git a/CRM/Contact/Form/Search/Custom/Basic.php b/CRM/Contact/Form/Search/Custom/Basic.php index b920a45188..71c7257cce 100644 --- a/CRM/Contact/Form/Search/Custom/Basic.php +++ b/CRM/Contact/Form/Search/Custom/Basic.php @@ -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; } diff --git a/CRM/Contact/Form/Search/Custom/ContribSYBNT.php b/CRM/Contact/Form/Search/Custom/ContribSYBNT.php index cb9d54e226..8c5c9114ad 100644 --- a/CRM/Contact/Form/Search/Custom/ContribSYBNT.php +++ b/CRM/Contact/Form/Search/Custom/ContribSYBNT.php @@ -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; } diff --git a/CRM/Contact/Form/Search/Custom/ContributionAggregate.php b/CRM/Contact/Form/Search/Custom/ContributionAggregate.php index fdbf2435d7..acf5f253c9 100644 --- a/CRM/Contact/Form/Search/Custom/ContributionAggregate.php +++ b/CRM/Contact/Form/Search/Custom/ContributionAggregate.php @@ -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); } /** diff --git a/CRM/Contact/Form/Search/Custom/DateAdded.php b/CRM/Contact/Form/Search/Custom/DateAdded.php index a2106ff25e..2868318407 100644 --- a/CRM/Contact/Form/Search/Custom/DateAdded.php +++ b/CRM/Contact/Form/Search/Custom/DateAdded.php @@ -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; } diff --git a/CRM/Contact/Form/Search/Custom/MultipleValues.php b/CRM/Contact/Form/Search/Custom/MultipleValues.php index 1323924668..d9d767c0c4 100644 --- a/CRM/Contact/Form/Search/Custom/MultipleValues.php +++ b/CRM/Contact/Form/Search/Custom/MultipleValues.php @@ -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); } diff --git a/CRM/Contact/Form/Search/Custom/PriceSet.php b/CRM/Contact/Form/Search/Custom/PriceSet.php index 01c39a5022..2436b8ca50 100644 --- a/CRM/Contact/Form/Search/Custom/PriceSet.php +++ b/CRM/Contact/Form/Search/Custom/PriceSet.php @@ -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; } diff --git a/CRM/Contact/Form/Search/Custom/Proximity.php b/CRM/Contact/Form/Search/Custom/Proximity.php index ee97c6c1dc..78015b2f91 100644 --- a/CRM/Contact/Form/Search/Custom/Proximity.php +++ b/CRM/Contact/Form/Search/Custom/Proximity.php @@ -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} "; diff --git a/CRM/Contact/Form/Search/Custom/RandomSegment.php b/CRM/Contact/Form/Search/Custom/RandomSegment.php index e9b2a9e9fb..13bc69ea0f 100644 --- a/CRM/Contact/Form/Search/Custom/RandomSegment.php +++ b/CRM/Contact/Form/Search/Custom/RandomSegment.php @@ -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)'; diff --git a/CRM/Contact/Form/Search/Custom/Sample.php b/CRM/Contact/Form/Search/Custom/Sample.php index 85ce543136..0d1afb1582 100644 --- a/CRM/Contact/Form/Search/Custom/Sample.php +++ b/CRM/Contact/Form/Search/Custom/Sample.php @@ -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)) { diff --git a/CRM/Contact/Form/Search/Custom/ZipCodeRange.php b/CRM/Contact/Form/Search/Custom/ZipCodeRange.php index f661731e1b..1af002dd77 100644 --- a/CRM/Contact/Form/Search/Custom/ZipCodeRange.php +++ b/CRM/Contact/Form/Search/Custom/ZipCodeRange.php @@ -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); }