From 9c097caf2734530f30c4afc9abcdecdcc29cfd26 Mon Sep 17 00:00:00 2001 From: Deepak Srivastava Date: Mon, 29 Apr 2013 16:21:37 +0530 Subject: [PATCH] Fix for CRM-12431 --- CRM/Logging/ReportSummary.php | 27 ++++++++++++---------- CRM/Report/Form/Contact/LoggingSummary.php | 17 +++++++------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/CRM/Logging/ReportSummary.php b/CRM/Logging/ReportSummary.php index 8c002224ae..6ab08cca6c 100644 --- a/CRM/Logging/ReportSummary.php +++ b/CRM/Logging/ReportSummary.php @@ -160,19 +160,22 @@ class CRM_Logging_ReportSummary extends CRM_Report_Form { function postProcess() { $this->beginPostProcess(); $rows = array(); + + $tempColumns = "id int(10)"; + if (CRM_Utils_Array::value('log_action', $this->_params['fields'])) { + $tempColumns .= ", log_action varchar(64)"; + } + $tempColumns .= ", log_type varchar(64), log_user_id int(10), log_date timestamp"; + if (CRM_Utils_Array::value('altered_contact', $this->_params['fields'])) { + $tempColumns .= ", altered_contact varchar(128)"; + } + $tempColumns .= ", altered_contact_id int(10), log_conn_id int(11), is_deleted tinyint(4)"; + if (CRM_Utils_Array::value('display_name', $this->_params['fields'])) { + $tempColumns .= ", display_name varchar(128)"; + } + // temp table to hold all altered contact-ids - $sql = " -CREATE TEMPORARY TABLE - civicrm_temp_civireport_logsummary ( id int(10), - log_action varchar(64), - log_type varchar(64), - log_user_id int(10), - log_date timestamp, - altered_contact varchar(128), - altered_contact_id int(10), - log_conn_id int(11), - is_deleted tinyint(4), - display_name varchar(128) ) ENGINE=HEAP"; + $sql = "CREATE TEMPORARY TABLE civicrm_temp_civireport_logsummary ( {$tempColumns} ) ENGINE=HEAP"; CRM_Core_DAO::executeQuery($sql); $logDateClause = $this->dateClause('log_date', diff --git a/CRM/Report/Form/Contact/LoggingSummary.php b/CRM/Report/Form/Contact/LoggingSummary.php index 7a112fad06..e41d44d7da 100644 --- a/CRM/Report/Form/Contact/LoggingSummary.php +++ b/CRM/Report/Form/Contact/LoggingSummary.php @@ -162,7 +162,8 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary { CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $row['log_civicrm_entity_altered_contact_id'], 'is_deleted') !== '0'; } - if (!$isDeleted[$row['log_civicrm_entity_altered_contact_id']]) { + if (CRM_Utils_Array::value($row, 'log_civicrm_entity_altered_contact') && + !$isDeleted[$row['log_civicrm_entity_altered_contact_id']]) { $row['log_civicrm_entity_altered_contact_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $row['log_civicrm_entity_altered_contact_id']); $row['log_civicrm_entity_altered_contact_hover'] = ts("Go to contact summary"); @@ -173,7 +174,7 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary { $row['altered_by_contact_display_name_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $row['log_civicrm_entity_log_user_id']); $row['altered_by_contact_display_name_hover'] = ts("Go to contact summary"); - if ($row['log_civicrm_entity_is_deleted'] and $row['log_civicrm_entity_log_action'] == 'Update') { + if ($row['log_civicrm_entity_is_deleted'] and 'Update' == CRM_Utils_Array::value($row, 'log_civicrm_entity_log_action')) { $row['log_civicrm_entity_log_action'] = ts('Delete (to trash)'); } @@ -182,18 +183,18 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary { $row['log_civicrm_entity_log_action'] = ts('Update'); } - if ($newAction = - $this->getEntityAction($row['log_civicrm_entity_id'], - $row['log_civicrm_entity_log_conn_id'], - $row['log_civicrm_entity_log_type'], - $row['log_civicrm_entity_log_action'])) + if (CRM_Utils_Array::value($row, 'log_civicrm_entity_log_action') && + $newAction = $this->getEntityAction($row['log_civicrm_entity_id'], + $row['log_civicrm_entity_log_conn_id'], + $row['log_civicrm_entity_log_type'], + $row['log_civicrm_entity_log_action'])) $row['log_civicrm_entity_log_action'] = $newAction; $row['log_civicrm_entity_log_type'] = $this->getLogType($row['log_civicrm_entity_log_type']); $date = CRM_Utils_Date::isoToMysql($row['log_civicrm_entity_log_date']); - if ($row['log_civicrm_entity_log_action'] == 'Update') { + if ('Update' == CRM_Utils_Array::value($row, 'log_civicrm_entity_log_action')) { $q = "reset=1&log_conn_id={$row['log_civicrm_entity_log_conn_id']}&log_date=". $date; if ($this->cid) { $q .= '&cid=' . $this->cid; -- 2.25.1