From 10b32ed4f7eb52381e5b8292bdd9f82c669ebe53 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 7 Apr 2016 11:18:36 +1200 Subject: [PATCH] CRM-18193 do not require log_date Log_date should be an optional report parameter reflecting the changes in CRM-18193 to make the connection_id unique --- CRM/Logging/Differ.php | 20 ++++++++++++++------ CRM/Logging/ReportDetail.php | 4 ++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CRM/Logging/Differ.php b/CRM/Logging/Differ.php index 923629a809..06a87b3b37 100644 --- a/CRM/Logging/Differ.php +++ b/CRM/Logging/Differ.php @@ -269,11 +269,16 @@ WHERE lt.log_conn_id = %1 } /** - * @param $table + * Get the titles & metadata option values for the table. + * + * For custom fields the titles may change so we use the ones as at the reference date. + * + * @param string $table + * @param string $referenceDate * * @return array */ - public function titlesAndValuesForTable($table) { + public function titlesAndValuesForTable($table, $referenceDate) { // static caches for subsequent calls with the same $table static $titles = array(); static $values = array(); @@ -325,7 +330,7 @@ WHERE lt.log_conn_id = %1 } } elseif (substr($table, 0, 14) == 'civicrm_value_') { - list($titles[$table], $values[$table]) = $this->titlesAndValuesForCustomDataTable($table); + list($titles[$table], $values[$table]) = $this->titlesAndValuesForCustomDataTable($table, $referenceDate); } else { $titles[$table] = $values[$table] = array(); @@ -348,17 +353,20 @@ WHERE lt.log_conn_id = %1 } /** - * @param $table + * Get the field titles & option group values for the custom table as at the reference date. + * + * @param string $table + * @param string $referenceDate * * @return array */ - private function titlesAndValuesForCustomDataTable($table) { + private function titlesAndValuesForCustomDataTable($table, $referenceDate) { $titles = array(); $values = array(); $params = array( 1 => array($this->log_conn_id, 'String'), - 2 => array($this->log_date, 'String'), + 2 => array($referenceDate, 'String'), 3 => array($table, 'String'), ); diff --git a/CRM/Logging/ReportDetail.php b/CRM/Logging/ReportDetail.php index b30d7065f0..2e680da42c 100644 --- a/CRM/Logging/ReportDetail.php +++ b/CRM/Logging/ReportDetail.php @@ -127,7 +127,7 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form { */ public function buildRows($sql, &$rows) { // safeguard for when there aren’t any log entries yet - if (!$this->log_conn_id or !$this->log_date) { + if (!$this->log_conn_id && !$this->log_date) { return; } $this->getDiffs(); @@ -177,7 +177,7 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form { foreach ($this->diffs as $diff) { $table = $diff['table']; if (empty($metadata[$table])) { - list($metadata[$table]['titles'], $metadata[$table]['values']) = $this->differ->titlesAndValuesForTable($table); + list($metadata[$table]['titles'], $metadata[$table]['values']) = $this->differ->titlesAndValuesForTable($table, $diff['log_date']); } $values = CRM_Utils_Array::value('values', $metadata[$diff['table']], array()); $titles = $metadata[$diff['table']]['titles']; -- 2.25.1