Fix for CRM-12431
authorDeepak Srivastava <deepak.srivastava@webaccess.co.in>
Mon, 29 Apr 2013 10:51:37 +0000 (16:21 +0530)
committerDeepak Srivastava <deepak.srivastava@webaccess.co.in>
Mon, 29 Apr 2013 10:51:37 +0000 (16:21 +0530)
CRM/Logging/ReportSummary.php
CRM/Report/Form/Contact/LoggingSummary.php

index 8c002224aedb9278fec358a8251eb884c23204cd..6ab08cca6c941498c2a4079dd94bb0e706b3869e 100644 (file)
@@ -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',
index 7a112fad06992fbe9cbc65df2ecfb178cefe128c..e41d44d7dac6e91ccbae1e8a929623a9569b5da7 100644 (file)
@@ -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;