*
* Generated from xml/schema/CRM/Contact/Contact.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:b72765d873639076299753a8c4e676d5)
+ * (GenCodeChecksum:773bf2fc16c1af3c283f6ecc7098e927)
*/
/**
'size' => CRM_Utils_Type::BIG,
'where' => 'civicrm_contact.contact_type',
'export' => TRUE,
+ 'contactType' => NULL,
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
'headerPattern' => '/^first|(f(irst\s)?name)$/i',
'dataPattern' => '/^\w+$/',
'export' => TRUE,
+ 'contactType' => 'Individual',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
'headerPattern' => '/^middle|(m(iddle\s)?name)$/i',
'dataPattern' => '/^\w+$/',
'export' => TRUE,
+ 'contactType' => 'Individual',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
'headerPattern' => '/^last|(l(ast\s)?name)$/i',
'dataPattern' => '/^\w+(\s\w+)?+$/',
'export' => TRUE,
+ 'contactType' => 'Individual',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
'headerPattern' => '/^(prefix|title)/i',
'dataPattern' => '/^(mr|ms|mrs|sir|dr)\.?$/i',
'export' => TRUE,
+ 'contactType' => 'Individual',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
'headerPattern' => '/^suffix$/i',
'dataPattern' => '/^(sr|jr)\.?|i{2,}$/',
'export' => TRUE,
+ 'contactType' => 'Individual',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
'where' => 'civicrm_contact.formal_title',
'headerPattern' => '/^title/i',
'export' => TRUE,
+ 'contactType' => 'Individual',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
'headerPattern' => '/^job|(j(ob\s)?title)$/i',
'dataPattern' => '//',
'export' => TRUE,
+ 'contactType' => 'Individual',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
'where' => 'civicrm_contact.gender_id',
'headerPattern' => '/^gender$/i',
'export' => TRUE,
+ 'contactType' => 'Individual',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
'headerPattern' => '/^birth|(b(irth\s)?date)|D(\W*)O(\W*)B(\W*)$/i',
'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
'export' => TRUE,
+ 'contactType' => 'Individual',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
'where' => 'civicrm_contact.is_deceased',
'headerPattern' => '/i(s\s)?d(eceased)$/i',
'export' => TRUE,
+ 'contactType' => 'Individual',
'default' => '0',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'where' => 'civicrm_contact.deceased_date',
'headerPattern' => '/^deceased|(d(eceased\s)?date)$/i',
'export' => TRUE,
+ 'contactType' => 'Individual',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
'headerPattern' => '/^household|(h(ousehold\s)?name)$/i',
'dataPattern' => '/^\w+$/',
'export' => TRUE,
+ 'contactType' => 'Household',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
'title' => ts('Household Primary Contact ID'),
'description' => ts('Optional FK to Primary Contact for this household.'),
'where' => 'civicrm_contact.primary_contact_id',
+ 'contactType' => 'Household',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
'headerPattern' => '/^organization|(o(rganization\s)?name)$/i',
'dataPattern' => '/^\w+$/',
'export' => TRUE,
+ 'contactType' => 'Organization',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
'where' => 'civicrm_contact.sic_code',
'headerPattern' => '/^sic|(s(ic\s)?code)$/i',
'export' => TRUE,
+ 'contactType' => 'Organization',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
'description' => ts('OPTIONAL FK to civicrm_contact record.'),
'where' => 'civicrm_contact.employer_id',
'export' => TRUE,
+ 'contactType' => 'Individual',
'table_name' => 'civicrm_contact',
'entity' => 'Contact',
'bao' => 'CRM_Contact_BAO_Contact',
*/
class GetExtraFieldsTest extends UnitTestCase {
- public function testBAOFieldsWillBeReturned() {
- $returnedFields = Contact::getFields()
- ->execute()
- ->getArrayCopy();
+ public function testGetFieldsByContactType() {
+ $getFields = Contact::getFields()->setCheckPermissions(FALSE)->addSelect('name')->setIncludeCustom(FALSE);
- $baseFields = \CRM_Contact_BAO_Contact::fields();
- $baseFieldNames = array_column($baseFields, 'name');
- $returnedFieldNames = array_column($returnedFields, 'name');
- $notReturned = array_diff($baseFieldNames, $returnedFieldNames);
+ $baseFields = array_column(\CRM_Contact_BAO_Contact::fields(), 'name');
+ $returnedFields = $getFields->execute()->column('name');
+ $notReturned = array_diff($baseFields, $returnedFields);
+ // With no contact_type specified, all fields should be returned
$this->assertEmpty($notReturned);
+
+ $individualFields = $getFields->setValues(['contact_type' => 'Individual'])->execute()->column('name');
+ $this->assertNotContains('sic_code', $individualFields);
+ $this->assertNotContains('contact_type', $individualFields);
+ $this->assertContains('first_name', $individualFields);
+
+ $organizationFields = $getFields->setValues(['contact_type' => 'Organization'])->execute()->column('name');
+ $this->assertContains('sic_code', $organizationFields);
+ $this->assertNotContains('contact_type', $organizationFields);
+ $this->assertNotContains('first_name', $organizationFields);
+ $this->assertNotContains('household_name', $organizationFields);
}
}
</html>
<add>1.1</add>
<change>3.1</change>
+ <contactType>null</contactType>
</field>
<index>
<name>index_contact_type</name>
<fulltext/>
<comment>First Name.</comment>
<add>1.1</add>
+ <contactType>Individual</contactType>
</field>
<index>
<name>index_first_name</name>
<fulltext/>
<comment>Middle Name.</comment>
<add>1.1</add>
+ <contactType>Individual</contactType>
</field>
<field>
<name>last_name</name>
<comment>Last Name.</comment>
<fulltext/>
<add>1.1</add>
+ <contactType>Individual</contactType>
</field>
<index>
<name>index_last_name</name>
<dataPattern>/^(mr|ms|mrs|sir|dr)\.?$/i</dataPattern>
<import>true</import>
<add>1.2</add>
+ <contactType>Individual</contactType>
</field>
<index>
<name>UI_prefix</name>
<headerPattern>/^suffix$/i</headerPattern>
<dataPattern>/^(sr|jr)\.?|i{2,}$/</dataPattern>
<add>1.2</add>
+ <contactType>Individual</contactType>
</field>
<index>
<name>UI_suffix</name>
<headerPattern>/^title/i</headerPattern>
<comment>Formal (academic or similar) title in front of name. (Prof., Dr. etc.)</comment>
<add>4.5</add>
+ <contactType>Individual</contactType>
</field>
<field>
<name>communication_style_id</name>
<dataPattern>//</dataPattern>
<comment>Job Title</comment>
<add>1.1</add>
+ <contactType>Individual</contactType>
</field>
<field>
<name>gender_id</name>
<comment>FK to gender ID</comment>
<import>true</import>
<add>1.2</add>
+ <contactType>Individual</contactType>
</field>
<index>
<name>UI_gender</name>
<type>Select Date</type>
<formatType>birth</formatType>
</html>
+ <contactType>Individual</contactType>
</field>
<field>
<name>is_deceased</name>
<html>
<type>CheckBox</type>
</html>
+ <contactType>Individual</contactType>
</field>
<index>
<name>index_is_deceased</name>
<type>Select Date</type>
<formatType>birth</formatType>
</html>
+ <contactType>Individual</contactType>
</field>
<field>
<name>mail_to_household_id</name>
<comment>Household Name.</comment>
<fulltext/>
<add>1.1</add>
+ <contactType>Household</contactType>
</field>
<index>
<name>index_household_name</name>
<title>Household Primary Contact ID</title>
<comment>Optional FK to Primary Contact for this household.</comment>
<add>1.1</add>
+ <contactType>Household</contactType>
</field>
<foreignKey>
<name>primary_contact_id</name>
<comment>Organization Name.</comment>
<fulltext/>
<add>1.1</add>
+ <contactType>Organization</contactType>
</field>
<index>
<name>index_organization_name</name>
<html>
<type>Text</type>
</html>
+ <contactType>Organization</contactType>
</field>
<field>
<name>user_unique_id</name>
<html>
<type>EntityRef</type>
</html>
+ <contactType>Individual</contactType>
</field>
<foreignKey>
<name>employer_id</name>