Add import labels fixes that I figured out doing memberhsip
authorEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 3 Jun 2022 03:23:29 +0000 (15:23 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 3 Jun 2022 22:26:10 +0000 (10:26 +1200)
Importantly do_not_import should be added

CRM/Contribute/Import/Form/MapField.php
CRM/Upgrade/Incremental/php/FiveFiftyOne.php

index 78e6a869d8b18122f47005a2dccba902d0f58baf..8c24947a2bd448a4526f95ed57644f9256853d10 100644 (file)
@@ -433,7 +433,7 @@ class CRM_Contribute_Import_Form_MapField extends CRM_Import_Form_MapField {
       if (isset($mapperKeys[$i][0]) && $mapperKeys[$i][0] == 'soft_credit') {
         $mapperSoftCredit[$i] = $mapperKeys[$i][1];
         if (strpos($mapperSoftCredit[$i], '_') !== FALSE) {
-          list($first, $second) = explode('_', $mapperSoftCredit[$i]);
+          [$first, $second] = explode('_', $mapperSoftCredit[$i]);
           $softCreditFields[$i] = ucwords($first . " " . $second);
         }
         else {
index fe10b78e63308ec6f84bc654d05416076bcf8187..3de256e0ff4b5b9a9b9651fc67e06afbbc16acca 100644 (file)
@@ -71,6 +71,7 @@ class CRM_Upgrade_Incremental_php_FiveFiftyOne extends CRM_Upgrade_Incremental_B
    * @throws \API_Exception
    */
   public static function convertMappingFieldLabelsToNames(): bool {
+    // Contribution fields....
     $mappings = MappingField::get(FALSE)
       ->setSelect(['id', 'name'])
       ->addWhere('mapping_id.mapping_type_id:name', '=', 'Import Contribution')
@@ -79,12 +80,16 @@ class CRM_Upgrade_Incremental_php_FiveFiftyOne extends CRM_Upgrade_Incremental_B
     $fieldMap = [];
     foreach ($fields as $fieldName => $field) {
       $fieldMap[$field['title']] = $fieldName;
+      if (!empty($field['html']['label'])) {
+        $fieldMap[$field['html']['label']] = $fieldName;
+      }
     }
     $fieldMap[ts('Soft Credit')] = 'soft_credit';
     $fieldMap[ts('Pledge Payment')] = 'pledge_payment';
     $fieldMap[ts(ts('Pledge ID'))] = 'pledge_id';
     $fieldMap[ts(ts('Financial Type'))] = 'financial_type_id';
     $fieldMap[ts(ts('Payment Method'))] = 'payment_instrument_id';
+    $fieldMap[ts('- do not import -')] = 'do_not_import';
 
     foreach ($mappings as $mapping) {
       if (!empty($fieldMap[$mapping['name']])) {