diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index a392f89ac969..22f0238c64c3 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -1384,54 +1384,15 @@ public static function importableFields( $withMultiCustomFields ) ); - //unset the fields, which are not related to their - //contact type. - $commonValues = [ - 'Individual' => [ - 'household_name', - 'legal_name', - 'sic_code', - 'organization_name', - ], - 'Household' => [ - 'first_name', - 'middle_name', - 'last_name', - 'formal_title', - 'job_title', - 'gender_id', - 'prefix_id', - 'suffix_id', - 'birth_date', - 'organization_name', - 'legal_name', - 'legal_identifier', - 'sic_code', - 'home_URL', - 'is_deceased', - 'deceased_date', - ], - 'Organization' => [ - 'first_name', - 'middle_name', - 'last_name', - 'formal_title', - 'job_title', - 'gender_id', - 'prefix_id', - 'suffix_id', - 'birth_date', - 'household_name', - 'is_deceased', - 'deceased_date', - ], - ]; - foreach ($commonValues[$contactType] as $value) { - unset($fields[$value]); + // Unset the fields which are not related to their contact type. + foreach (CRM_Contact_DAO_Contact::import() as $name => $value) { + if (!empty($value['contactType']) && $value['contactType'] !== $contactType) { + unset($fields[$name]); + } } } else { - foreach (['Individual', 'Household', 'Organization'] as $type) { + foreach (CRM_Contact_BAO_ContactType::basicTypes() as $type) { $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($type, $showAll, @@ -1604,7 +1565,7 @@ public static function &exportableFields($contactType = 'Individual', $status = ); } else { - foreach (['Individual', 'Household', 'Organization'] as $type) { + foreach (CRM_Contact_BAO_ContactType::basicTypes() as $type) { $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($type, FALSE, FALSE, $search, $checkPermissions, $withMultiRecord) ); diff --git a/CRM/Contact/DAO/Contact.php b/CRM/Contact/DAO/Contact.php index 99405af76c36..e4135fe7e2a0 100644 --- a/CRM/Contact/DAO/Contact.php +++ b/CRM/Contact/DAO/Contact.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Contact/Contact.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:773bf2fc16c1af3c283f6ecc7098e927) + * (GenCodeChecksum:4b1e2ef9f5c431f59befcc000cb35577) */ /** @@ -688,6 +688,7 @@ public static function &fields() { 'where' => 'civicrm_contact.legal_name', 'headerPattern' => '/^legal|(l(egal\s)?name)$/i', 'export' => TRUE, + 'contactType' => 'Organization', 'table_name' => 'civicrm_contact', 'entity' => 'Contact', 'bao' => 'CRM_Contact_BAO_Contact', diff --git a/xml/schema/Contact/Contact.xml b/xml/schema/Contact/Contact.xml index 262358eaf1c9..28a2ee98f704 100644 --- a/xml/schema/Contact/Contact.xml +++ b/xml/schema/Contact/Contact.xml @@ -238,7 +238,7 @@ Text 30 - + Organization true /^legal|(l(egal\s)?name)$/i Legal Name.