From ed79572300c50661b630e73b7ef0ca94bfb35194 Mon Sep 17 00:00:00 2001 From: Jamie McClelland Date: Mon, 5 Jan 2015 11:40:04 -0500 Subject: [PATCH] CRM-15781 - ensure filter by activity tag works on activity report Previously only contact tags were listed and searched for. ---------------------------------------- * CRM-15781: activity report does not properly handle activity tags https://issues.civicrm.org/jira/browse/CRM-15781 --- CRM/Report/Form.php | 14 ++++++++++---- CRM/Report/Form/Activity.php | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 84efb835cd..b7f1edb2f7 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -147,6 +147,12 @@ class CRM_Report_Form extends CRM_Core_Form { */ protected $_tagFilter = FALSE; + /** + * specify entity table for tags filter + * + */ + protected $_tagFilterTable = 'civicrm_contact'; + /** * build groups filter * @@ -1260,7 +1266,7 @@ class CRM_Report_Form extends CRM_Core_Form { } function buildTagFilter() { - $contactTags = CRM_Core_BAO_Tag::getTags(); + $contactTags = CRM_Core_BAO_Tag::getTags($this->_tagFilterTable); if (!empty($contactTags)) { $this->_columns['civicrm_tag'] = array( 'dao' => 'CRM_Core_DAO_Tag', @@ -3009,11 +3015,11 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $value = array($value); } $clause = "{$field['dbAlias']} IN (" . implode(', ', $value) . ")"; - - return " {$this->_aliases['civicrm_contact']}.id {$sqlOp} ( + $entity_table = $this->_tagFilterTable; + return " {$this->_aliases[$entity_table]}.id {$sqlOp} ( SELECT DISTINCT {$this->_aliases['civicrm_tag']}.entity_id FROM civicrm_entity_tag {$this->_aliases['civicrm_tag']} - WHERE entity_table = 'civicrm_contact' AND {$clause} ) "; + WHERE entity_table = '$entity_table' AND {$clause} ) "; } function whereMembershipOrgClause($field, $value, $op) { diff --git a/CRM/Report/Form/Activity.php b/CRM/Report/Form/Activity.php index f46b8639ef..43a3f7950b 100644 --- a/CRM/Report/Form/Activity.php +++ b/CRM/Report/Form/Activity.php @@ -308,6 +308,7 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { } $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; + $this->_tagFilterTable = 'civicrm_activity'; parent::__construct(); } -- 2.25.1