From 0cd506235b56c03da23dc835cfd1e50b73296a00 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Wed, 8 Jul 2015 14:51:36 +0530 Subject: [PATCH] add smartGroup title in select clause --- CRM/Contact/BAO/Query.php | 21 +++++++++++++---- CRM/Core/TableHierarchy.php | 47 +++++++++++++++++++------------------ 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 22adce2d0d..edffa26e80 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -2431,9 +2431,14 @@ class CRM_Contact_BAO_Query { ); } - // add group_contact table if group table is present - if (!empty($tables['civicrm_group']) && empty($tables['civicrm_group_contact'])) { - $tables['civicrm_group_contact'] = " LEFT JOIN civicrm_group_contact ON civicrm_group_contact.contact_id = contact_a.id AND civicrm_group_contact.status = 'Added'"; + // add group_contact and group_contact_cache table if group table is present + if (!empty($tables['civicrm_group'])) { + if (empty($tables['civicrm_group_contact'])) { + $tables['civicrm_group_contact'] = " LEFT JOIN civicrm_group_contact ON civicrm_group_contact.contact_id = contact_a.id AND civicrm_group_contact.status = 'Added' "; + } + if (empty($tables['civicrm_group_contact_cache'])) { + $tables['civicrm_group_contact_cache'] = " LEFT JOIN civicrm_group_contact_cache ON civicrm_group_contact_cache.contact_id = contact_a.id "; + } } // add group_contact and group table is subscription history is present @@ -2550,13 +2555,17 @@ class CRM_Contact_BAO_Query { continue; case 'civicrm_group': - $from .= " $side JOIN civicrm_group ON civicrm_group.id = civicrm_group_contact.group_id "; + $from .= " $side JOIN civicrm_group ON (civicrm_group.id = civicrm_group_contact.group_id OR civicrm_group.id = civicrm_group_contact_cache.group_id) "; continue; case 'civicrm_group_contact': $from .= " $side JOIN civicrm_group_contact ON contact_a.id = civicrm_group_contact.contact_id "; continue; + case 'civicrm_group_contact_cache': + $from .= " $side JOIN civicrm_group_contact_cache ON contact_a.id = civicrm_group_contact_cache.contact_id "; + continue; + case 'civicrm_activity': case 'civicrm_activity_tag': case 'activity_type': @@ -2869,7 +2878,9 @@ class CRM_Contact_BAO_Query { list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contact_DAO_Group', 'id', $value, $op); $this->_qill[$grouping][] = ts("Group(s) %1 %2", array(1 => $qillop, 2 => $qillVal)); - $this->_qill[$grouping][] = ts("Group Status %1", array(1 => implode(' ' . ts('or') . ' ', $statii))); + if (strpos($op, 'NULL') === FALSE) { + $this->_qill[$grouping][] = ts("Group Status %1", array(1 => implode(' ' . ts('or') . ' ', $statii))); + } if ($groupClause) { $this->_where[$grouping][] = $groupClause; } diff --git a/CRM/Core/TableHierarchy.php b/CRM/Core/TableHierarchy.php index e16b13d780..0c9478f3f1 100644 --- a/CRM/Core/TableHierarchy.php +++ b/CRM/Core/TableHierarchy.php @@ -51,29 +51,30 @@ class CRM_Core_TableHierarchy { 'civicrm_openid' => '17', 'civicrm_location_type' => '18', 'civicrm_group_contact' => '19', - 'civicrm_group' => '20', - 'civicrm_subscription_history' => '21', - 'civicrm_entity_tag' => '22', - 'civicrm_note' => '23', - 'civicrm_contribution' => '24', - 'civicrm_financial_type' => '25', - 'civicrm_participant' => '26', - 'civicrm_event' => '27', - 'civicrm_worldregion' => '28', - 'civicrm_case_contact' => '29', - 'civicrm_case' => '30', - 'case_relationship' => '31', - 'case_relation_type' => '32', - 'civicrm_activity' => '33', - 'civicrm_mailing_summary' => '34', - 'civicrm_mailing_recipients' => '35', - 'civicrm_mailing' => '36', - 'civicrm_mailing_job' => '37', - 'civicrm_mailing_event_queue' => '38', - 'civicrm_mailing_event_bounce' => '39', - 'civicrm_mailing_event_opened' => '40', - 'civicrm_mailing_event_reply' => '41', - 'civicrm_mailing_event_trackable_url_open' => '42', + 'civicrm_group_contact_cache' => '20', + 'civicrm_group' => '21', + 'civicrm_subscription_history' => '22', + 'civicrm_entity_tag' => '23', + 'civicrm_note' => '24', + 'civicrm_contribution' => '25', + 'civicrm_financial_type' => '26', + 'civicrm_participant' => '27', + 'civicrm_event' => '28', + 'civicrm_worldregion' => '29', + 'civicrm_case_contact' => '30', + 'civicrm_case' => '31', + 'case_relationship' => '32', + 'case_relation_type' => '33', + 'civicrm_activity' => '34', + 'civicrm_mailing_summary' => '35', + 'civicrm_mailing_recipients' => '36', + 'civicrm_mailing' => '37', + 'civicrm_mailing_job' => '38', + 'civicrm_mailing_event_queue' => '39', + 'civicrm_mailing_event_bounce' => '40', + 'civicrm_mailing_event_opened' => '41', + 'civicrm_mailing_event_reply' => '42', + 'civicrm_mailing_event_trackable_url_open' => '43', ); /** -- 2.25.1