code clean / fixes CRM-14429
authorkurund <kurund@civicrm.org>
Wed, 16 Apr 2014 02:11:40 +0000 (19:11 -0700)
committerkurund <kurund@civicrm.org>
Wed, 16 Apr 2014 02:11:40 +0000 (19:11 -0700)
----------------------------------------
* CRM-14429: Contact import fails silently on lookup of custom field option values by label
  https://issues.civicrm.org/jira/browse/CRM-14429

CRM/Contact/Import/Parser/Contact.php

index 60ea53b99f1cd2f8c0d9d7df78817e9df4c7b672..2ac24f27cdaeeb750841d9a84bd8a5630b52bd5a 100644 (file)
@@ -1953,6 +1953,22 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
         $extends = CRM_Utils_Array::value('extends', $customFields[$customFieldID]);
         $htmlType = CRM_Utils_Array::value( 'html_type', $customFields[$customFieldID] );
         switch ( $htmlType ) {
+        case 'Select':
+        case 'Radio':
+        case 'Autocomplete-Select':
+          if ($customFields[$customFieldID]['data_type'] == 'String') {
+            $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE);
+            foreach ($customOption as $customFldID => $customValue) {
+              $val = CRM_Utils_Array::value('value', $customValue);
+              $label = CRM_Utils_Array::value('label', $customValue);
+              $label = strtolower($label);
+              $value = strtolower(trim($formatted[$key]));
+              if (($value == $label) || ($value == strtolower($val))) {
+                $params[$key] = $formatted[$key] = $val;
+              }
+            }
+          }
+          break;
         case 'CheckBox':
         case 'AdvMulti-Select':
         case 'Multi-Select':