minor fix
authormonishdeb <monish.deb@webaccess.co.in>
Tue, 27 May 2014 10:48:43 +0000 (16:18 +0530)
committermonishdeb <monish.deb@webaccess.co.in>
Tue, 27 May 2014 10:48:43 +0000 (16:18 +0530)
CRM/Contact/Form/Search/Custom/ContribSYBNT.php
CRM/Contact/Form/Search/Custom/FullText.php
CRM/Contact/Selector.php

index 6b5a196b4c2ec1f263b5cc7a9b382444e2c78001..91775a4948214ed404f58b55b2c1b5d48637f3e6 100644 (file)
@@ -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;
index 16c8a8d06a2a08edc20d32a848ad0edb43d975a7..aaefb737cd6ec7beec9a56121aadce71d843229e 100644 (file)
@@ -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 = "
index 51b5a87710dc2e2736e93e75342694ed69b288ce..49042178a560fda05bbca052f51f2ee07f754817 100644 (file)
@@ -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);