Save different type_id per import
authorEileen McNaughton <emcnaughton@wikimedia.org>
Sat, 4 Jun 2022 22:27:28 +0000 (10:27 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Sat, 4 Jun 2022 22:39:39 +0000 (10:39 +1200)
I left it as just contact to start with - but as I've gone further it's clear
we need a type for each import - best done now

CRM/Activity/Import/Form/DataSource.php
CRM/Contact/Import/Form/DataSource.php
CRM/Contribute/Import/Form/DataSource.php
CRM/Core/BAO/UserJob.php
CRM/Custom/Import/Form/DataSource.php
CRM/Event/Import/Form/DataSource.php
CRM/Import/Forms.php
CRM/Member/Import/Form/DataSource.php

index 103669bd61edf1b8fab2d23c91e9dd8b342df03c..ccb097e80a0247b2f7b0a80fb03be1713f7ebf40 100644 (file)
@@ -24,6 +24,15 @@ class CRM_Activity_Import_Form_DataSource extends CRM_Import_Form_DataSource {
 
   const IMPORT_ENTITY = 'Activity';
 
+  /**
+   * Get the name of the type to be stored in civicrm_user_job.type_id.
+   *
+   * @return string
+   */
+  public function getUserJobType(): string {
+    return 'activity_import';
+  }
+
   /**
    * @var bool
    */
index fb4c8dcbf5aa7410efa4566f99a2ebbaa342cf45..24baf8485d1b02625e7e46dc2bf74ebe43e30be6 100644 (file)
  */
 class CRM_Contact_Import_Form_DataSource extends CRM_Import_Form_DataSource {
 
+  /**
+   * Get the name of the type to be stored in civicrm_user_job.type_id.
+   *
+   * @return string
+   */
+  public function getUserJobType(): string {
+    return 'contact_import';
+  }
+
   /**
    * Get any smarty elements that may not be present in the form.
    *
index 1a6c307fac9d303c441d1c2a62f1b7f9c45b3238..36ef3c98845e8667bbf8fe6f71396c4f2198cf84 100644 (file)
@@ -24,6 +24,15 @@ class CRM_Contribute_Import_Form_DataSource extends CRM_Import_Form_DataSource {
 
   const IMPORT_ENTITY = 'Contribution';
 
+  /**
+   * Get the name of the type to be stored in civicrm_user_job.type_id.
+   *
+   * @return string
+   */
+  public function getUserJobType(): string {
+    return 'contribution_import';
+  }
+
   /**
    * Build the form object.
    */
index a8cafe65d721dfca77dc80f5a3685fcd12f3aad5..7802f4a4ba32761df2c51b919c4b7b82daa866dc 100644 (file)
@@ -86,6 +86,37 @@ class CRM_Core_BAO_UserJob extends CRM_Core_DAO_UserJob {
         'id' => 1,
         'name' => 'contact_import',
         'label' => ts('Contact Import'),
+        'class' => 'CRM_Contact_Import_Parser_Contact',
+      ],
+      [
+        'id' => 2,
+        'name' => 'contribution_import',
+        'label' => ts('Contribution Import'),
+        'class' => 'CRM_Contribute_Import_Parser_Contribution',
+      ],
+      [
+        'id' => 3,
+        'name' => 'membership_import',
+        'label' => ts('Membership Import'),
+        'class' => 'CRM_Member_Import_Parser_Membership',
+      ],
+      [
+        'id' => 4,
+        'name' => 'activity_import',
+        'label' => ts('Activity Import'),
+        'class' => 'CRM_Activity_Import_Parser_Activity',
+      ],
+      [
+        'id' => 5,
+        'name' => 'participant_import',
+        'label' => ts('Participant Import'),
+        'class' => 'CRM_Event_Import_Parser_Participant',
+      ],
+      [
+        'id' => 6,
+        'name' => 'custom_field_import',
+        'label' => ts('Multiple Value Custom Field Import'),
+        'class' => 'CRM_Custom_Import_Parser_Api',
       ],
     ];
   }
index 71b2eb52b96d0f9ab6fbac567e79cb2a31c5c061..1032e422a63eb23c92dd8a1985c5af4ef630a4ad 100644 (file)
@@ -24,6 +24,15 @@ class CRM_Custom_Import_Form_DataSource extends CRM_Import_Form_DataSource {
 
   const IMPORT_ENTITY = 'Multi value custom data';
 
+  /**
+   * Get the name of the type to be stored in civicrm_user_job.type_id.
+   *
+   * @return string
+   */
+  public function getUserJobType(): string {
+    return 'custom_field_import';
+  }
+
   /**
    * Get the import entity (translated).
    *
index 93f8812909948dd9ba83b9cc2df5d662dea223a0..3d96f26535a13f8916d4466c906645a7edf03023 100644 (file)
@@ -24,6 +24,15 @@ class CRM_Event_Import_Form_DataSource extends CRM_Import_Form_DataSource {
 
   const IMPORT_ENTITY = 'Participant';
 
+  /**
+   * Get the name of the type to be stored in civicrm_user_job.type_id.
+   *
+   * @return string
+   */
+  public function getUserJobType(): string {
+    return 'participant_import';
+  }
+
   /**
    * Build the form object.
    *
index e87bc5acb7478830c4b6d73cd0a1dc001563c9ad..cd81aa4585f96471974edacf10b71bd26c218b80 100644 (file)
@@ -376,7 +376,7 @@ class CRM_Import_Forms extends CRM_Core_Form {
     $id = UserJob::create(FALSE)
       ->setValues([
         'created_id' => CRM_Core_Session::getLoggedInContactID(),
-        'type_id:name' => 'contact_import',
+        'type_id:name' => $this->getUserJobType(),
         'status_id:name' => 'draft',
         // This suggests the data could be cleaned up after this.
         'expires_date' => '+ 1 week',
index 0e91fb36c42a8bb1fa5ee1f5098fa5f479d9f580..dc0c10f7c466f3114d21d6d4a7b4548825ea1b06 100644 (file)
@@ -24,6 +24,15 @@ class CRM_Member_Import_Form_DataSource extends CRM_Import_Form_DataSource {
 
   const IMPORT_ENTITY = 'Membership';
 
+  /**
+   * Get the name of the type to be stored in civicrm_user_job.type_id.
+   *
+   * @return string
+   */
+  public function getUserJobType(): string {
+    return 'membership_import';
+  }
+
   /**
    * Build the form object.
    *