From: eileen Date: Thu, 7 Apr 2016 04:38:18 +0000 (+1200) Subject: CRM-18214 Add link to detail report for contact merge activities, with oid if applicable X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=549cd4cacfdc125317aed4cdc957a55cac2e009f;p=civicrm-core.git CRM-18214 Add link to detail report for contact merge activities, with oid if applicable After merging all my other changes the only thing needed for the dedupe merge report was it to be linked from the summary report and to redirect after merge to the comparison of the 2 contacts, covered in this commit --- diff --git a/CRM/Logging/ReportDetail.php b/CRM/Logging/ReportDetail.php index 2e680da42c..afefe3926c 100644 --- a/CRM/Logging/ReportDetail.php +++ b/CRM/Logging/ReportDetail.php @@ -32,6 +32,15 @@ */ class CRM_Logging_ReportDetail extends CRM_Report_Form { protected $cid; + + /** + * Other contact ID. + * + * This would be set if we are viewing a merge of 2 contacts. + * + * @var int + */ + protected $oid; protected $db; protected $log_conn_id; protected $log_date; @@ -122,8 +131,10 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form { } /** - * @param $sql - * @param $rows + * Build rows from query. + * + * @param string $sql + * @param array $rows */ public function buildRows($sql, &$rows) { // safeguard for when there aren’t any log entries yet @@ -248,6 +259,9 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form { $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}"; + if ($this->oid) { + $q .= '&oid=' . $this->oid; + } $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 changes?')); } @@ -262,10 +276,8 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form { /** * Calculate all the contact related diffs for the change. - * - * @return array */ - protected function calculateContactDiffs(){ + protected function calculateContactDiffs() { $this->diffs = $this->getAllContactChangesForConnection(); } @@ -318,7 +330,18 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form { $reverter->revert(); CRM_Core_Session::setStatus(ts('The changes have been reverted.'), ts('Reverted'), 'success'); if ($this->cid) { - CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view', "reset=1&selectedChild=log&cid={$this->cid}", FALSE, NULL, FALSE)); + if ($this->oid) { + CRM_Utils_System::redirect(CRM_Utils_System::url( + 'civicrm/contact/merge', + "reset=1&cid={$this->cid}&oid={$this->oid}", + FALSE, + NULL, + FALSE) + ); + } + else { + CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view', "reset=1&selectedChild=log&cid={$this->cid}", FALSE, NULL, FALSE)); + } } else { CRM_Utils_System::redirect(CRM_Report_Utils_Report::getNextUrl($this->summary, 'reset=1', FALSE, TRUE)); diff --git a/CRM/Report/Form/Contact/LoggingSummary.php b/CRM/Report/Form/Contact/LoggingSummary.php index 17c0b3f832..d9e2dda032 100644 --- a/CRM/Report/Form/Contact/LoggingSummary.php +++ b/CRM/Report/Form/Contact/LoggingSummary.php @@ -203,6 +203,17 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary { $row['log_civicrm_entity_altered_contact'] = $row['log_civicrm_entity_altered_contact'] . " [{$entity}]"; } if ($entity == 'Contact Merged') { + $deletedID = CRM_Core_DAO::singleValueQuery(' + SELECT GROUP_CONCAT(contact_id) FROM civicrm_activity_contact ac + INNER JOIN civicrm_activity a + ON a.id = ac.activity_id AND a.parent_id = ' . $row['log_civicrm_entity_id'] . ' AND ac.record_type_id = + ' . CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_ActivityContact', 'record_type_id', 'Activity Targets') + ); + if ($deletedID && !stristr($deletedID, ',')) { + $baseQueryCriteria .= '&oid=' . $deletedID; + } + $row['log_civicrm_entity_log_action'] = ts('Contact Merge'); + $row = $this->addDetailReportLinksToRow($baseQueryCriteria, $row); $isMerge = 1; }