*
* @param string $contactSubType
*/
- public function setContactSubType(string $contactSubType) {
- $this->contactSubType = $contactSubType;
+ public function setContactSubType($contactSubType) {
+ $this->contactSubType = (string) $contactSubType;
}
/**
}
/**
+ * Get the contact type for the import.
+ *
* @return string
*/
public function getContactType(): string {
}
/**
+ * Set mapping fields.
+ *
+ * We do a little cleanup here too.
+ *
+ * We ensure that column numbers are set and that the fields are ordered by them.
+ *
+ * This would mean the fields could be loaded unsorted.
+ *
* @param array $mappingFields
*/
public function setMappingFields(array $mappingFields) {
+ $i = 0;
+ foreach ($mappingFields as &$mappingField) {
+ if (!isset($mappingField['column_number'])) {
+ $mappingField['column_number'] = $i;
+ }
+ if ($mappingField['column_number'] > $i) {
+ $i = $mappingField['column_number'];
+ }
+ $i++;
+ }
$this->mappingFields = $this->rekeyBySortedColumnNumbers($mappingFields);
}
}
else {
// Honour legacy chaos factor.
+ if ($field['name'] === ts('- do not import -')) {
+ // This is why we save names not labels people....
+ $field['name'] = 'do_not_import';
+ }
$fields[$index]['name'] = strtolower(str_replace(" ", "_", $field['name']));
// fix for edge cases, CRM-4954
if ($fields[$index]['name'] === 'image_url') {
*/
public function getQuickFormJSForField($column) {
$columnNumbersToHide = [];
- if ($this->getRelationshipKey($column)) {
+ if ($this->getFieldName($column) === 'do_not_import') {
+ $columnNumbersToHide = [1, 2, 3];
+ }
+ elseif ($this->getRelationshipKey($column)) {
if (!$this->getWebsiteTypeID($column) && !$this->getLocationTypeID($column)) {
$columnNumbersToHide[] = 2;
}
* @throws \CiviCRM_API3_Exception
*/
public function getSavedQuickformDefaultsForColumn($column) {
+ if ($this->getFieldName($column) === 'do_not_import') {
+ return [];
+ }
if ($this->getValidRelationshipKey($column)) {
if ($this->getWebsiteTypeID($column)) {
return [$this->getValidRelationshipKey($column), $this->getFieldName($column), $this->getWebsiteTypeID($column)];