CRM-13344 - Individual/Pseudoconstant - Fix prefix/suffix
authorColeman Watts <coleman@civicrm.org>
Tue, 8 Oct 2013 12:04:31 +0000 (13:04 +0100)
committerColeman Watts <coleman@civicrm.org>
Tue, 8 Oct 2013 21:06:29 +0000 (22:06 +0100)
----------------------------------------
* 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
CRM/Core/PseudoConstant.php
CRM/Dedupe/BAO/RuleGroup.php
CRM/Dedupe/Finder.php

index a9978bd8ab3ec849edfa19bcd4cc8931d981e71c..165c69be62cbac95fc8982d6e7fd990f057c49a7 100644 (file)
@@ -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);
           }
         }
       }
index 218b3d9debce074a9268548035183de344c1f1f6..1a2630d3beebe313b587a8a3e9104c4d1ed4684f 100644 (file)
@@ -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])) {
index b520606c4ee0efb939eda181269979fcb33efc94..8ca95614b0bc70d39266031648537143ec80f17c 100644 (file)
@@ -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'])) {
index 1ad4023d553bc6cf8955ff1a5b63aa873cd3b552..62af0e5e0d3bd6b41f5548e9e677b1d6ea4c474b 100644 (file)
@@ -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]);