*/
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;
}
/**
- * @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
$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?'));
}
/**
* Calculate all the contact related diffs for the change.
- *
- * @return array
*/
- protected function calculateContactDiffs(){
+ protected function calculateContactDiffs() {
$this->diffs = $this->getAllContactChangesForConnection();
}
$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));
$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;
}