From b9f6b15055eef95647cd32c627e80fbccabec3c1 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Tue, 27 May 2014 16:18:43 +0530 Subject: [PATCH] minor fix --- .../Form/Search/Custom/ContribSYBNT.php | 20 +++++++++---------- CRM/Contact/Form/Search/Custom/FullText.php | 2 +- CRM/Contact/Selector.php | 15 -------------- 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/CRM/Contact/Form/Search/Custom/ContribSYBNT.php b/CRM/Contact/Form/Search/Custom/ContribSYBNT.php index 6b5a196b4c..91775a4948 100644 --- a/CRM/Contact/Form/Search/Custom/ContribSYBNT.php +++ b/CRM/Contact/Form/Search/Custom/ContribSYBNT.php @@ -164,13 +164,13 @@ class CRM_Contact_Form_Search_Custom_ContribSYBNT implements CRM_Contact_Form_Se if ($justIDs) { $select = $this->select(); - $select .= ', contact.id as contact_id, sort_name'; + $select .= ', contact_a.id, display_name'; } else { $select = $this->select(); $select = " - DISTINCT contact.id as contact_id, - contact.display_name as display_name, + DISTINCT contact_a.id as contact_id, + contact_a.display_name as display_name, $select "; @@ -178,13 +178,13 @@ class CRM_Contact_Form_Search_Custom_ContribSYBNT implements CRM_Contact_Form_Se $sql = " SELECT $select -FROM civicrm_contact AS contact -LEFT JOIN civicrm_contribution contrib_1 ON contrib_1.contact_id = contact.id +FROM civicrm_contact AS contact_a +LEFT JOIN civicrm_contribution contrib_1 ON contrib_1.contact_id = contact_a.id $from -WHERE contrib_1.contact_id = contact.id +WHERE contrib_1.contact_id = contact_a.id AND contrib_1.is_test = 0 $where -GROUP BY contact.id +GROUP BY contact_a.id $having ORDER BY donation_amount desc "; @@ -194,7 +194,7 @@ ORDER BY donation_amount desc CRM_Core_DAO::executeQuery("DROP TEMPORARY TABLE IF EXISTS CustomSearch_SYBNT_temp"); $query = "CREATE TEMPORARY TABLE CustomSearch_SYBNT_temp AS ({$sql})"; $dao = CRM_Core_DAO::executeQuery($query); - $sql = "SELECT contact_id FROM CustomSearch_SYBNT_temp"; + $sql = "SELECT contact_a.id as contact_id FROM CustomSearch_SYBNT_temp as contact_a"; } return $sql; @@ -224,14 +224,14 @@ count(contrib_1.id) AS donation_count function from() { $from = NULL; if (!empty($this->start_date_2) || !empty($this->end_date_2)) { - $from .= " LEFT JOIN civicrm_contribution contrib_2 ON contrib_2.contact_id = contact.id "; + $from .= " LEFT JOIN civicrm_contribution contrib_2 ON contrib_2.contact_id = contact_a.id "; } if (!empty($this->exclude_start_date) || !empty($this->exclude_end_date) || !empty($this->is_first_amount) ) { - $from .= " LEFT JOIN XG_CustomSearch_SYBNT xg ON xg.contact_id = contact.id "; + $from .= " LEFT JOIN XG_CustomSearch_SYBNT xg ON xg.contact_id = contact_a.id "; } return $from; diff --git a/CRM/Contact/Form/Search/Custom/FullText.php b/CRM/Contact/Form/Search/Custom/FullText.php index 16c8a8d06a..aaefb737cd 100644 --- a/CRM/Contact/Form/Search/Custom/FullText.php +++ b/CRM/Contact/Form/Search/Custom/FullText.php @@ -893,7 +893,7 @@ WHERE (c.sort_name LIKE {$this->_text} OR c.display_name LIKE {$this->_text $this->initialize(); if ($justIDs) { - $select = "contact_a.contact_id as contact_id"; + $select = "contact_a.contact_id"; } else { $select = " diff --git a/CRM/Contact/Selector.php b/CRM/Contact/Selector.php index 51b5a87710..49042178a5 100644 --- a/CRM/Contact/Selector.php +++ b/CRM/Contact/Selector.php @@ -978,12 +978,6 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se $sql = $this->_search->contactIDs($start, $end, $sort, TRUE); $replaceSQL = "SELECT contact_a.id as contact_id"; - if (is_a($this->_search, 'CRM_Contact_Form_Search_Custom_FullText') || - is_a($this->_search, 'CRM_Contact_Form_Search_Custom_ContribSYBNT') - ) { - $replaceSQL = "SELECT contact_id"; - } - $coreSearch = FALSE; } // For core searches use the searchQuery method @@ -1006,15 +1000,6 @@ INSERT INTO civicrm_prevnext_cache ( entity_table, entity_id1, entity_id2, cache SELECT 'civicrm_contact', contact_a.id, contact_a.id, '$cacheKey', contact_a.display_name "; - if (property_exists($this, '_search') && - (is_a($this->_search, 'CRM_Contact_Form_Search_Custom_FullText') || - is_a($this->_search, 'CRM_Contact_Form_Search_Custom_ContribSYBNT')) - ) { - $insertSQL = " -INSERT INTO civicrm_prevnext_cache ( entity_table, entity_id1, entity_id2, cacheKey, data ) -SELECT 'civicrm_contact', contact_id, contact_id, '$cacheKey', sort_name -"; - } $sql = str_replace($replaceSQL, $insertSQL, $sql); -- 2.25.1