From 02e02ac52ecf868b66ab3f80f5af1b45c9b3bb3d Mon Sep 17 00:00:00 2001 From: Deepak Srivastava Date: Tue, 14 Jan 2014 16:30:50 +0530 Subject: [PATCH] CRM-14057 - contact logging detail report may have missing/wrong altered and altered by name ---------------------------------------- * CRM-14057: contact logging detail report may have missing/wrong altered and altered by name http://issues.civicrm.org/jira/browse/CRM-14057 --- CRM/Logging/ReportDetail.php | 24 +++++++++++--------- CRM/Report/Form/Contact/LoggingDetail.php | 10 -------- CRM/Report/Form/Contact/LoggingSummary.php | 6 +++++ CRM/Report/Form/Contribute/LoggingDetail.php | 10 -------- 4 files changed, 19 insertions(+), 31 deletions(-) diff --git a/CRM/Logging/ReportDetail.php b/CRM/Logging/ReportDetail.php index 0ee0fad709..bfaeaf4430 100644 --- a/CRM/Logging/ReportDetail.php +++ b/CRM/Logging/ReportDetail.php @@ -41,6 +41,10 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form { protected $tables = array(); protected $interval = '10 SECOND'; + protected $altered_name; + protected $altered_by; + protected $altered_by_id; + // detail/summary report ids protected $detail; protected $summary; @@ -57,6 +61,10 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form { $this->cid = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject); $this->raw = CRM_Utils_Request::retrieve('raw', 'Boolean', CRM_Core_DAO::$_nullObject); + $this->altered_name = CRM_Utils_Request::retrieve('alteredName', 'String', CRM_Core_DAO::$_nullObject); + $this->altered_by = CRM_Utils_Request::retrieve('alteredBy', 'String', CRM_Core_DAO::$_nullObject); + $this->altered_by_id = CRM_Utils_Request::retrieve('alteredById', 'Integer', CRM_Core_DAO::$_nullObject); + parent::__construct(); CRM_Utils_System::resetBreadCrumb(); @@ -199,22 +207,16 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form { 2 => array($this->log_date, 'String'), ); - // let the template know who updated whom when - $dao = CRM_Core_DAO::executeQuery($this->whoWhomWhenSql(), $params); - if ($dao->fetch()) { - $this->assign('who_url', CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->who_id}")); - $this->assign('whom_url', CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->whom_id}")); - $this->assign('who_name', $dao->who_name); - $this->assign('whom_name', $dao->whom_name); - } + $this->assign('whom_url', CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->cid}")); + $this->assign('who_url', CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->altered_by_id}")); + $this->assign('whom_name', $this->altered_name); + $this->assign('who_name', $this->altered_by); + $this->assign('log_date', CRM_Utils_Date::mysqlToIso($this->log_date)); $q = "reset=1&log_conn_id={$this->log_conn_id}&log_date={$this->log_date}"; $this->assign('revertURL', CRM_Report_Utils_Report::getNextUrl($this->detail, "$q&revert=1", FALSE, TRUE)); $this->assign('revertConfirm', ts('Are you sure you want to revert all these changes?')); } - - // redefine this accordingly in ancestors for buildQuickForm()’s sake - protected function whoWhomWhenSql() {} } diff --git a/CRM/Report/Form/Contact/LoggingDetail.php b/CRM/Report/Form/Contact/LoggingDetail.php index 9a0b40fac8..37b7b3aaac 100644 --- a/CRM/Report/Form/Contact/LoggingDetail.php +++ b/CRM/Report/Form/Contact/LoggingDetail.php @@ -74,15 +74,5 @@ class CRM_Report_Form_Contact_LoggingDetail extends CRM_Logging_ReportDetail { $this->assign('backURL', CRM_Report_Utils_Report::getNextUrl('logging/contact/summary', 'reset=1', FALSE, TRUE)); } } - - protected function whoWhomWhenSql() { - return " - SELECT who.id who_id, who.display_name who_name, whom.id whom_id, whom.display_name whom_name, l.is_deleted - FROM `{$this->db}`.log_civicrm_contact l - JOIN civicrm_contact who ON (l.log_user_id = who.id) - JOIN civicrm_contact whom ON (l.id = whom.id) - WHERE log_action = 'Update' AND log_conn_id = %1 AND log_date = %2 ORDER BY log_date DESC LIMIT 1 - "; - } } diff --git a/CRM/Report/Form/Contact/LoggingSummary.php b/CRM/Report/Form/Contact/LoggingSummary.php index 2daa35d4be..fef8530c26 100644 --- a/CRM/Report/Form/Contact/LoggingSummary.php +++ b/CRM/Report/Form/Contact/LoggingSummary.php @@ -201,6 +201,12 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary { if ($this->cid) { $q .= '&cid=' . $this->cid; } + $q .= (!empty($row['log_civicrm_entity_altered_contact'])) ? + '&alteredName='.$row['log_civicrm_entity_altered_contact'] : ''; + $q .= (!empty($row['altered_by_contact_display_name'])) ? + '&alteredBy='.$row['altered_by_contact_display_name'] : ''; + $q .= (!empty($row['log_civicrm_entity_log_user_id'])) ? + '&alteredById='.$row['log_civicrm_entity_log_user_id'] : ''; $url1 = CRM_Report_Utils_Report::getNextUrl('logging/contact/detail', "{$q}&snippet=4§ion=2&layout=overlay", FALSE, TRUE); $url2 = CRM_Report_Utils_Report::getNextUrl('logging/contact/detail', "{$q}§ion=2", FALSE, TRUE); diff --git a/CRM/Report/Form/Contribute/LoggingDetail.php b/CRM/Report/Form/Contribute/LoggingDetail.php index 276689a514..223cc6f29a 100644 --- a/CRM/Report/Form/Contribute/LoggingDetail.php +++ b/CRM/Report/Form/Contribute/LoggingDetail.php @@ -51,15 +51,5 @@ class CRM_Report_Form_Contribute_LoggingDetail extends CRM_Logging_ReportDetail // link back to summary report $this->assign('backURL', CRM_Report_Utils_Report::getNextUrl('logging/contribute/summary', 'reset=1', FALSE, TRUE)); } - - protected function whoWhomWhenSql() { - return " - SELECT who.id who_id, who.display_name who_name, whom.id whom_id, whom.display_name whom_name - FROM `{$this->db}`.log_civicrm_contribution l - LEFT JOIN civicrm_contact who ON (l.log_user_id = who.id) - LEFT JOIN civicrm_contact whom ON (l.contact_id = whom.id) - WHERE log_action = 'Update' AND log_conn_id = %1 AND log_date = %2 ORDER BY log_date DESC LIMIT 1 - "; - } } -- 2.25.1