CRM-15781 - ensure filter by activity tag works on activity report
authorJamie McClelland <jm@mayfirst.org>
Mon, 5 Jan 2015 16:40:04 +0000 (11:40 -0500)
committerJamie McClelland <jm@mayfirst.org>
Mon, 5 Jan 2015 16:40:04 +0000 (11:40 -0500)
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
CRM/Report/Form/Activity.php

index 84efb835cd925cb26f88128108c4406e98cb8dd7..b7f1edb2f7ce392761d30cc6e713d187c6662332 100644 (file)
@@ -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) {
index f46b8639efef7946981613f7726f7e14a88d734d..43a3f7950bb84341bc2cbbc4843bede591c7a62d 100644 (file)
@@ -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();
   }