diff --git a/CRM/Core/xml/Menu/Import.xml b/CRM/Core/xml/Menu/Import.xml
index 33d935c63421..affd37169b48 100644
--- a/CRM/Core/xml/Menu/Import.xml
+++ b/CRM/Core/xml/Menu/Import.xml
@@ -35,7 +35,7 @@
civicrm/import/custom
id=%%id%%
Import Multi-value Custom Data
- access CiviCRM
+ CRM_Custom_Import_Form_DataSource::isAvailable
1
CRM_Custom_Import_Controller
420
diff --git a/CRM/Custom/Import/Form/DataSource.php b/CRM/Custom/Import/Form/DataSource.php
index 71b2eb52b96d..3b6f9762a666 100644
--- a/CRM/Custom/Import/Form/DataSource.php
+++ b/CRM/Custom/Import/Form/DataSource.php
@@ -74,12 +74,24 @@ public function buildQuickForm() {
parent::buildQuickForm();
$multipleCustomData = CRM_Core_BAO_CustomGroup::getMultipleFieldGroup();
- $this->assign('fieldGroups', $multipleCustomData);
+ if (!$multipleCustomData) {
+ CRM_Core_Error::statusBounce(ts('This import screen cannot be used because there are no Multi-value custom data groups'));
+ }
$this->add('select', 'multipleCustomData', ts('Multi-value Custom Data'), ['' => ts('- select -')] + $multipleCustomData, TRUE);
-
+ // Assign an array of fields that are specific to this import to be included.
+ $this->assign('import_options', ['multipleCustomData']);
$this->addContactTypeSelector();
}
+ /**
+ * Is the custom data import available for use.
+ *
+ * @return bool
+ */
+ public static function isAvailable(): bool {
+ return CRM_Core_Permission::check('access CiviCRM') && CRM_Core_BAO_CustomGroup::getMultipleFieldGroup();
+ }
+
/**
* Process the uploaded file.
*
diff --git a/CRM/Import/Form/DataSource.php b/CRM/Import/Form/DataSource.php
index 19fea5947c19..1045acb08725 100644
--- a/CRM/Import/Form/DataSource.php
+++ b/CRM/Import/Form/DataSource.php
@@ -23,8 +23,12 @@ abstract class CRM_Import_Form_DataSource extends CRM_Import_Forms {
* Set variables up before form is built.
*/
public function preProcess() {
+ // Import options as an array of field names specific to the import
+ // (used by custom field import at time or writing) that will be included
+ // in the tpl.
+ $this->assign('import_options', []);
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
- $params = "reset=1";
+ $params = 'reset=1';
if ($this->_id) {
$params .= "&id={$this->_id}";
}
diff --git a/templates/CRM/Custom/Import/Form/DataSource.tpl b/templates/CRM/Custom/Import/Form/DataSource.tpl
index a5fde9dd84b6..5395b37fcf7f 100644
--- a/templates/CRM/Custom/Import/Form/DataSource.tpl
+++ b/templates/CRM/Custom/Import/Form/DataSource.tpl
@@ -7,71 +7,4 @@
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
-
-{* Import Wizard - Step 1 (choose data source) *}
-
+{include file="CRM/Import/Form/DataSource.tpl"}
diff --git a/templates/CRM/Import/Form/DataSource.tpl b/templates/CRM/Import/Form/DataSource.tpl
index b1b0308c7c06..b57fddb3d93d 100644
--- a/templates/CRM/Import/Form/DataSource.tpl
+++ b/templates/CRM/Import/Form/DataSource.tpl
@@ -34,27 +34,33 @@
- {if array_key_exists('contactType', $form)}
-
- {$form.contactType.label} |
- {$form.contactType.html}
-
+ {if array_key_exists('contactType', $form)}
+
+ {$form.contactType.label} |
+ {$form.contactType.html}
+
{ts 1=$importEntities}Select 'Individual' if you are importing %1 made by individual persons.{/ts}
- {ts 1=$importEntities}Select 'Organization' or 'Household' if you are importing %1 made by contacts of that type. (NOTE: Some built-in contact types may not be enabled for your site.){/ts}
+ {ts 1=$importEntities}Select 'Organization' or 'Household' if you are importing %1 made by contacts of that type. (NOTE: Some built-in contact types may not be enabled for your site.){/ts}
- |
-
- {/if}
- {if array_key_exists('onDuplicate', $form)}
-
- {$form.onDuplicate.label} |
- {$form.onDuplicate.html} {help id="id-onDuplicate"} |
-
- {/if}
-
- {$form.fieldSeparator.label} {help id='id-fieldSeparator' file='CRM/Contact/Import/Form/DataSource'} |
- {$form.fieldSeparator.html} |
-
+ |
+
+ {/if}
+ {foreach from=$import_options item=import_option}
+
+ {$form.$import_option.label} |
+ {$form.$import_option.html} |
+
+ {/foreach}
+ {if array_key_exists('onDuplicate', $form)}
+
+ {$form.onDuplicate.label} |
+ {$form.onDuplicate.html} {help id="id-onDuplicate"} |
+
+ {/if}
+
+ {$form.fieldSeparator.label} {help id='id-fieldSeparator' file='CRM/Contact/Import/Form/DataSource'} |
+ {$form.fieldSeparator.html} |
+
{include file="CRM/Core/Date.tpl"}
{if $savedMapping}