X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FImport%2FForms.php;h=cd81aa4585f96471974edacf10b71bd26c218b80;hb=c4a6ea3f4397aeec5ec3705ac3dbf73e3845772c;hp=6c61172567b3ea50fd81b406cfa7f9dab2a3b854;hpb=941983b542df8b5311f3b57f55e51de930a38483;p=civicrm-core.git diff --git a/CRM/Import/Forms.php b/CRM/Import/Forms.php index 6c61172567..cd81aa4585 100644 --- a/CRM/Import/Forms.php +++ b/CRM/Import/Forms.php @@ -137,7 +137,10 @@ class CRM_Import_Forms extends CRM_Core_Form { if ($fieldName === 'dataSource') { // Hard-coded handling for DataSource as it affects the contents of // getSubmittableFields and can cause a loop. - return $this->controller->exportValue('DataSource', 'dataSource'); + // Note that the non-contact imports are not currently sharing the DataSource.tpl + // that adds the CSV/SQL options & hence fall back on this hidden field. + // - todo - switch to the same DataSource.tpl for all. + return $this->controller->exportValue('DataSource', 'dataSource') ?? $this->controller->exportValue('DataSource', 'hidden_dataSource'); } $mappedValues = $this->getSubmittableFields(); if (array_key_exists($fieldName, $mappedValues)) { @@ -373,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', @@ -586,4 +589,53 @@ class CRM_Import_Forms extends CRM_Core_Form { return $mapper; } + /** + * Assign variables required for the MapField form. + * + * @throws \API_Exception + * @throws \CRM_Core_Exception + */ + protected function assignMapFieldVariables(): void { + $this->addExpectedSmartyVariable('highlightedRelFields'); + $this->_columnCount = $this->getNumberOfColumns(); + $this->_columnNames = $this->getColumnHeaders(); + $this->_dataValues = array_values($this->getDataRows([], 2)); + $this->assign('columnNames', $this->getColumnHeaders()); + $this->assign('highlightedFields', $this->getHighlightedFields()); + $this->assign('columnCount', $this->_columnCount); + $this->assign('dataValues', $this->_dataValues); + } + + /** + * Get the fields to be highlighted in the UI. + * + * The highlighted fields are those used to match + * to an existing entity. + * + * @return array + * + * @throws \CRM_Core_Exception + */ + protected function getHighlightedFields(): array { + return []; + } + + /** + * Get the data patterns to pattern match the incoming data. + * + * @return array + */ + public function getDataPatterns(): array { + return $this->getParser()->getDataPatterns(); + } + + /** + * Get the data patterns to pattern match the incoming data. + * + * @return array + */ + public function getHeaderPatterns(): array { + return $this->getParser()->getHeaderPatterns(); + } + }