From 8b253b95558b30e097e82cd252c3531e0d56dd58 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 16 Mar 2023 17:34:16 +1300 Subject: [PATCH] Deprecated buildSavedMappingFields noisily This function was only being used from one place & was only separate from that function because the Contact DataSource form used to call it directly. That is no longer true so I've coped the code into the calling function & added noisy deprecation, with a view to remove --- CRM/Import/Form/MapField.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/CRM/Import/Form/MapField.php b/CRM/Import/Form/MapField.php index 3406aaf6d0..456be759fb 100644 --- a/CRM/Import/Form/MapField.php +++ b/CRM/Import/Form/MapField.php @@ -136,6 +136,7 @@ abstract class CRM_Import_Form_MapField extends CRM_Import_Forms { * @throws \CRM_Core_Exception */ protected function buildSavedMappingFields($savedMappingID) { + CRM_Core_Error::deprecatedFunctionWarning('addSavedMappingFields'); //to save the current mappings if (!$savedMappingID) { $saveDetailsName = ts('Save this field mapping'); @@ -364,7 +365,29 @@ abstract class CRM_Import_Form_MapField extends CRM_Import_Forms { */ protected function addSavedMappingFields(): void { $savedMappingID = $this->getSavedMappingID(); - $this->buildSavedMappingFields($savedMappingID); + //to save the current mappings + if (!$savedMappingID) { + $saveDetailsName = ts('Save this field mapping'); + $this->applyFilter('saveMappingName', 'trim'); + $this->add('text', 'saveMappingName', ts('Name')); + $this->add('text', 'saveMappingDesc', ts('Description')); + } + else { + // @todo we should stop doing this - the passed in value should be fine, confirmed OK in contact import. + $savedMapping = $this->get('savedMapping'); + $mappingName = (string) civicrm_api3('Mapping', 'getvalue', ['id' => $savedMappingID, 'return' => 'name']); + // @todo - this should go too - used when going back to the DataSource form but it should + // access the job. + $this->set('loadedMapping', $savedMapping); + $this->add('hidden', 'mappingId', $savedMapping); + + $this->addElement('checkbox', 'updateMapping', ts('Update this field mapping'), NULL); + $saveDetailsName = ts('Save as a new field mapping'); + $this->add('text', 'saveMappingName', ts('Name')); + $this->add('text', 'saveMappingDesc', ts('Description')); + } + $this->assign('savedMappingName', $mappingName ?? NULL); + $this->addElement('checkbox', 'saveMapping', $saveDetailsName, NULL); $this->addFormRule(['CRM_Import_Form_MapField', 'mappingRule']); } -- 2.25.1