From 6b4b11c477484a9e6894bc82564d318cd7cee20e Mon Sep 17 00:00:00 2001 From: Deepak Srivastava Date: Wed, 14 Aug 2013 17:30:02 +0530 Subject: [PATCH] CRM-12910 - logDetail extension for job tables, via report hook query objects --- CRM/Logging/Differ.php | 9 ++++++++- CRM/Logging/ReportSummary.php | 2 +- CRM/Report/BAO/Hook.php | 16 ++++++++++++++-- CRM/Report/BAO/HookInterface.php | 5 ++++- CRM/Report/Form/Contact/LoggingDetail.php | 3 +++ 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/CRM/Logging/Differ.php b/CRM/Logging/Differ.php index 6111deba84..d17c243410 100644 --- a/CRM/Logging/Differ.php +++ b/CRM/Logging/Differ.php @@ -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(); } } diff --git a/CRM/Logging/ReportSummary.php b/CRM/Logging/ReportSummary.php index fea2b82d5e..91c7e74809 100644 --- a/CRM/Logging/ReportSummary.php +++ b/CRM/Logging/ReportSummary.php @@ -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(); } diff --git a/CRM/Report/BAO/Hook.php b/CRM/Report/BAO/Hook.php index 6c2cee9f6c..bf43cfc67b 100644 --- a/CRM/Report/BAO/Hook.php +++ b/CRM/Report/BAO/Hook.php @@ -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 diff --git a/CRM/Report/BAO/HookInterface.php b/CRM/Report/BAO/HookInterface.php index af3b33f02a..42723835c0 100644 --- a/CRM/Report/BAO/HookInterface.php +++ b/CRM/Report/BAO/HookInterface.php @@ -38,7 +38,10 @@ */ 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 diff --git a/CRM/Report/Form/Contact/LoggingDetail.php b/CRM/Report/Form/Contact/LoggingDetail.php index 9c0fcf38bb..b7dfde2a00 100644 --- a/CRM/Report/Form/Contact/LoggingDetail.php +++ b/CRM/Report/Form/Contact/LoggingDetail.php @@ -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'; -- 2.25.1