Merge pull request #12306 from JO0st/dev-core-166
[civicrm-core.git] / CRM / Utils / Migrate / Import.php
index 8a9cf99e74f8d0bdd0fc8d4868afb9ead7cac9d1..dc9e24419ae308b18ed25461a38c41b010c7adba 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
+ | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2018                                |
  +--------------------------------------------------------------------+
@@ -242,6 +242,15 @@ WHERE      v.option_group_id = %1
             elseif (in_array($customGroup->extends, array('Individual', 'Organization', 'Household'))) {
               $valueIDs = $optionValues;
             }
+            elseif (in_array($customGroup->extends, array('Contribution', 'ContributionRecur'))) {
+              $sql = "SELECT id
+                      FROM civicrm_financial_type
+                      WHERE name IN ('{$optValues}')";
+              $dao = &CRM_Core_DAO::executeQuery($sql);
+              while ($dao->fetch()) {
+                $valueIDs[] = $dao->id;
+              }
+            }
             else {
               $sql = "
 SELECT     v.value
@@ -352,10 +361,10 @@ AND        v.name = %1
         $fields_indexed_by_group_id[$id][] = $customFieldXML;
       }
     }
-    while (list($group_id, $fields) = each($fields_indexed_by_group_id)) {
+    foreach ($fields_indexed_by_group_id as $group_id => $fields) {
       $total = count($fields);
       $count = 0;
-      while (list(, $customFieldXML) = each($fields)) {
+      foreach ($fields as $customFieldXML) {
         $count++;
         $customField = new CRM_Core_DAO_CustomField();
         $customField->custom_group_id = $group_id;