From f398c92fc7138a71a922dd1f41bfd63ee71cd9f2 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 6 Apr 2023 16:57:04 +1200 Subject: [PATCH 1/2] Re-order Contact fields in table,DAO --- CRM/Contact/DAO/Contact.php | 610 ++++++++++++++++----------------- xml/schema/Contact/Contact.xml | 274 +++++++-------- 2 files changed, 442 insertions(+), 442 deletions(-) diff --git a/CRM/Contact/DAO/Contact.php b/CRM/Contact/DAO/Contact.php index 9353b0ce2cb3..339c3e0b494f 100644 --- a/CRM/Contact/DAO/Contact.php +++ b/CRM/Contact/DAO/Contact.php @@ -74,6 +74,33 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO { */ public $contact_type; + /** + * Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations. + * + * @var string|null + * (SQL type: varchar(64)) + * Note that values will be retrieved from the database as a string. + */ + public $external_identifier; + + /** + * Formatted name representing preferred format for display/print/other output. + * + * @var string|null + * (SQL type: varchar(128)) + * Note that values will be retrieved from the database as a string. + */ + public $display_name; + + /** + * Organization Name. + * + * @var string|null + * (SQL type: varchar(128)) + * Note that values will be retrieved from the database as a string. + */ + public $organization_name; + /** * May be used to over-ride contact view and edit templates. * @@ -83,6 +110,33 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO { */ public $contact_sub_type; + /** + * First Name. + * + * @var string|null + * (SQL type: varchar(64)) + * Note that values will be retrieved from the database as a string. + */ + public $first_name; + + /** + * Middle Name. + * + * @var string|null + * (SQL type: varchar(64)) + * Note that values will be retrieved from the database as a string. + */ + public $middle_name; + + /** + * Last Name. + * + * @var string|null + * (SQL type: varchar(64)) + * Note that values will be retrieved from the database as a string. + */ + public $last_name; + /** * @var bool|string * (SQL type: tinyint) @@ -136,15 +190,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO { */ public $legal_identifier; - /** - * Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations. - * - * @var string|null - * (SQL type: varchar(64)) - * Note that values will be retrieved from the database as a string. - */ - public $external_identifier; - /** * Name used for sorting different contact types * @@ -154,15 +199,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO { */ public $sort_name; - /** - * Formatted name representing preferred format for display/print/other output. - * - * @var string|null - * (SQL type: varchar(128)) - * Note that values will be retrieved from the database as a string. - */ - public $display_name; - /** * Nickname. * @@ -208,16 +244,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO { */ public $preferred_language; - /** - * Deprecated setting for text vs html mailings - * - * @var string|null - * (SQL type: varchar(8)) - * Note that values will be retrieved from the database as a string. - * @deprecated - */ - public $preferred_mail_format; - /** * Key for validating requests related to this contact. * @@ -245,33 +271,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO { */ public $source; - /** - * First Name. - * - * @var string|null - * (SQL type: varchar(64)) - * Note that values will be retrieved from the database as a string. - */ - public $first_name; - - /** - * Middle Name. - * - * @var string|null - * (SQL type: varchar(64)) - * Note that values will be retrieved from the database as a string. - */ - public $middle_name; - - /** - * Last Name. - * - * @var string|null - * (SQL type: varchar(64)) - * Note that values will be retrieved from the database as a string. - */ - public $last_name; - /** * Prefix or Title for name (Ms, Mr...). FK to prefix ID * @@ -450,15 +449,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO { */ public $primary_contact_id; - /** - * Organization Name. - * - * @var string|null - * (SQL type: varchar(128)) - * Note that values will be retrieved from the database as a string. - */ - public $organization_name; - /** * Standard Industry Classification Code. * @@ -512,6 +502,16 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO { */ public $modified_date; + /** + * Deprecated setting for text vs html mailings + * + * @var string|null + * (SQL type: varchar(8)) + * Note that values will be retrieved from the database as a string. + * @deprecated + */ + public $preferred_mail_format; + /** * Class constructor. */ @@ -622,6 +622,88 @@ public static function &fields() { 'readonly' => TRUE, 'add' => '1.1', ], + 'external_identifier' => [ + 'name' => 'external_identifier', + 'type' => CRM_Utils_Type::T_STRING, + 'title' => ts('External Identifier'), + 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'), + 'maxlength' => 64, + 'size' => 8, + 'usage' => [ + 'import' => TRUE, + 'export' => TRUE, + 'duplicate_matching' => TRUE, + 'token' => FALSE, + ], + 'import' => TRUE, + 'where' => 'civicrm_contact.external_identifier', + 'headerPattern' => '/external\s?id/i', + 'dataPattern' => '/^\d{11,}$/', + 'export' => TRUE, + 'table_name' => 'civicrm_contact', + 'entity' => 'Contact', + 'bao' => 'CRM_Contact_BAO_Contact', + 'localizable' => 0, + 'html' => [ + 'type' => 'Text', + 'label' => ts("External Identifier"), + ], + 'add' => '1.1', + ], + 'display_name' => [ + 'name' => 'display_name', + 'type' => CRM_Utils_Type::T_STRING, + 'title' => ts('Display Name'), + 'description' => ts('Formatted name representing preferred format for display/print/other output.'), + 'maxlength' => 128, + 'size' => 30, + 'usage' => [ + 'import' => FALSE, + 'export' => TRUE, + 'duplicate_matching' => FALSE, + 'token' => FALSE, + ], + 'where' => 'civicrm_contact.display_name', + 'export' => TRUE, + 'table_name' => 'civicrm_contact', + 'entity' => 'Contact', + 'bao' => 'CRM_Contact_BAO_Contact', + 'localizable' => 0, + 'html' => [ + 'type' => 'Text', + ], + 'readonly' => TRUE, + 'add' => '1.1', + ], + 'organization_name' => [ + 'name' => 'organization_name', + 'type' => CRM_Utils_Type::T_STRING, + 'title' => ts('Organization Name'), + 'description' => ts('Organization Name.'), + 'maxlength' => 128, + 'size' => 30, + 'usage' => [ + 'import' => TRUE, + 'export' => TRUE, + 'duplicate_matching' => TRUE, + 'token' => FALSE, + ], + 'import' => TRUE, + 'where' => 'civicrm_contact.organization_name', + 'headerPattern' => '/^organization|(o(rganization\s)?name)$/i', + 'dataPattern' => '/^\w+$/', + 'export' => TRUE, + 'contactType' => 'Organization', + 'table_name' => 'civicrm_contact', + 'entity' => 'Contact', + 'bao' => 'CRM_Contact_BAO_Contact', + 'localizable' => 0, + 'html' => [ + 'type' => 'Text', + 'label' => ts("Organization Name"), + ], + 'add' => '1.1', + ], 'contact_sub_type' => [ 'name' => 'contact_sub_type', 'type' => CRM_Utils_Type::T_STRING, @@ -656,6 +738,93 @@ public static function &fields() { ], 'add' => '1.5', ], + 'first_name' => [ + 'name' => 'first_name', + 'type' => CRM_Utils_Type::T_STRING, + 'title' => ts('First Name'), + 'description' => ts('First Name.'), + 'maxlength' => 64, + 'size' => 30, + 'usage' => [ + 'import' => TRUE, + 'export' => TRUE, + 'duplicate_matching' => TRUE, + 'token' => FALSE, + ], + 'import' => TRUE, + 'where' => 'civicrm_contact.first_name', + 'headerPattern' => '/^first|(f(irst\s)?name)$/i', + 'dataPattern' => '/^\w+$/', + 'export' => TRUE, + 'contactType' => 'Individual', + 'table_name' => 'civicrm_contact', + 'entity' => 'Contact', + 'bao' => 'CRM_Contact_BAO_Contact', + 'localizable' => 0, + 'html' => [ + 'type' => 'Text', + 'label' => ts("First Name"), + ], + 'add' => '1.1', + ], + 'middle_name' => [ + 'name' => 'middle_name', + 'type' => CRM_Utils_Type::T_STRING, + 'title' => ts('Middle Name'), + 'description' => ts('Middle Name.'), + 'maxlength' => 64, + 'size' => 30, + 'usage' => [ + 'import' => TRUE, + 'export' => TRUE, + 'duplicate_matching' => TRUE, + 'token' => FALSE, + ], + 'import' => TRUE, + 'where' => 'civicrm_contact.middle_name', + 'headerPattern' => '/^middle|(m(iddle\s)?name)$/i', + 'dataPattern' => '/^\w+$/', + 'export' => TRUE, + 'contactType' => 'Individual', + 'table_name' => 'civicrm_contact', + 'entity' => 'Contact', + 'bao' => 'CRM_Contact_BAO_Contact', + 'localizable' => 0, + 'html' => [ + 'type' => 'Text', + 'label' => ts("Middle Name"), + ], + 'add' => '1.1', + ], + 'last_name' => [ + 'name' => 'last_name', + 'type' => CRM_Utils_Type::T_STRING, + 'title' => ts('Last Name'), + 'description' => ts('Last Name.'), + 'maxlength' => 64, + 'size' => 30, + 'usage' => [ + 'import' => TRUE, + 'export' => TRUE, + 'duplicate_matching' => TRUE, + 'token' => FALSE, + ], + 'import' => TRUE, + 'where' => 'civicrm_contact.last_name', + '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', + 'localizable' => 0, + 'html' => [ + 'type' => 'Text', + 'label' => ts("Last Name"), + ], + 'add' => '1.1', + ], 'do_not_email' => [ 'name' => 'do_not_email', 'type' => CRM_Utils_Type::T_BOOLEAN, @@ -823,70 +992,17 @@ public static function &fields() { 'title' => ts('Legal Identifier'), 'description' => ts('May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.'), 'maxlength' => 32, - 'size' => CRM_Utils_Type::MEDIUM, - 'usage' => [ - 'import' => TRUE, - 'export' => TRUE, - 'duplicate_matching' => TRUE, - 'token' => FALSE, - ], - 'import' => TRUE, - 'where' => 'civicrm_contact.legal_identifier', - 'headerPattern' => '/legal\s?id/i', - 'dataPattern' => '/\w+?\d{5,}/', - 'export' => TRUE, - 'table_name' => 'civicrm_contact', - 'entity' => 'Contact', - 'bao' => 'CRM_Contact_BAO_Contact', - 'localizable' => 0, - 'html' => [ - 'type' => 'Text', - 'label' => ts("Legal Identifier"), - ], - 'add' => '1.1', - ], - 'external_identifier' => [ - 'name' => 'external_identifier', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('External Identifier'), - 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'), - 'maxlength' => 64, - 'size' => 8, - 'usage' => [ - 'import' => TRUE, - 'export' => TRUE, - 'duplicate_matching' => TRUE, - 'token' => FALSE, - ], - 'import' => TRUE, - 'where' => 'civicrm_contact.external_identifier', - 'headerPattern' => '/external\s?id/i', - 'dataPattern' => '/^\d{11,}$/', - 'export' => TRUE, - 'table_name' => 'civicrm_contact', - 'entity' => 'Contact', - 'bao' => 'CRM_Contact_BAO_Contact', - 'localizable' => 0, - 'html' => [ - 'type' => 'Text', - 'label' => ts("External Identifier"), - ], - 'add' => '1.1', - ], - 'sort_name' => [ - 'name' => 'sort_name', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Sort Name'), - 'description' => ts('Name used for sorting different contact types'), - 'maxlength' => 128, - 'size' => 30, + 'size' => CRM_Utils_Type::MEDIUM, 'usage' => [ - 'import' => FALSE, + 'import' => TRUE, 'export' => TRUE, - 'duplicate_matching' => FALSE, + 'duplicate_matching' => TRUE, 'token' => FALSE, ], - 'where' => 'civicrm_contact.sort_name', + 'import' => TRUE, + 'where' => 'civicrm_contact.legal_identifier', + 'headerPattern' => '/legal\s?id/i', + 'dataPattern' => '/\w+?\d{5,}/', 'export' => TRUE, 'table_name' => 'civicrm_contact', 'entity' => 'Contact', @@ -894,15 +1010,15 @@ public static function &fields() { 'localizable' => 0, 'html' => [ 'type' => 'Text', + 'label' => ts("Legal Identifier"), ], - 'readonly' => TRUE, 'add' => '1.1', ], - 'display_name' => [ - 'name' => 'display_name', + 'sort_name' => [ + 'name' => 'sort_name', 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Display Name'), - 'description' => ts('Formatted name representing preferred format for display/print/other output.'), + 'title' => ts('Sort Name'), + 'description' => ts('Name used for sorting different contact types'), 'maxlength' => 128, 'size' => 30, 'usage' => [ @@ -911,7 +1027,7 @@ public static function &fields() { 'duplicate_matching' => FALSE, 'token' => FALSE, ], - 'where' => 'civicrm_contact.display_name', + 'where' => 'civicrm_contact.sort_name', 'export' => TRUE, 'table_name' => 'civicrm_contact', 'entity' => 'Contact', @@ -1065,36 +1181,6 @@ public static function &fields() { ], 'add' => '3.2', ], - 'preferred_mail_format' => [ - 'name' => 'preferred_mail_format', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Preferred Mail Format'), - 'description' => ts('Deprecated setting for text vs html mailings'), - 'maxlength' => 8, - 'size' => CRM_Utils_Type::EIGHT, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_contact.preferred_mail_format', - 'headerPattern' => '/^p(ref\w*\s)?m(ail\s)?f(orm\w*)$/i', - 'default' => 'Both', - 'table_name' => 'civicrm_contact', - 'entity' => 'Contact', - 'bao' => 'CRM_Contact_BAO_Contact', - 'localizable' => 0, - 'deprecated' => TRUE, - 'html' => [ - 'type' => 'Select', - 'label' => ts("Preferred Mail Format"), - ], - 'pseudoconstant' => [ - 'callback' => 'CRM_Core_SelectValues::pmf', - ], - 'add' => '1.1', - ], 'hash' => [ 'name' => 'hash', 'type' => CRM_Utils_Type::T_STRING, @@ -1173,93 +1259,6 @@ public static function &fields() { ], 'add' => '1.1', ], - 'first_name' => [ - 'name' => 'first_name', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('First Name'), - 'description' => ts('First Name.'), - 'maxlength' => 64, - 'size' => 30, - 'usage' => [ - 'import' => TRUE, - 'export' => TRUE, - 'duplicate_matching' => TRUE, - 'token' => FALSE, - ], - 'import' => TRUE, - 'where' => 'civicrm_contact.first_name', - 'headerPattern' => '/^first|(f(irst\s)?name)$/i', - 'dataPattern' => '/^\w+$/', - 'export' => TRUE, - 'contactType' => 'Individual', - 'table_name' => 'civicrm_contact', - 'entity' => 'Contact', - 'bao' => 'CRM_Contact_BAO_Contact', - 'localizable' => 0, - 'html' => [ - 'type' => 'Text', - 'label' => ts("First Name"), - ], - 'add' => '1.1', - ], - 'middle_name' => [ - 'name' => 'middle_name', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Middle Name'), - 'description' => ts('Middle Name.'), - 'maxlength' => 64, - 'size' => 30, - 'usage' => [ - 'import' => TRUE, - 'export' => TRUE, - 'duplicate_matching' => TRUE, - 'token' => FALSE, - ], - 'import' => TRUE, - 'where' => 'civicrm_contact.middle_name', - 'headerPattern' => '/^middle|(m(iddle\s)?name)$/i', - 'dataPattern' => '/^\w+$/', - 'export' => TRUE, - 'contactType' => 'Individual', - 'table_name' => 'civicrm_contact', - 'entity' => 'Contact', - 'bao' => 'CRM_Contact_BAO_Contact', - 'localizable' => 0, - 'html' => [ - 'type' => 'Text', - 'label' => ts("Middle Name"), - ], - 'add' => '1.1', - ], - 'last_name' => [ - 'name' => 'last_name', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Last Name'), - 'description' => ts('Last Name.'), - 'maxlength' => 64, - 'size' => 30, - 'usage' => [ - 'import' => TRUE, - 'export' => TRUE, - 'duplicate_matching' => TRUE, - 'token' => FALSE, - ], - 'import' => TRUE, - 'where' => 'civicrm_contact.last_name', - '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', - 'localizable' => 0, - 'html' => [ - 'type' => 'Text', - 'label' => ts("Last Name"), - ], - 'add' => '1.1', - ], 'prefix_id' => [ 'name' => 'prefix_id', 'type' => CRM_Utils_Type::T_INT, @@ -1789,35 +1788,6 @@ public static function &fields() { 'readonly' => TRUE, 'add' => '1.1', ], - 'organization_name' => [ - 'name' => 'organization_name', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Organization Name'), - 'description' => ts('Organization Name.'), - 'maxlength' => 128, - 'size' => 30, - 'usage' => [ - 'import' => TRUE, - 'export' => TRUE, - 'duplicate_matching' => TRUE, - 'token' => FALSE, - ], - 'import' => TRUE, - 'where' => 'civicrm_contact.organization_name', - 'headerPattern' => '/^organization|(o(rganization\s)?name)$/i', - 'dataPattern' => '/^\w+$/', - 'export' => TRUE, - 'contactType' => 'Organization', - 'table_name' => 'civicrm_contact', - 'entity' => 'Contact', - 'bao' => 'CRM_Contact_BAO_Contact', - 'localizable' => 0, - 'html' => [ - 'type' => 'Text', - 'label' => ts("Organization Name"), - ], - 'add' => '1.1', - ], 'sic_code' => [ 'name' => 'sic_code', 'type' => CRM_Utils_Type::T_STRING, @@ -1980,6 +1950,36 @@ public static function &fields() { 'readonly' => TRUE, 'add' => '4.3', ], + 'preferred_mail_format' => [ + 'name' => 'preferred_mail_format', + 'type' => CRM_Utils_Type::T_STRING, + 'title' => ts('Preferred Mail Format'), + 'description' => ts('Deprecated setting for text vs html mailings'), + 'maxlength' => 8, + 'size' => CRM_Utils_Type::EIGHT, + 'usage' => [ + 'import' => FALSE, + 'export' => FALSE, + 'duplicate_matching' => FALSE, + 'token' => FALSE, + ], + 'where' => 'civicrm_contact.preferred_mail_format', + 'headerPattern' => '/^p(ref\w*\s)?m(ail\s)?f(orm\w*)$/i', + 'default' => 'Both', + 'table_name' => 'civicrm_contact', + 'entity' => 'Contact', + 'bao' => 'CRM_Contact_BAO_Contact', + 'localizable' => 0, + 'deprecated' => TRUE, + 'html' => [ + 'type' => 'Select', + 'label' => ts("Preferred Mail Format"), + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::pmf', + ], + 'add' => '1.1', + ], ]; CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); } @@ -2058,6 +2058,23 @@ public static function indices($localize = TRUE) { 'localizable' => FALSE, 'sig' => 'civicrm_contact::0::contact_type', ], + 'UI_external_identifier' => [ + 'name' => 'UI_external_identifier', + 'field' => [ + 0 => 'external_identifier', + ], + 'localizable' => FALSE, + 'unique' => TRUE, + 'sig' => 'civicrm_contact::1::external_identifier', + ], + 'index_organization_name' => [ + 'name' => 'index_organization_name', + 'field' => [ + 0 => 'organization_name', + ], + 'localizable' => FALSE, + 'sig' => 'civicrm_contact::0::organization_name', + ], 'index_contact_sub_type' => [ 'name' => 'index_contact_sub_type', 'field' => [ @@ -2066,14 +2083,21 @@ public static function indices($localize = TRUE) { 'localizable' => FALSE, 'sig' => 'civicrm_contact::0::contact_sub_type', ], - 'UI_external_identifier' => [ - 'name' => 'UI_external_identifier', + 'index_first_name' => [ + 'name' => 'index_first_name', 'field' => [ - 0 => 'external_identifier', + 0 => 'first_name', ], 'localizable' => FALSE, - 'unique' => TRUE, - 'sig' => 'civicrm_contact::1::external_identifier', + 'sig' => 'civicrm_contact::0::first_name', + ], + 'index_last_name' => [ + 'name' => 'index_last_name', + 'field' => [ + 0 => 'last_name', + ], + 'localizable' => FALSE, + 'sig' => 'civicrm_contact::0::last_name', ], 'index_sort_name' => [ 'name' => 'index_sort_name', @@ -2107,22 +2131,6 @@ public static function indices($localize = TRUE) { 'localizable' => FALSE, 'sig' => 'civicrm_contact::0::api_key', ], - 'index_first_name' => [ - 'name' => 'index_first_name', - 'field' => [ - 0 => 'first_name', - ], - 'localizable' => FALSE, - 'sig' => 'civicrm_contact::0::first_name', - ], - 'index_last_name' => [ - 'name' => 'index_last_name', - 'field' => [ - 0 => 'last_name', - ], - 'localizable' => FALSE, - 'sig' => 'civicrm_contact::0::last_name', - ], 'UI_prefix' => [ 'name' => 'UI_prefix', 'field' => [ @@ -2171,14 +2179,6 @@ public static function indices($localize = TRUE) { 'localizable' => FALSE, 'sig' => 'civicrm_contact::0::household_name', ], - 'index_organization_name' => [ - 'name' => 'index_organization_name', - 'field' => [ - 0 => 'organization_name', - ], - 'localizable' => FALSE, - 'sig' => 'civicrm_contact::0::organization_name', - ], 'index_is_deleted_sort_name' => [ 'name' => 'index_is_deleted_sort_name', 'field' => [ diff --git a/xml/schema/Contact/Contact.xml b/xml/schema/Contact/Contact.xml index 59078d8361b0..569d40e025be 100644 --- a/xml/schema/Contact/Contact.xml +++ b/xml/schema/Contact/Contact.xml @@ -60,6 +60,64 @@ contact_type 2.1 + + external_identifier + varchar + 64 + + Text + 8 + + + + true + /external\s?id/i + /^\d{11,}$/ + Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations. + 1.1 + + + UI_external_identifier + true + external_identifier + 1.7 + + + display_name + Display Name + varchar + 128 + + Text + 30 + + true + true + Formatted name representing preferred format for display/print/other output. + 1.1 + + + organization_name + varchar + 128 + + Text + 30 + + + true + /^organization|(o(rganization\s)?name)$/i + /^\w+$/ + Organization Name. + + 1.1 + Organization + + + index_organization_name + organization_name + 1.8 + contact_sub_type Contact Subtype @@ -88,6 +146,67 @@ contact_sub_type 2.1 + + first_name + varchar + 64 + + Text + 30 + + + true + /^first|(f(irst\s)?name)$/i + /^\w+$/ + + First Name. + 1.1 + Individual + + + index_first_name + first_name + 1.8 + + + middle_name + varchar + 64 + + Text + 30 + + + true + /^middle|(m(iddle\s)?name)$/i + /^\w+$/ + + Middle Name. + 1.1 + Individual + + + last_name + varchar + 64 + + Text + 30 + + + true + /^last|(l(ast\s)?name)$/i + /^\w+(\s\w+)?+$/ + Last Name. + + 1.1 + Individual + + + index_last_name + last_name + 1.8 + do_not_email boolean @@ -187,28 +306,6 @@ - - external_identifier - varchar - 64 - - Text - 8 - - - - true - /external\s?id/i - /^\d{11,}$/ - Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations. - 1.1 - - - UI_external_identifier - true - external_identifier - 1.7 - sort_name Sort Name @@ -228,20 +325,6 @@ sort_name 2.1 - - display_name - Display Name - varchar - 128 - - Text - 30 - - true - true - Formatted name representing preferred format for display/print/other output. - 1.1 - nick_name Nickname @@ -328,24 +411,6 @@ 3.2 - - preferred_mail_format - varchar - 8 - "Both" - false - /^p(ref\w*\s)?m(ail\s)?f(orm\w*)$/i - Deprecated setting for text vs html mailings - 1.1 - - CRM_Core_SelectValues::pmf - - - Select - - - true - hash Contact Hash @@ -397,67 +462,6 @@ where contact come from, e.g. import, donate module insert... 1.1 - - first_name - varchar - 64 - - Text - 30 - - - true - /^first|(f(irst\s)?name)$/i - /^\w+$/ - - First Name. - 1.1 - Individual - - - index_first_name - first_name - 1.8 - - - middle_name - varchar - 64 - - Text - 30 - - - true - /^middle|(m(iddle\s)?name)$/i - /^\w+$/ - - Middle Name. - 1.1 - Individual - - - last_name - varchar - 64 - - Text - 30 - - - true - /^last|(l(ast\s)?name)$/i - /^\w+(\s\w+)?+$/ - Last Name. - - 1.1 - Individual - - - index_last_name - last_name - 1.8 - prefix_id Individual Prefix @@ -775,28 +779,6 @@ 1.1 SET NULL - - organization_name - varchar - 128 - - Text - 30 - - - true - /^organization|(o(rganization\s)?name)$/i - /^\w+$/ - Organization Name. - - 1.1 - Organization - - - index_organization_name - organization_name - 1.8 - sic_code varchar @@ -909,4 +891,22 @@ modified_date 5.18 + + preferred_mail_format + varchar + 8 + "Both" + false + /^p(ref\w*\s)?m(ail\s)?f(orm\w*)$/i + Deprecated setting for text vs html mailings + 1.1 + + CRM_Core_SelectValues::pmf + + + Select + + + true + From 44f39c51044e3dee1b6c6c760e03d352cf72bfbe Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 7 Apr 2023 12:07:19 +1200 Subject: [PATCH 2/2] Fix tests for re-ordering --- tests/phpunit/CRM/Contact/SelectorTest.php | 12 ++-- tests/phpunit/CRM/Export/BAO/ExportTest.php | 72 +++++++++++---------- 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/tests/phpunit/CRM/Contact/SelectorTest.php b/tests/phpunit/CRM/Contact/SelectorTest.php index f1b5423e8ee3..afec67da8088 100644 --- a/tests/phpunit/CRM/Contact/SelectorTest.php +++ b/tests/phpunit/CRM/Contact/SelectorTest.php @@ -472,7 +472,7 @@ public function querySets(): array { 'includeContactIds' => NULL, 'searchDescendentGroups' => FALSE, 'expected_query' => [ - 0 => 'SELECT contact_a.id as contact_id, contact_a.contact_type as `contact_type`, contact_a.contact_sub_type as `contact_sub_type`, contact_a.sort_name as `sort_name`, contact_a.display_name as `display_name`, contact_a.do_not_email as `do_not_email`, contact_a.do_not_phone as `do_not_phone`, contact_a.do_not_mail as `do_not_mail`, contact_a.do_not_sms as `do_not_sms`, contact_a.do_not_trade as `do_not_trade`, contact_a.is_opt_out as `is_opt_out`, contact_a.legal_identifier as `legal_identifier`, contact_a.external_identifier as `external_identifier`, contact_a.nick_name as `nick_name`, contact_a.legal_name as `legal_name`, contact_a.image_URL as `image_URL`, contact_a.preferred_communication_method as `preferred_communication_method`, contact_a.preferred_language as `preferred_language`, contact_a.first_name as `first_name`, contact_a.middle_name as `middle_name`, contact_a.last_name as `last_name`, contact_a.prefix_id as `prefix_id`, contact_a.suffix_id as `suffix_id`, contact_a.formal_title as `formal_title`, contact_a.communication_style_id as `communication_style_id`, contact_a.job_title as `job_title`, contact_a.gender_id as `gender_id`, contact_a.birth_date as `birth_date`, contact_a.is_deceased as `is_deceased`, contact_a.deceased_date as `deceased_date`, contact_a.household_name as `household_name`, IF ( contact_a.contact_type = \'Individual\', NULL, contact_a.organization_name ) as organization_name, contact_a.sic_code as `sic_code`, contact_a.is_deleted as `contact_is_deleted`, IF ( contact_a.contact_type = \'Individual\', contact_a.organization_name, NULL ) as current_employer, civicrm_address.id as address_id, civicrm_address.street_address as `street_address`, civicrm_address.supplemental_address_1 as `supplemental_address_1`, civicrm_address.supplemental_address_2 as `supplemental_address_2`, civicrm_address.supplemental_address_3 as `supplemental_address_3`, civicrm_address.city as `city`, civicrm_address.postal_code_suffix as `postal_code_suffix`, civicrm_address.postal_code as `postal_code`, civicrm_address.geo_code_1 as `geo_code_1`, civicrm_address.geo_code_2 as `geo_code_2`, civicrm_address.state_province_id as state_province_id, civicrm_address.country_id as country_id, civicrm_phone.id as phone_id, civicrm_phone.phone_type_id as phone_type_id, civicrm_phone.phone as `phone`, civicrm_email.id as email_id, civicrm_email.email as `email`, civicrm_email.on_hold as `on_hold`, civicrm_im.id as im_id, civicrm_im.provider_id as provider_id, civicrm_im.name as `im`, civicrm_worldregion.id as worldregion_id, civicrm_worldregion.name as `world_region`', + 0 => 'SELECT contact_a.id as contact_id, contact_a.contact_type as `contact_type`, contact_a.contact_sub_type as `contact_sub_type`, contact_a.sort_name as `sort_name`, contact_a.display_name as `display_name`, contact_a.external_identifier as `external_identifier`, IF ( contact_a.contact_type = \'Individual\', NULL, contact_a.organization_name ) as organization_name, contact_a.first_name as `first_name`, contact_a.middle_name as `middle_name`, contact_a.last_name as `last_name`, contact_a.do_not_email as `do_not_email`, contact_a.do_not_phone as `do_not_phone`, contact_a.do_not_mail as `do_not_mail`, contact_a.do_not_sms as `do_not_sms`, contact_a.do_not_trade as `do_not_trade`, contact_a.is_opt_out as `is_opt_out`, contact_a.legal_identifier as `legal_identifier`, contact_a.nick_name as `nick_name`, contact_a.legal_name as `legal_name`, contact_a.image_URL as `image_URL`, contact_a.preferred_communication_method as `preferred_communication_method`, contact_a.preferred_language as `preferred_language`, contact_a.prefix_id as `prefix_id`, contact_a.suffix_id as `suffix_id`, contact_a.formal_title as `formal_title`, contact_a.communication_style_id as `communication_style_id`, contact_a.job_title as `job_title`, contact_a.gender_id as `gender_id`, contact_a.birth_date as `birth_date`, contact_a.is_deceased as `is_deceased`, contact_a.deceased_date as `deceased_date`, contact_a.household_name as `household_name`, contact_a.sic_code as `sic_code`, contact_a.is_deleted as `contact_is_deleted`, IF ( contact_a.contact_type = \'Individual\', contact_a.organization_name, NULL ) as current_employer, civicrm_address.id as address_id, civicrm_address.street_address as `street_address`, civicrm_address.supplemental_address_1 as `supplemental_address_1`, civicrm_address.supplemental_address_2 as `supplemental_address_2`, civicrm_address.supplemental_address_3 as `supplemental_address_3`, civicrm_address.city as `city`, civicrm_address.postal_code_suffix as `postal_code_suffix`, civicrm_address.postal_code as `postal_code`, civicrm_address.geo_code_1 as `geo_code_1`, civicrm_address.geo_code_2 as `geo_code_2`, civicrm_address.state_province_id as state_province_id, civicrm_address.country_id as country_id, civicrm_phone.id as phone_id, civicrm_phone.phone_type_id as phone_type_id, civicrm_phone.phone as `phone`, civicrm_email.id as email_id, civicrm_email.email as `email`, civicrm_email.on_hold as `on_hold`, civicrm_im.id as im_id, civicrm_im.provider_id as provider_id, civicrm_im.name as `im`, civicrm_worldregion.id as worldregion_id, civicrm_worldregion.name as `world_region`', 2 => 'WHERE displayRelType.relationship_type_id = 1 AND displayRelType.is_active = 1 AND ( 1 ) AND (contact_a.is_deleted = 0)', @@ -733,15 +733,17 @@ public function testCustomDateField(): void { */ public static function getDefaultSelectString(): string { return 'SELECT contact_a.id as contact_id, contact_a.contact_type as `contact_type`, contact_a.contact_sub_type as `contact_sub_type`, contact_a.sort_name as `sort_name`,' - . ' contact_a.display_name as `display_name`, contact_a.do_not_email as `do_not_email`, contact_a.do_not_phone as `do_not_phone`, contact_a.do_not_mail as `do_not_mail`,' + . ' contact_a.display_name as `display_name`, contact_a.external_identifier as `external_identifier`,' + . ' IF ( contact_a.contact_type = \'Individual\', NULL, contact_a.organization_name ) as organization_name,' + . ' contact_a.first_name as `first_name`, contact_a.middle_name as `middle_name`, contact_a.last_name as `last_name`,' + . ' contact_a.do_not_email as `do_not_email`, contact_a.do_not_phone as `do_not_phone`, contact_a.do_not_mail as `do_not_mail`,' . ' contact_a.do_not_sms as `do_not_sms`, contact_a.do_not_trade as `do_not_trade`, contact_a.is_opt_out as `is_opt_out`, contact_a.legal_identifier as `legal_identifier`,' - . ' contact_a.external_identifier as `external_identifier`, contact_a.nick_name as `nick_name`, contact_a.legal_name as `legal_name`, contact_a.image_URL as `image_URL`,' + . ' contact_a.nick_name as `nick_name`, contact_a.legal_name as `legal_name`, contact_a.image_URL as `image_URL`,' . ' contact_a.preferred_communication_method as `preferred_communication_method`, contact_a.preferred_language as `preferred_language`,' - . ' contact_a.first_name as `first_name`, contact_a.middle_name as `middle_name`, contact_a.last_name as `last_name`,' . ' contact_a.prefix_id as `prefix_id`, contact_a.suffix_id as `suffix_id`, contact_a.formal_title as `formal_title`, contact_a.communication_style_id as `communication_style_id`,' . ' contact_a.job_title as `job_title`, contact_a.gender_id as `gender_id`, contact_a.birth_date as `birth_date`, contact_a.is_deceased as `is_deceased`,' . ' contact_a.deceased_date as `deceased_date`, contact_a.household_name as `household_name`,' - . ' IF ( contact_a.contact_type = \'Individual\', NULL, contact_a.organization_name ) as organization_name, contact_a.sic_code as `sic_code`, contact_a.is_deleted as `contact_is_deleted`,' + . ' contact_a.sic_code as `sic_code`, contact_a.is_deleted as `contact_is_deleted`,' . ' IF ( contact_a.contact_type = \'Individual\', contact_a.organization_name, NULL ) as current_employer, civicrm_address.id as address_id,' . ' civicrm_address.street_address as `street_address`, civicrm_address.supplemental_address_1 as `supplemental_address_1`, ' . 'civicrm_address.supplemental_address_2 as `supplemental_address_2`, civicrm_address.supplemental_address_3 as `supplemental_address_3`, civicrm_address.city as `city`, civicrm_address.postal_code_suffix as `postal_code_suffix`, ' diff --git a/tests/phpunit/CRM/Export/BAO/ExportTest.php b/tests/phpunit/CRM/Export/BAO/ExportTest.php index cd2015fc1ffa..dcbdd770de55 100644 --- a/tests/phpunit/CRM/Export/BAO/ExportTest.php +++ b/tests/phpunit/CRM/Export/BAO/ExportTest.php @@ -147,6 +147,8 @@ public function testExportComponentsContribution(): void { /** * Implements hook_civicrm_export(). + * + * @throws \Civi\Core\Exception\DBQueryException */ public function confirmHookWasCalled($exportTempTable, &$headerRows, &$sqlColumns, $exportMode, $componentTable, $ids): void { $sqlColumns['display'] = 'display varchar(255)'; @@ -2219,41 +2221,41 @@ protected function getBasicHeaderDefinition($isContactExport): array { $headers = [ 0 => 'Contact ID', 1 => 'Contact Type', - 2 => 'Contact Subtype', - 3 => 'Do Not Email', - 4 => 'Do Not Phone', - 5 => 'Do Not Mail', - 6 => 'Do Not Sms', - 7 => 'Do Not Trade', - 8 => 'No Bulk Emails (User Opt Out)', - 9 => 'Legal Identifier', - 10 => 'External Identifier', - 11 => 'Sort Name', - 12 => 'Display Name', - 13 => 'Nickname', - 14 => 'Legal Name', - 15 => 'Image Url', - 16 => 'Preferred Communication Method', - 17 => 'Preferred Language', - 18 => 'Contact Hash', - 19 => 'Contact Source', - 20 => 'First Name', - 21 => 'Middle Name', - 22 => 'Last Name', - 23 => 'Individual Prefix', - 24 => 'Individual Suffix', - 25 => 'Formal Title', - 26 => 'Communication Style', - 27 => 'Email Greeting ID', - 28 => 'Postal Greeting ID', - 29 => 'Addressee ID', - 30 => 'Job Title', - 31 => 'Gender', - 32 => 'Birth Date', - 33 => 'Deceased', - 34 => 'Deceased Date', - 35 => 'Household Name', - 36 => 'Organization Name', + 2 => 'External Identifier', + 3 => 'Display Name', + 4 => 'Organization Name', + 5 => 'Contact Subtype', + 6 => 'First Name', + 7 => 'Middle Name', + 8 => 'Last Name', + 9 => 'Do Not Email', + 10 => 'Do Not Phone', + 11 => 'Do Not Mail', + 12 => 'Do Not Sms', + 13 => 'Do Not Trade', + 14 => 'No Bulk Emails (User Opt Out)', + 15 => 'Legal Identifier', + 16 => 'Sort Name', + 17 => 'Nickname', + 18 => 'Legal Name', + 19 => 'Image Url', + 20 => 'Preferred Communication Method', + 21 => 'Preferred Language', + 22 => 'Contact Hash', + 23 => 'Contact Source', + 24 => 'Individual Prefix', + 25 => 'Individual Suffix', + 26 => 'Formal Title', + 27 => 'Communication Style', + 28 => 'Email Greeting ID', + 29 => 'Postal Greeting ID', + 30 => 'Addressee ID', + 31 => 'Job Title', + 32 => 'Gender', + 33 => 'Birth Date', + 34 => 'Deceased', + 35 => 'Deceased Date', + 36 => 'Household Name', 37 => 'Sic Code', 38 => 'Unique ID (OpenID)', 39 => 'Current Employer ID',