From 309a09df4010bda77e097152f52caa4ee7fdb987 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 8 Oct 2013 13:04:31 +0100 Subject: [PATCH] CRM-13344 - Individual/Pseudoconstant - Fix prefix/suffix ---------------------------------------- * CRM-13344: Resolve test / schema issues around prefix_id, suffix_id, gender http://issues.civicrm.org/jira/browse/CRM-13344 --- CRM/Contact/BAO/Individual.php | 13 ++++--------- CRM/Core/PseudoConstant.php | 2 +- CRM/Dedupe/BAO/RuleGroup.php | 3 +-- CRM/Dedupe/Finder.php | 5 ++--- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/CRM/Contact/BAO/Individual.php b/CRM/Contact/BAO/Individual.php index a9978bd8ab..165c69be62 100644 --- a/CRM/Contact/BAO/Individual.php +++ b/CRM/Contact/BAO/Individual.php @@ -136,32 +136,27 @@ class CRM_Contact_BAO_Individual extends CRM_Contact_DAO_Contact { } foreach (array('prefix', 'suffix') as $name) { - $phpName = $name; $dbName = "{$name}_id"; - $vals = "{$name}es"; $value = $individual->$dbName; if (in_array($name, $useDBNames)) { $params[$dbName] = $value; $contact->$dbName = $value; if ($value) { - $temp = $$vals; - $$phpName = $temp[$value]; + $$name = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', $name, $value); } else { - $$phpName = NULL; + $$name = NULL; } } elseif (array_key_exists($dbName, $params)) { - $temp = $$vals; // CRM-5278 if (!empty($params[$dbName])) { - $$phpName = CRM_Utils_Array::value($params[$dbName], $temp); + $$name = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', $dbName, $params[$dbName]); } } elseif ($value) { - $temp = $$vals; - $$phpName = $temp[$value]; + $$name = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', $name, $value); } } } diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index 218b3d9deb..1a2630d3be 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -283,7 +283,7 @@ class CRM_Core_PseudoConstant { // Support "unique names" as well as sql names $fieldKey = $fieldName; if (empty($fields[$fieldKey])) { - $fieldKey = $fieldKeys[$fieldName]; + $fieldKey = CRM_Utils_Array::value($fieldName, $fieldKeys); } // If neither worked then this field doesn't exist. Return false. if (empty($fields[$fieldKey])) { diff --git a/CRM/Dedupe/BAO/RuleGroup.php b/CRM/Dedupe/BAO/RuleGroup.php index b520606c4e..8ca95614b0 100644 --- a/CRM/Dedupe/BAO/RuleGroup.php +++ b/CRM/Dedupe/BAO/RuleGroup.php @@ -82,8 +82,7 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { 'civicrm_im', 'civicrm_note', 'civicrm_openid', 'civicrm_phone', ); - foreach (array( - 'Individual', 'Organization', 'Household') as $ctype) { + foreach (array('Individual', 'Organization', 'Household') as $ctype) { // take the table.field pairs and their titles from importableFields() if the table is supported foreach (CRM_Contact_BAO_Contact::importableFields($ctype) as $iField) { if (isset($iField['where'])) { diff --git a/CRM/Dedupe/Finder.php b/CRM/Dedupe/Finder.php index 1ad4023d55..62af0e5e0d 100644 --- a/CRM/Dedupe/Finder.php +++ b/CRM/Dedupe/Finder.php @@ -201,14 +201,13 @@ class CRM_Dedupe_Finder { $flat = array(); CRM_Utils_Array::flatten($fields, $flat); + // FIXME: This may no longer be necessary - check inputs $replace_these = array( 'individual_prefix' => 'prefix_id', 'individual_suffix' => 'suffix_id', 'gender' => 'gender_id', ); - //handle for individual_suffix, individual_prefix, gender - foreach (array( - 'individual_suffix', 'individual_prefix', 'gender') as $name) { + foreach (array('individual_suffix', 'individual_prefix', 'gender') as $name) { if (CRM_Utils_Array::value($name, $fields)) { $flat[$replace_these[$name]] = $flat[$name]; unset($flat[$name]); -- 2.25.1