CRM-12910 - logDetail extension for job tables, via report hook query objects
authorDeepak Srivastava <deepak.srivastava@webaccess.co.in>
Wed, 14 Aug 2013 12:00:02 +0000 (17:30 +0530)
committerDeepak Srivastava <deepak.srivastava@webaccess.co.in>
Wed, 14 Aug 2013 12:00:02 +0000 (17:30 +0530)
CRM/Logging/Differ.php
CRM/Logging/ReportSummary.php
CRM/Report/BAO/Hook.php
CRM/Report/BAO/HookInterface.php
CRM/Report/Form/Contact/LoggingDetail.php

index 6111deba84c3b8a82dca01a5a5703598173fb19d..d17c243410143e8b97b4d69ea720eb4ed8ede842 100644 (file)
@@ -97,7 +97,12 @@ LEFT JOIN civicrm_activity_contact source ON source.activity_id = lt.id AND sour
         $contactIdClause = "AND id = (select case_id FROM civicrm_case_contact WHERE contact_id = %3 LIMIT 1)";
         break;
       default:
-        $contactIdClause = "AND contact_id = %3";
+        // allow tables to be extended by report hook query objects
+        list($contactIdClause, $join) = CRM_Report_BAO_Hook::singleton()->logDiffClause($this, $table);
+
+        if (empty($contactIdClause)) {
+          $contactIdClause = "AND contact_id = %3";
+        }
         if ( strpos($table, 'civicrm_value') !== false ) {
           $contactIdClause = "AND entity_id = %3";
         }
@@ -272,6 +277,8 @@ WHERE log_conn_id = %1 AND
       }
       elseif (substr($table, 0, 14) == 'civicrm_value_') {
         list($titles[$table], $values[$table]) = $this->titlesAndValuesForCustomDataTable($table);
+      } else {
+        $titles[$table] = $values[$table] = array();
       }
     }
 
index fea2b82d5e96d7a4b56f222366cc95d5b96b0f55..91c7e74809a791034d56f9d3be689255d2a13d3e 100644 (file)
@@ -177,7 +177,7 @@ class CRM_Logging_ReportSummary extends CRM_Report_Form {
     }
 
     // allow log tables to be extended via report hooks
-    CRM_Report_BAO_Hook::singleton()->alterLogTables($this->_logTables);
+    CRM_Report_BAO_Hook::singleton()->alterLogTables($this, $this->_logTables);
 
     parent::__construct();
   }
index 6c2cee9f6c87a53801024041a098bf6a6b9e3a7b..bf43cfc67badcf5c9b328f831782aef405cb4313 100644 (file)
@@ -72,9 +72,21 @@ class CRM_Report_BAO_Hook {
     return $this->_queryObjects;
   }
 
-  public function alterLogTables(&$logTables) {
+  public function alterLogTables(&$reportObj, &$logTables) {
     foreach (self::getSearchQueryObjects() as $obj) {
-      $obj->alterLogTables($logTables);
+      $obj->alterLogTables($reportObj, $logTables);
     }
   }
+
+  public function logDiffClause(&$reportObj, $table) {
+    $contactIdClause = $join = '';
+    foreach (self::getSearchQueryObjects() as $obj) {
+      list($cidClause, $joinClause) = $obj->logDiffClause($reportObj, $table);
+      if ($joinClause) 
+        $join .= $joinClause;
+      if ($cidClause) 
+        $contactIdClause .= $cidClause;
+    }
+    return array($contactIdClause, $join);
+  }
 }
\ No newline at end of file
index af3b33f02a7cb4b3bd22545442c01d2a290f00bd..42723835c091fb91da3d8bd62d19b499e0bbcffc 100644 (file)
  */
 class CRM_Report_BAO_HookInterface {
 
-  public function alterLogTables(&$logTables) {
+  public function alterLogTables(&$reportObj, &$logTables) {
     return NULL;
   }
+  public function logDiffClause(&$reportObj, $table) {
+    return array();
+  }
 }
\ No newline at end of file
index 9c0fcf38bb9dbbbbb679d61428f2f9604221102e..b7dfde2a00fca1ecd9896be7288ef69009649f85 100644 (file)
@@ -49,6 +49,9 @@ class CRM_Report_Form_Contact_LoggingDetail extends CRM_Logging_ReportDetail {
     $this->tables[] = 'civicrm_activity';
     $this->tables[] = 'civicrm_case';
 
+    // allow tables to be extended by report hook query objects
+    CRM_Report_BAO_Hook::singleton()->alterLogTables($this, $this->tables);
+
     $this->detail = 'logging/contact/detail';
     $this->summary = 'logging/contact/summary';