From c3e3dd658a7cbb82aeb742131efc8a83c89fde6a Mon Sep 17 00:00:00 2001 From: Deepak Srivastava Date: Sun, 11 Aug 2013 13:10:13 +0530 Subject: [PATCH] CRM-12910, extend log reports to support injected job tables, via report query-hook-objects --- CRM/Contact/BAO/Query/Hook.php | 2 +- CRM/Logging/ReportSummary.php | 3 ++ CRM/Report/BAO/Hook.php | 81 ++++++++++++++++++++++++++++++++ CRM/Report/BAO/HookInterface.php | 44 +++++++++++++++++ CRM/Utils/Hook.php | 4 +- 5 files changed, 131 insertions(+), 3 deletions(-) create mode 100644 CRM/Report/BAO/Hook.php create mode 100644 CRM/Report/BAO/HookInterface.php diff --git a/CRM/Contact/BAO/Query/Hook.php b/CRM/Contact/BAO/Query/Hook.php index 419b5aad0e..d791b626ec 100644 --- a/CRM/Contact/BAO/Query/Hook.php +++ b/CRM/Contact/BAO/Query/Hook.php @@ -66,7 +66,7 @@ class CRM_Contact_BAO_Query_Hook { public function getSearchQueryObjects() { if ($this->_queryObjects === NULL) { $this->_queryObjects = array(); - CRM_Utils_Hook::queryObjects($this->_queryObjects); + CRM_Utils_Hook::queryObjects($this->_queryObjects, 'Contact'); } return $this->_queryObjects; } diff --git a/CRM/Logging/ReportSummary.php b/CRM/Logging/ReportSummary.php index 203f336b2e..fea2b82d5e 100644 --- a/CRM/Logging/ReportSummary.php +++ b/CRM/Logging/ReportSummary.php @@ -176,6 +176,9 @@ class CRM_Logging_ReportSummary extends CRM_Report_Form { $this->_logTables[$table] = array('fk' => 'entity_id', 'log_type' => 'Contact'); } + // allow log tables to be extended via report hooks + CRM_Report_BAO_Hook::singleton()->alterLogTables($this->_logTables); + parent::__construct(); } diff --git a/CRM/Report/BAO/Hook.php b/CRM/Report/BAO/Hook.php new file mode 100644 index 0000000000..12bbbf95f0 --- /dev/null +++ b/CRM/Report/BAO/Hook.php @@ -0,0 +1,81 @@ +_queryObjects === NULL) { + $this->_queryObjects = array(); + CRM_Utils_Hook::queryObjects($this->_queryObjects, 'Report'); + } + CRM_Core_Error::debug( '$this->_queryObjects', $this->_queryObjects ); + return $this->_queryObjects; + } + + public function alterLogTables(&$logTables) { + foreach (self::getSearchQueryObjects() as $obj) { + $obj->alterLogTables($logTables); + } + } +} \ No newline at end of file diff --git a/CRM/Report/BAO/HookInterface.php b/CRM/Report/BAO/HookInterface.php new file mode 100644 index 0000000000..af3b33f02a --- /dev/null +++ b/CRM/Report/BAO/HookInterface.php @@ -0,0 +1,44 @@ +invoke(1, $queryObjects, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_queryObjects'); + static function queryObjects(&$queryObjects, $type = 'Contact') { + return self::singleton()->invoke(2, $queryObjects, $type, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_queryObjects'); } } -- 2.25.1