else {
$savedMapping = $this->get('savedMapping');
- list($mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType, $mappingImProvider, $mappingRelation) = CRM_Core_BAO_Mapping::getMappingFields($savedMapping, TRUE);
+ list($mappingName) = CRM_Core_BAO_Mapping::getMappingFields($savedMapping, TRUE);
//get loaded Mapping Fields
$mappingName = CRM_Utils_Array::value(1, $mappingName);
- $mappingRelation = CRM_Utils_Array::value(1, $mappingRelation);
$this->assign('loadedMapping', $savedMapping);
$this->set('loadedMapping', $savedMapping);
$processor->setMappingID($savedMappingID);
$processor->setFormName($formName);
$processor->setMetadata($this->getContactImportMetadata());
+ $processor->setContactTypeByConstant($this->get('contactType'));
for ($i = 0; $i < $this->_columnCount; $i++) {
$sel = &$this->addElement('hierselect', "mapper[$i]", ts('Mapper for Field %1', [1 => $i]), NULL);
if ($this->get('savedMapping')) {
- list($defaults, $js) = $this->loadSavedMapping($processor, $mappingName, $i, $mappingRelation, $defaults, $js, $hasColumnNames, $dataPatterns, $columnPatterns);
+ list($defaults, $js) = $this->loadSavedMapping($processor, $mappingName, $i, $defaults, $js, $hasColumnNames, $dataPatterns, $columnPatterns);
}
else {
$js .= "swapOptions($formName, 'mapper[$i]', 0, 3, 'hs_mapper_0_');\n";
* @param \CRM_Import_ImportProcessor $processor
* @param $mappingName
* @param int $i
- * @param array $mappingRelation
* @param array $defaults
* @param string $js
* @param bool $hasColumnNames
* @return array
* @throws \CiviCRM_API3_Exception
*/
- public function loadSavedMapping($processor, $mappingName, $i, $mappingRelation, $defaults, $js, $hasColumnNames, $dataPatterns, $columnPatterns) {
+ public function loadSavedMapping($processor, $mappingName, $i, $defaults, $js, $hasColumnNames, $dataPatterns, $columnPatterns) {
$jsSet = FALSE;
$formName = $processor->getFormName();
if (isset($mappingName[$i])) {
if ($mappingName[$i] != ts('- do not import -')) {
- if (isset($mappingRelation[$i])) {
- // relationship mapping
- switch ($this->get('contactType')) {
- case CRM_Import_Parser::CONTACT_INDIVIDUAL:
- $contactType = 'Individual';
- break;
-
- case CRM_Import_Parser::CONTACT_HOUSEHOLD:
- $contactType = 'Household';
- break;
-
- case CRM_Import_Parser::CONTACT_ORGANIZATION:
- $contactType = 'Organization';
- }
+ if ($processor->getRelationshipKey($i)) {
+ $contactType = $processor->getContactType();
//CRM-5125
$contactSubType = NULL;
if ($this->get('contactSubType')) {
);
foreach ($relations as $key => $var) {
- if ($key == $mappingRelation[$i]) {
- $relation = $key;
+ if ($processor->getValidRelationshipKey($i)) {
+ $relation = $processor->getValidRelationshipKey($i);
break;
}
}
['name' => 'Website', 'contact_type' => 'Individual', 'column_number' => 0, 'website_type_id'],
"document.forms.MapField['mapper[0][1]'].style.display = 'none';
document.forms.MapField['mapper[0][2]'].style.display = 'none';
+document.forms.MapField['mapper[0][3]'].style.display = 'none';\n",
+ ],
+ [
+ // Yes, the relationship mapping really does use url whereas non relationship uses website because... legacy
+ ['name' => 'Url', 'contact_type' => 'Individual', 'column_number' => 0, 'website_type_id', 'relationship_type_id' => 1, 'relationship_direction' => 'a_b'],
+ "document.forms.MapField['mapper[0][2]'].style.display = 'none';
document.forms.MapField['mapper[0][3]'].style.display = 'none';\n",
],
];
* @throws \CiviCRM_API3_Exception
*/
protected function loadSavedMapping($form, $mappingID, $columnNumber) {
- list($mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType, $mappingImProvider, $mappingRelation, $mappingOperator, $mappingValue, $mappingWebsiteType) = CRM_Core_BAO_Mapping::getMappingFields($mappingID, TRUE);
+ list($mappingName) = CRM_Core_BAO_Mapping::getMappingFields($mappingID, TRUE);
//get loaded Mapping Fields
$mappingName = CRM_Utils_Array::value(1, $mappingName);
- $mappingLocation = CRM_Utils_Array::value(1, $mappingLocation);
- $mappingPhoneType = CRM_Utils_Array::value(1, $mappingPhoneType);
- $mappingImProvider = CRM_Utils_Array::value(1, $mappingImProvider);
- $mappingRelation = CRM_Utils_Array::value(1, $mappingRelation);
- $mappingWebsiteType = CRM_Utils_Array::value(1, $mappingWebsiteType);
$defaults = [];
$js = '';
$processor->setMappingID($mappingID);
$processor->setFormName('document.forms.MapField');
$processor->setMetadata($this->getContactImportMetadata());
+ $processor->setContactTypeByConstant(CRM_Import_Parser::CONTACT_INDIVIDUAL);
- $return = $form->loadSavedMapping($processor, $mappingName, $columnNumber, $mappingRelation, $defaults, $js, $hasColumnNames, $dataPatterns, $columnPatterns);
+ $return = $form->loadSavedMapping($processor, $mappingName, $columnNumber, $defaults, $js, $hasColumnNames, $dataPatterns, $columnPatterns);
return ['defaults' => $return[0], 'js' => $return[1]];
}