X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FLogging%2FDiffer.php;h=6111deba84c3b8a82dca01a5a5703598173fb19d;hb=c8950569c8c39745086e5a6c9df08b36441b5662;hp=04d9a00b2604b7d51e36e74a997e2d61b2417c5e;hpb=26cf88b561cc3ccdc7f9cbbed8dbc1bb06bd3dc1;p=civicrm-core.git diff --git a/CRM/Logging/Differ.php b/CRM/Logging/Differ.php index 04d9a00b26..6111deba84 100644 --- a/CRM/Logging/Differ.php +++ b/CRM/Logging/Differ.php @@ -73,7 +73,7 @@ class CRM_Logging_Differ { $contactIdClause = "AND id = %3"; break; case 'civicrm_note': - $contactIdClause = "AND ( entity_id = %3 AND entity_table = 'civicrm_contact' ) OR (entity_id IN (SELECT note.id FROM {$this->db}.log_civicrm_note note WHERE note.entity_id = %3 AND note.entity_table = 'civicrm_contact') AND entity_table = 'civicrm_note')"; + $contactIdClause = "AND ( entity_id = %3 AND entity_table = 'civicrm_contact' ) OR (entity_id IN (SELECT note.id FROM `{$this->db}`.log_civicrm_note note WHERE note.entity_id = %3 AND note.entity_table = 'civicrm_contact') AND entity_table = 'civicrm_note')"; break; case 'civicrm_entity_tag': $contactIdClause = "AND entity_id = %3 AND entity_table = 'civicrm_contact'"; @@ -82,7 +82,7 @@ class CRM_Logging_Differ { $contactIdClause = "AND (contact_id_a = %3 OR contact_id_b = %3)"; break; case 'civicrm_activity': - $activityContacts = CRM_Core_PseudoConstant::activityContacts('name'); + $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); @@ -106,10 +106,10 @@ LEFT JOIN civicrm_activity_contact source ON source.activity_id = lt.id AND sour // find ids in this table that were affected in the given connection (based on connection id and a ±10 s time period around the date) $sql = " -SELECT DISTINCT lt.id FROM `{$this->db}`.`log_$table` lt -{$join} -WHERE log_conn_id = %1 AND - log_date BETWEEN DATE_SUB(%2, INTERVAL {$this->interval}) AND DATE_ADD(%2, INTERVAL {$this->interval}) +SELECT DISTINCT lt.id FROM `{$this->db}`.`log_$table` lt +{$join} +WHERE log_conn_id = %1 AND + log_date BETWEEN DATE_SUB(%2, INTERVAL {$this->interval}) AND DATE_ADD(%2, INTERVAL {$this->interval}) {$contactIdClause}"; $dao = CRM_Core_DAO::executeQuery($sql, $params); @@ -159,7 +159,7 @@ WHERE log_conn_id = %1 AND $originalSQL = "SELECT * FROM `{$this->db}`.`log_$table` WHERE log_conn_id != %1 AND log_date < %2 AND id = %3 ORDER BY log_date DESC LIMIT 1"; $original = $this->sqlToArray($originalSQL, $params); if (empty($original)) { - // A blank original array is not possible for Update action, otherwise we 'll end up displaying all information + // A blank original array is not possible for Update action, otherwise we 'll end up displaying all information // in $changed variable as updated-info $original = $changed; } @@ -177,8 +177,8 @@ WHERE log_conn_id = %1 AND if (CRM_Utils_Array::value($diff, $original) === CRM_Utils_Array::value($diff, $changed)) { continue; } - - // hack: case_type_id column is a varchar with separator. For proper mapping to type labels, + + // hack: case_type_id column is a varchar with separator. For proper mapping to type labels, // we need to make sure separators are trimmed if ($diff == 'case_type_id') { foreach (array('original', 'changed') as $var) { @@ -229,25 +229,26 @@ WHERE log_conn_id = %1 AND if (in_array($table, array_keys($daos))) { // FIXME: these should be populated with pseudo constants as they // were at the time of logging rather than their current values + // FIXME: Use *_BAO:buildOptions() method rather than pseudoconstants & fetch programmatically $values[$table] = array( 'contribution_page_id' => CRM_Contribute_PseudoConstant::contributionPage(), 'contribution_status_id' => CRM_Contribute_PseudoConstant::contributionStatus(), 'financial_type_id' => CRM_Contribute_PseudoConstant::financialType(), 'country_id' => CRM_Core_PseudoConstant::country(), 'gender_id' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), - 'location_type_id' => CRM_Core_PseudoConstant::locationType(), + 'location_type_id' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'), 'payment_instrument_id' => CRM_Contribute_PseudoConstant::paymentInstrument(), - 'phone_type_id' => CRM_Core_PseudoConstant::phoneType(), - 'preferred_communication_method' => CRM_Core_PseudoConstant::pcm(), - 'preferred_language' => CRM_Core_PseudoConstant::languages(), - 'prefix_id' => CRM_Core_PseudoConstant::individualPrefix(), - 'provider_id' => CRM_Core_PseudoConstant::IMProvider(), + 'phone_type_id' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'), + 'preferred_communication_method' => CRM_Contact_BAO_Contact::buildOptions('preferred_communication_method'), + 'preferred_language' => CRM_Contact_BAO_Contact::buildOptions('preferred_language'), + 'prefix_id' => CRM_Contact_BAO_Contact::buildOptions('prefix_id'), + 'provider_id' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'), 'state_province_id' => CRM_Core_PseudoConstant::stateProvince(), - 'suffix_id' => CRM_Core_PseudoConstant::individualSuffix(), - 'website_type_id' => CRM_Core_PseudoConstant::websiteType(), + 'suffix_id' => CRM_Contact_BAO_Contact::buildOptions('suffix_id'), + 'website_type_id' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'), 'activity_type_id' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE), 'case_type_id' => CRM_Case_PseudoConstant::caseType('label', FALSE), - 'priority_id' => CRM_Core_PseudoConstant::priority(), + 'priority_id' => CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'), ); // for columns that appear in more than 1 table