From d69fecb95b7b092e4ecb8712bacb1880b9cd77c4 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 18 Apr 2022 16:31:06 +1200 Subject: [PATCH] [REF] [Import] Obsolete if removal This if was left in in the last patch for readability --- CRM/Contact/Import/Form/DataSource.php | 97 +++++++++++++------------- 1 file changed, 48 insertions(+), 49 deletions(-) diff --git a/CRM/Contact/Import/Form/DataSource.php b/CRM/Contact/Import/Form/DataSource.php index 474cd4ca63..0377f23fdf 100644 --- a/CRM/Contact/Import/Form/DataSource.php +++ b/CRM/Contact/Import/Form/DataSource.php @@ -172,59 +172,58 @@ class CRM_Contact_Import_Form_DataSource extends CRM_Import_Forms { public function postProcess() { $this->controller->resetPage('MapField'); - if (1) { - // Setup the params array - $this->_params = $this->controller->exportValues($this->_name); - - $storeParams = [ - 'onDuplicate' => $this->exportValue('onDuplicate'), - 'dedupe' => $this->exportValue('dedupe'), - 'contactType' => $this->exportValue('contactType'), - 'contactSubType' => $this->exportValue('subType'), - 'dateFormats' => $this->exportValue('dateFormats'), - 'savedMapping' => $this->exportValue('savedMapping'), - ]; - - foreach ($storeParams as $storeName => $value) { - $this->set($storeName, $value); - } - $this->set('disableUSPS', !empty($this->_params['disableUSPS'])); + // Setup the params array + $this->_params = $this->controller->exportValues($this->_name); + + $storeParams = [ + 'onDuplicate' => $this->exportValue('onDuplicate'), + 'dedupe' => $this->exportValue('dedupe'), + 'contactType' => $this->exportValue('contactType'), + 'contactSubType' => $this->exportValue('subType'), + 'dateFormats' => $this->exportValue('dateFormats'), + 'savedMapping' => $this->exportValue('savedMapping'), + ]; - $this->set('dataSource', $this->getSubmittedValue('dataSource')); - $this->set('skipColumnHeader', CRM_Utils_Array::value('skipColumnHeader', $this->_params)); + foreach ($storeParams as $storeName => $value) { + $this->set($storeName, $value); + } + $this->set('disableUSPS', !empty($this->_params['disableUSPS'])); - CRM_Core_Session::singleton()->set('dateTypes', $storeParams['dateFormats']); + $this->set('dataSource', $this->getSubmittedValue('dataSource')); + $this->set('skipColumnHeader', CRM_Utils_Array::value('skipColumnHeader', $this->_params)); - //hack to prevent multiple tables. - $this->_params['import_table_name'] = $this->get('importTableName'); - if (!$this->_params['import_table_name']) { - $this->_params['import_table_name'] = 'civicrm_import_job_' . md5(uniqid(rand(), TRUE)); - } - $this->instantiateDataSource(); - - // We should have the data in the DB now, parse it - $importTableName = $this->get('importTableName'); - $fieldNames = $this->_prepareImportTable($importTableName); - $mapper = []; - - $parser = new CRM_Contact_Import_Parser_Contact($mapper); - $parser->setMaxLinesToProcess(100); - $parser->run($importTableName, - $mapper, - CRM_Import_Parser::MODE_MAPFIELD, - $storeParams['contactType'], - $fieldNames['pk'], - $fieldNames['status'], - CRM_Import_Parser::DUPLICATE_SKIP, - NULL, NULL, FALSE, - CRM_Contact_Import_Parser_Contact::DEFAULT_TIMEOUT, - $storeParams['contactSubType'], - $storeParams['dedupe'] - ); - - // add all the necessary variables to the form - $parser->set($this); + CRM_Core_Session::singleton()->set('dateTypes', $storeParams['dateFormats']); + + //hack to prevent multiple tables. + $this->_params['import_table_name'] = $this->get('importTableName'); + if (!$this->_params['import_table_name']) { + $this->_params['import_table_name'] = 'civicrm_import_job_' . md5(uniqid(rand(), TRUE)); } + $this->instantiateDataSource(); + + // We should have the data in the DB now, parse it + $importTableName = $this->get('importTableName'); + $fieldNames = $this->_prepareImportTable($importTableName); + $mapper = []; + + $parser = new CRM_Contact_Import_Parser_Contact($mapper); + $parser->setMaxLinesToProcess(100); + $parser->run($importTableName, + $mapper, + CRM_Import_Parser::MODE_MAPFIELD, + $storeParams['contactType'], + $fieldNames['pk'], + $fieldNames['status'], + CRM_Import_Parser::DUPLICATE_SKIP, + NULL, NULL, FALSE, + CRM_Contact_Import_Parser_Contact::DEFAULT_TIMEOUT, + $storeParams['contactSubType'], + $storeParams['dedupe'] + ); + + // add all the necessary variables to the form + $parser->set($this); + } /** -- 2.25.1