5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Contact/Contact.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:aa86c226e54f7c7f8a8ad6b5e8c8aa5a)
13 * Database access object for the Contact entity.
15 class CRM_Contact_DAO_Contact
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_contact';
27 * Icon associated with this entity.
31 public static $_icon = 'fa-address-book-o';
34 * Field to show when displaying a record.
38 public static $_labelField = 'display_name';
41 * Should CiviCRM log any modifications to this table in the civicrm_log table.
45 public static $_log = TRUE;
48 * Paths for accessing this entity in the UI.
52 protected static $_paths = [
53 'add' => 'civicrm/contact/add?reset=1&ct=[contact_type]',
54 'view' => 'civicrm/contact/view?reset=1&cid=[id]',
55 'update' => 'civicrm/contact/add?reset=1&action=update&cid=[id]',
56 'delete' => 'civicrm/contact/view/delete?reset=1&delete=1&cid=[id]',
74 * May be used to over-ride contact view and edit templates.
78 public $contact_sub_type;
103 public $do_not_trade;
106 * Has the contact opted out from receiving all bulk email from the organization or site domain?
113 * May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.
117 public $legal_identifier;
120 * Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.
124 public $external_identifier;
127 * Name used for sorting different contact types
134 * Formatted name representing preferred format for display/print/other output.
138 public $display_name;
155 * optional URL for preferred image (photo, logo, etc.) to display for this contact.
162 * What is the preferred mode of communication.
166 public $preferred_communication_method;
169 * Which language is preferred for communication. FK to languages in civicrm_option_value.
173 public $preferred_language;
176 * What is the preferred mode of sending an email.
180 public $preferred_mail_format;
183 * Key for validating requests related to this contact.
190 * API Key for validating requests related to this contact.
197 * where contact come from, e.g. import, donate module insert...
225 * Prefix or Title for name (Ms, Mr...). FK to prefix ID
232 * Suffix for name (Jr, Sr...). FK to suffix ID
239 * Formal (academic or similar) title in front of name. (Prof., Dr. etc.)
243 public $formal_title;
246 * Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.
250 public $communication_style_id;
253 * FK to civicrm_option_value.id, that has to be valid registered Email Greeting.
257 public $email_greeting_id;
260 * Custom Email Greeting.
264 public $email_greeting_custom;
267 * Cache Email Greeting.
271 public $email_greeting_display;
274 * FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.
278 public $postal_greeting_id;
281 * Custom Postal greeting.
285 public $postal_greeting_custom;
288 * Cache Postal greeting.
292 public $postal_greeting_display;
295 * FK to civicrm_option_value.id, that has to be valid registered Addressee.
299 public $addressee_id;
306 public $addressee_custom;
313 public $addressee_display;
346 public $deceased_date;
353 public $household_name;
356 * Optional FK to Primary Contact for this household.
360 public $primary_contact_id;
367 public $organization_name;
370 * Standard Industry Classification Code.
377 * the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM
381 public $user_unique_id;
384 * OPTIONAL FK to civicrm_contact record.
396 * When was the contact was created.
400 public $created_date;
403 * When was the contact (or closely related entity) was created or modified or deleted.
407 public $modified_date;
412 public function __construct() {
413 $this->__table
= 'civicrm_contact';
414 parent
::__construct();
418 * Returns localized title of this entity.
420 * @param bool $plural
421 * Whether to return the plural version of the title.
423 public static function getEntityTitle($plural = FALSE) {
424 return $plural ?
ts('Contacts') : ts('Contact');
428 * Returns foreign keys and entity references.
431 * [CRM_Core_Reference_Interface]
433 public static function getReferenceColumns() {
434 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
435 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
436 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'primary_contact_id', 'civicrm_contact', 'id');
437 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'employer_id', 'civicrm_contact', 'id');
438 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
440 return Civi
::$statics[__CLASS__
]['links'];
444 * Returns all the column names of this table
448 public static function &fields() {
449 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
450 Civi
::$statics[__CLASS__
]['fields'] = [
453 'type' => CRM_Utils_Type
::T_INT
,
454 'title' => ts('Contact ID'),
455 'description' => ts('Unique Contact ID'),
458 'where' => 'civicrm_contact.id',
459 'headerPattern' => '/internal|contact?|id$/i',
461 'table_name' => 'civicrm_contact',
462 'entity' => 'Contact',
463 'bao' => 'CRM_Contact_BAO_Contact',
472 'name' => 'contact_type',
473 'type' => CRM_Utils_Type
::T_STRING
,
474 'title' => ts('Contact Type'),
475 'description' => ts('Type of Contact.'),
477 'size' => CRM_Utils_Type
::BIG
,
478 'where' => 'civicrm_contact.contact_type',
480 'contactType' => NULL,
481 'table_name' => 'civicrm_contact',
482 'entity' => 'Contact',
483 'bao' => 'CRM_Contact_BAO_Contact',
488 'pseudoconstant' => [
489 'table' => 'civicrm_contact_type',
490 'keyColumn' => 'name',
491 'labelColumn' => 'label',
492 'condition' => 'parent_id IS NULL',
497 'contact_sub_type' => [
498 'name' => 'contact_sub_type',
499 'type' => CRM_Utils_Type
::T_STRING
,
500 'title' => ts('Contact Subtype'),
501 'description' => ts('May be used to over-ride contact view and edit templates.'),
503 'size' => CRM_Utils_Type
::HUGE
,
505 'where' => 'civicrm_contact.contact_sub_type',
506 'headerPattern' => '/C(ontact )?(subtype|sub-type|sub type)/i',
508 'table_name' => 'civicrm_contact',
509 'entity' => 'Contact',
510 'bao' => 'CRM_Contact_BAO_Contact',
512 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
516 'pseudoconstant' => [
517 'table' => 'civicrm_contact_type',
518 'keyColumn' => 'name',
519 'labelColumn' => 'label',
520 'condition' => 'parent_id IS NOT NULL',
525 'name' => 'do_not_email',
526 'type' => CRM_Utils_Type
::T_BOOLEAN
,
527 'title' => ts('Do Not Email'),
529 'where' => 'civicrm_contact.do_not_email',
530 'headerPattern' => '/d(o )?(not )?(email)/i',
531 'dataPattern' => '/^\d{1,}$/',
534 'table_name' => 'civicrm_contact',
535 'entity' => 'Contact',
536 'bao' => 'CRM_Contact_BAO_Contact',
539 'type' => 'CheckBox',
540 'label' => ts("Do Not Email"),
545 'name' => 'do_not_phone',
546 'type' => CRM_Utils_Type
::T_BOOLEAN
,
547 'title' => ts('Do Not Phone'),
549 'where' => 'civicrm_contact.do_not_phone',
550 'headerPattern' => '/d(o )?(not )?(call|phone)/i',
551 'dataPattern' => '/^\d{1,}$/',
554 'table_name' => 'civicrm_contact',
555 'entity' => 'Contact',
556 'bao' => 'CRM_Contact_BAO_Contact',
559 'type' => 'CheckBox',
560 'label' => ts("Do Not Phone"),
565 'name' => 'do_not_mail',
566 'type' => CRM_Utils_Type
::T_BOOLEAN
,
567 'title' => ts('Do Not Mail'),
569 'where' => 'civicrm_contact.do_not_mail',
570 'headerPattern' => '/^(d(o\s)?n(ot\s)?mail)|(\w*)?bulk\s?(\w*)$/i',
571 'dataPattern' => '/^\d{1,}$/',
574 'table_name' => 'civicrm_contact',
575 'entity' => 'Contact',
576 'bao' => 'CRM_Contact_BAO_Contact',
579 'type' => 'CheckBox',
580 'label' => ts("Do Not Mail"),
585 'name' => 'do_not_sms',
586 'type' => CRM_Utils_Type
::T_BOOLEAN
,
587 'title' => ts('Do Not Sms'),
589 'where' => 'civicrm_contact.do_not_sms',
590 'headerPattern' => '/d(o )?(not )?(sms)/i',
591 'dataPattern' => '/^\d{1,}$/',
594 'table_name' => 'civicrm_contact',
595 'entity' => 'Contact',
596 'bao' => 'CRM_Contact_BAO_Contact',
599 'type' => 'CheckBox',
600 'label' => ts("Do Not Sms"),
605 'name' => 'do_not_trade',
606 'type' => CRM_Utils_Type
::T_BOOLEAN
,
607 'title' => ts('Do Not Trade'),
609 'where' => 'civicrm_contact.do_not_trade',
610 'headerPattern' => '/d(o )?(not )?(trade)/i',
611 'dataPattern' => '/^\d{1,}$/',
614 'table_name' => 'civicrm_contact',
615 'entity' => 'Contact',
616 'bao' => 'CRM_Contact_BAO_Contact',
619 'type' => 'CheckBox',
620 'label' => ts("Do Not Trade"),
625 'name' => 'is_opt_out',
626 'type' => CRM_Utils_Type
::T_BOOLEAN
,
627 'title' => ts('No Bulk Emails (User Opt Out)'),
628 'description' => ts('Has the contact opted out from receiving all bulk email from the organization or site domain?'),
631 'where' => 'civicrm_contact.is_opt_out',
634 'table_name' => 'civicrm_contact',
635 'entity' => 'Contact',
636 'bao' => 'CRM_Contact_BAO_Contact',
639 'type' => 'CheckBox',
640 'label' => ts("Is Opt Out"),
644 'legal_identifier' => [
645 'name' => 'legal_identifier',
646 'type' => CRM_Utils_Type
::T_STRING
,
647 'title' => ts('Legal Identifier'),
648 'description' => ts('May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.'),
650 'size' => CRM_Utils_Type
::MEDIUM
,
652 'where' => 'civicrm_contact.legal_identifier',
653 'headerPattern' => '/legal\s?id/i',
654 'dataPattern' => '/\w+?\d{5,}/',
656 'table_name' => 'civicrm_contact',
657 'entity' => 'Contact',
658 'bao' => 'CRM_Contact_BAO_Contact',
662 'label' => ts("Legal Identifier"),
666 'external_identifier' => [
667 'name' => 'external_identifier',
668 'type' => CRM_Utils_Type
::T_STRING
,
669 'title' => ts('External Identifier'),
670 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
674 'where' => 'civicrm_contact.external_identifier',
675 'headerPattern' => '/external\s?id/i',
676 'dataPattern' => '/^\d{11,}$/',
678 'table_name' => 'civicrm_contact',
679 'entity' => 'Contact',
680 'bao' => 'CRM_Contact_BAO_Contact',
684 'label' => ts("External Identifier"),
689 'name' => 'sort_name',
690 'type' => CRM_Utils_Type
::T_STRING
,
691 'title' => ts('Sort Name'),
692 'description' => ts('Name used for sorting different contact types'),
695 'where' => 'civicrm_contact.sort_name',
697 'table_name' => 'civicrm_contact',
698 'entity' => 'Contact',
699 'bao' => 'CRM_Contact_BAO_Contact',
708 'name' => 'display_name',
709 'type' => CRM_Utils_Type
::T_STRING
,
710 'title' => ts('Display Name'),
711 'description' => ts('Formatted name representing preferred format for display/print/other output.'),
714 'where' => 'civicrm_contact.display_name',
716 'table_name' => 'civicrm_contact',
717 'entity' => 'Contact',
718 'bao' => 'CRM_Contact_BAO_Contact',
727 'name' => 'nick_name',
728 'type' => CRM_Utils_Type
::T_STRING
,
729 'title' => ts('Nickname'),
730 'description' => ts('Nickname.'),
734 'where' => 'civicrm_contact.nick_name',
735 'headerPattern' => '/n(ick\s)name|nick$/i',
736 'dataPattern' => '/^\w+$/',
738 'table_name' => 'civicrm_contact',
739 'entity' => 'Contact',
740 'bao' => 'CRM_Contact_BAO_Contact',
748 'name' => 'legal_name',
749 'type' => CRM_Utils_Type
::T_STRING
,
750 'title' => ts('Legal Name'),
751 'description' => ts('Legal Name.'),
755 'where' => 'civicrm_contact.legal_name',
756 'headerPattern' => '/^legal|(l(egal\s)?name)$/i',
758 'contactType' => 'Organization',
759 'table_name' => 'civicrm_contact',
760 'entity' => 'Contact',
761 'bao' => 'CRM_Contact_BAO_Contact',
765 'label' => ts("Legal Name"),
770 'name' => 'image_URL',
771 'type' => CRM_Utils_Type
::T_TEXT
,
772 'title' => ts('Image Url'),
773 'description' => ts('optional URL for preferred image (photo, logo, etc.) to display for this contact.'),
775 'where' => 'civicrm_contact.image_URL',
777 'table_name' => 'civicrm_contact',
778 'entity' => 'Contact',
779 'bao' => 'CRM_Contact_BAO_Contact',
783 'label' => ts("Image URL"),
787 'preferred_communication_method' => [
788 'name' => 'preferred_communication_method',
789 'type' => CRM_Utils_Type
::T_STRING
,
790 'title' => ts('Preferred Communication Method'),
791 'description' => ts('What is the preferred mode of communication.'),
793 'size' => CRM_Utils_Type
::HUGE
,
795 'where' => 'civicrm_contact.preferred_communication_method',
796 'headerPattern' => '/^p(ref\w*\s)?c(omm\w*)|( meth\w*)$/i',
797 'dataPattern' => '/^\w+$/',
799 'table_name' => 'civicrm_contact',
800 'entity' => 'Contact',
801 'bao' => 'CRM_Contact_BAO_Contact',
803 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
807 'pseudoconstant' => [
808 'optionGroupName' => 'preferred_communication_method',
809 'optionEditPath' => 'civicrm/admin/options/preferred_communication_method',
813 'preferred_language' => [
814 'name' => 'preferred_language',
815 'type' => CRM_Utils_Type
::T_STRING
,
816 'title' => ts('Preferred Language'),
817 'description' => ts('Which language is preferred for communication. FK to languages in civicrm_option_value.'),
819 'size' => CRM_Utils_Type
::SIX
,
821 'where' => 'civicrm_contact.preferred_language',
822 'headerPattern' => '/^lang/i',
824 'table_name' => 'civicrm_contact',
825 'entity' => 'Contact',
826 'bao' => 'CRM_Contact_BAO_Contact',
831 'pseudoconstant' => [
832 'optionGroupName' => 'languages',
833 'keyColumn' => 'name',
834 'optionEditPath' => 'civicrm/admin/options/languages',
838 'preferred_mail_format' => [
839 'name' => 'preferred_mail_format',
840 'type' => CRM_Utils_Type
::T_STRING
,
841 'title' => ts('Preferred Mail Format'),
842 'description' => ts('What is the preferred mode of sending an email.'),
844 'size' => CRM_Utils_Type
::EIGHT
,
846 'where' => 'civicrm_contact.preferred_mail_format',
847 'headerPattern' => '/^p(ref\w*\s)?m(ail\s)?f(orm\w*)$/i',
850 'table_name' => 'civicrm_contact',
851 'entity' => 'Contact',
852 'bao' => 'CRM_Contact_BAO_Contact',
856 'label' => ts("Preferred Mail Format"),
858 'pseudoconstant' => [
859 'callback' => 'CRM_Core_SelectValues::pmf',
865 'type' => CRM_Utils_Type
::T_STRING
,
866 'title' => ts('Contact Hash'),
867 'description' => ts('Key for validating requests related to this contact.'),
869 'size' => CRM_Utils_Type
::MEDIUM
,
870 'where' => 'civicrm_contact.hash',
872 'table_name' => 'civicrm_contact',
873 'entity' => 'Contact',
874 'bao' => 'CRM_Contact_BAO_Contact',
881 'type' => CRM_Utils_Type
::T_STRING
,
882 'title' => ts('Api Key'),
883 'description' => ts('API Key for validating requests related to this contact.'),
885 'size' => CRM_Utils_Type
::MEDIUM
,
886 'where' => 'civicrm_contact.api_key',
889 'administer CiviCRM',
893 'table_name' => 'civicrm_contact',
894 'entity' => 'Contact',
895 'bao' => 'CRM_Contact_BAO_Contact',
898 'label' => ts("API KEY"),
903 'contact_source' => [
905 'type' => CRM_Utils_Type
::T_STRING
,
906 'title' => ts('Contact Source'),
907 'description' => ts('where contact come from, e.g. import, donate module insert...'),
911 'where' => 'civicrm_contact.source',
912 'headerPattern' => '/(C(ontact\s)?Source)$/i',
914 'table_name' => 'civicrm_contact',
915 'entity' => 'Contact',
916 'bao' => 'CRM_Contact_BAO_Contact',
924 'name' => 'first_name',
925 'type' => CRM_Utils_Type
::T_STRING
,
926 'title' => ts('First Name'),
927 'description' => ts('First Name.'),
931 'where' => 'civicrm_contact.first_name',
932 'headerPattern' => '/^first|(f(irst\s)?name)$/i',
933 'dataPattern' => '/^\w+$/',
935 'contactType' => 'Individual',
936 'table_name' => 'civicrm_contact',
937 'entity' => 'Contact',
938 'bao' => 'CRM_Contact_BAO_Contact',
942 'label' => ts("First Name"),
947 'name' => 'middle_name',
948 'type' => CRM_Utils_Type
::T_STRING
,
949 'title' => ts('Middle Name'),
950 'description' => ts('Middle Name.'),
954 'where' => 'civicrm_contact.middle_name',
955 'headerPattern' => '/^middle|(m(iddle\s)?name)$/i',
956 'dataPattern' => '/^\w+$/',
958 'contactType' => 'Individual',
959 'table_name' => 'civicrm_contact',
960 'entity' => 'Contact',
961 'bao' => 'CRM_Contact_BAO_Contact',
965 'label' => ts("Middle Name"),
970 'name' => 'last_name',
971 'type' => CRM_Utils_Type
::T_STRING
,
972 'title' => ts('Last Name'),
973 'description' => ts('Last Name.'),
977 'where' => 'civicrm_contact.last_name',
978 'headerPattern' => '/^last|(l(ast\s)?name)$/i',
979 'dataPattern' => '/^\w+(\s\w+)?+$/',
981 'contactType' => 'Individual',
982 'table_name' => 'civicrm_contact',
983 'entity' => 'Contact',
984 'bao' => 'CRM_Contact_BAO_Contact',
988 'label' => ts("Last Name"),
993 'name' => 'prefix_id',
994 'type' => CRM_Utils_Type
::T_INT
,
995 'title' => ts('Individual Prefix'),
996 'description' => ts('Prefix or Title for name (Ms, Mr...). FK to prefix ID'),
998 'where' => 'civicrm_contact.prefix_id',
999 'headerPattern' => '/^(prefix|title)/i',
1000 'dataPattern' => '/^(mr|ms|mrs|sir|dr)\.?$/i',
1002 'contactType' => 'Individual',
1003 'table_name' => 'civicrm_contact',
1004 'entity' => 'Contact',
1005 'bao' => 'CRM_Contact_BAO_Contact',
1010 'pseudoconstant' => [
1011 'optionGroupName' => 'individual_prefix',
1012 'optionEditPath' => 'civicrm/admin/options/individual_prefix',
1017 'name' => 'suffix_id',
1018 'type' => CRM_Utils_Type
::T_INT
,
1019 'title' => ts('Individual Suffix'),
1020 'description' => ts('Suffix for name (Jr, Sr...). FK to suffix ID'),
1022 'where' => 'civicrm_contact.suffix_id',
1023 'headerPattern' => '/^suffix$/i',
1024 'dataPattern' => '/^(sr|jr)\.?|i{2,}$/',
1026 'contactType' => 'Individual',
1027 'table_name' => 'civicrm_contact',
1028 'entity' => 'Contact',
1029 'bao' => 'CRM_Contact_BAO_Contact',
1034 'pseudoconstant' => [
1035 'optionGroupName' => 'individual_suffix',
1036 'optionEditPath' => 'civicrm/admin/options/individual_suffix',
1041 'name' => 'formal_title',
1042 'type' => CRM_Utils_Type
::T_STRING
,
1043 'title' => ts('Formal Title'),
1044 'description' => ts('Formal (academic or similar) title in front of name. (Prof., Dr. etc.)'),
1046 'size' => CRM_Utils_Type
::BIG
,
1048 'where' => 'civicrm_contact.formal_title',
1049 'headerPattern' => '/^title/i',
1051 'contactType' => 'Individual',
1052 'table_name' => 'civicrm_contact',
1053 'entity' => 'Contact',
1054 'bao' => 'CRM_Contact_BAO_Contact',
1058 'label' => ts("Formal Title"),
1062 'communication_style_id' => [
1063 'name' => 'communication_style_id',
1064 'type' => CRM_Utils_Type
::T_INT
,
1065 'title' => ts('Communication Style'),
1066 'description' => ts('Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.'),
1068 'where' => 'civicrm_contact.communication_style_id',
1069 'headerPattern' => '/style/i',
1071 'table_name' => 'civicrm_contact',
1072 'entity' => 'Contact',
1073 'bao' => 'CRM_Contact_BAO_Contact',
1078 'pseudoconstant' => [
1079 'optionGroupName' => 'communication_style',
1080 'optionEditPath' => 'civicrm/admin/options/communication_style',
1084 'email_greeting_id' => [
1085 'name' => 'email_greeting_id',
1086 'type' => CRM_Utils_Type
::T_INT
,
1087 'title' => ts('Email Greeting ID'),
1088 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Email Greeting.'),
1089 'where' => 'civicrm_contact.email_greeting_id',
1091 'table_name' => 'civicrm_contact',
1092 'entity' => 'Contact',
1093 'bao' => 'CRM_Contact_BAO_Contact',
1098 'pseudoconstant' => [
1099 'optionGroupName' => 'email_greeting',
1100 'optionEditPath' => 'civicrm/admin/options/email_greeting',
1104 'email_greeting_custom' => [
1105 'name' => 'email_greeting_custom',
1106 'type' => CRM_Utils_Type
::T_STRING
,
1107 'title' => ts('Email Greeting Custom'),
1108 'description' => ts('Custom Email Greeting.'),
1110 'size' => CRM_Utils_Type
::HUGE
,
1112 'where' => 'civicrm_contact.email_greeting_custom',
1114 'table_name' => 'civicrm_contact',
1115 'entity' => 'Contact',
1116 'bao' => 'CRM_Contact_BAO_Contact',
1120 'label' => ts("Email Greeting Custom"),
1124 'email_greeting_display' => [
1125 'name' => 'email_greeting_display',
1126 'type' => CRM_Utils_Type
::T_STRING
,
1127 'title' => ts('Email Greeting'),
1128 'description' => ts('Cache Email Greeting.'),
1130 'size' => CRM_Utils_Type
::HUGE
,
1131 'where' => 'civicrm_contact.email_greeting_display',
1132 'table_name' => 'civicrm_contact',
1133 'entity' => 'Contact',
1134 'bao' => 'CRM_Contact_BAO_Contact',
1139 'postal_greeting_id' => [
1140 'name' => 'postal_greeting_id',
1141 'type' => CRM_Utils_Type
::T_INT
,
1142 'title' => ts('Postal Greeting ID'),
1143 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.'),
1144 'where' => 'civicrm_contact.postal_greeting_id',
1146 'table_name' => 'civicrm_contact',
1147 'entity' => 'Contact',
1148 'bao' => 'CRM_Contact_BAO_Contact',
1153 'pseudoconstant' => [
1154 'optionGroupName' => 'postal_greeting',
1155 'optionEditPath' => 'civicrm/admin/options/postal_greeting',
1159 'postal_greeting_custom' => [
1160 'name' => 'postal_greeting_custom',
1161 'type' => CRM_Utils_Type
::T_STRING
,
1162 'title' => ts('Postal Greeting Custom'),
1163 'description' => ts('Custom Postal greeting.'),
1165 'size' => CRM_Utils_Type
::HUGE
,
1167 'where' => 'civicrm_contact.postal_greeting_custom',
1169 'table_name' => 'civicrm_contact',
1170 'entity' => 'Contact',
1171 'bao' => 'CRM_Contact_BAO_Contact',
1175 'label' => ts("Postal Greeting Custom"),
1179 'postal_greeting_display' => [
1180 'name' => 'postal_greeting_display',
1181 'type' => CRM_Utils_Type
::T_STRING
,
1182 'title' => ts('Postal Greeting'),
1183 'description' => ts('Cache Postal greeting.'),
1185 'size' => CRM_Utils_Type
::HUGE
,
1186 'where' => 'civicrm_contact.postal_greeting_display',
1187 'table_name' => 'civicrm_contact',
1188 'entity' => 'Contact',
1189 'bao' => 'CRM_Contact_BAO_Contact',
1195 'name' => 'addressee_id',
1196 'type' => CRM_Utils_Type
::T_INT
,
1197 'title' => ts('Addressee ID'),
1198 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Addressee.'),
1199 'where' => 'civicrm_contact.addressee_id',
1201 'table_name' => 'civicrm_contact',
1202 'entity' => 'Contact',
1203 'bao' => 'CRM_Contact_BAO_Contact',
1208 'pseudoconstant' => [
1209 'optionGroupName' => 'addressee',
1210 'optionEditPath' => 'civicrm/admin/options/addressee',
1214 'addressee_custom' => [
1215 'name' => 'addressee_custom',
1216 'type' => CRM_Utils_Type
::T_STRING
,
1217 'title' => ts('Addressee Custom'),
1218 'description' => ts('Custom Addressee.'),
1220 'size' => CRM_Utils_Type
::HUGE
,
1222 'where' => 'civicrm_contact.addressee_custom',
1224 'table_name' => 'civicrm_contact',
1225 'entity' => 'Contact',
1226 'bao' => 'CRM_Contact_BAO_Contact',
1230 'label' => ts("Addressee Custom"),
1234 'addressee_display' => [
1235 'name' => 'addressee_display',
1236 'type' => CRM_Utils_Type
::T_STRING
,
1237 'title' => ts('Addressee'),
1238 'description' => ts('Cache Addressee.'),
1240 'size' => CRM_Utils_Type
::HUGE
,
1241 'where' => 'civicrm_contact.addressee_display',
1242 'table_name' => 'civicrm_contact',
1243 'entity' => 'Contact',
1244 'bao' => 'CRM_Contact_BAO_Contact',
1250 'name' => 'job_title',
1251 'type' => CRM_Utils_Type
::T_STRING
,
1252 'title' => ts('Job Title'),
1253 'description' => ts('Job Title'),
1257 'where' => 'civicrm_contact.job_title',
1258 'headerPattern' => '/^job|(j(ob\s)?title)$/i',
1259 'dataPattern' => '//',
1261 'contactType' => 'Individual',
1262 'table_name' => 'civicrm_contact',
1263 'entity' => 'Contact',
1264 'bao' => 'CRM_Contact_BAO_Contact',
1268 'label' => ts("Job Title"),
1273 'name' => 'gender_id',
1274 'type' => CRM_Utils_Type
::T_INT
,
1275 'title' => ts('Gender ID'),
1276 'description' => ts('FK to gender ID'),
1278 'where' => 'civicrm_contact.gender_id',
1279 'headerPattern' => '/^gender$/i',
1281 'contactType' => 'Individual',
1282 'table_name' => 'civicrm_contact',
1283 'entity' => 'Contact',
1284 'bao' => 'CRM_Contact_BAO_Contact',
1288 'label' => ts("Gender"),
1290 'pseudoconstant' => [
1291 'optionGroupName' => 'gender',
1292 'optionEditPath' => 'civicrm/admin/options/gender',
1297 'name' => 'birth_date',
1298 'type' => CRM_Utils_Type
::T_DATE
,
1299 'title' => ts('Birth Date'),
1300 'description' => ts('Date of birth'),
1302 'where' => 'civicrm_contact.birth_date',
1303 'headerPattern' => '/^birth|(b(irth\s)?date)|D(\W*)O(\W*)B(\W*)$/i',
1304 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
1306 'contactType' => 'Individual',
1307 'table_name' => 'civicrm_contact',
1308 'entity' => 'Contact',
1309 'bao' => 'CRM_Contact_BAO_Contact',
1312 'type' => 'Select Date',
1313 'formatType' => 'birth',
1314 'label' => ts("Birth Date"),
1319 'name' => 'is_deceased',
1320 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1321 'title' => ts('Deceased'),
1324 'where' => 'civicrm_contact.is_deceased',
1325 'headerPattern' => '/i(s\s)?d(eceased)$/i',
1327 'contactType' => 'Individual',
1329 'table_name' => 'civicrm_contact',
1330 'entity' => 'Contact',
1331 'bao' => 'CRM_Contact_BAO_Contact',
1334 'type' => 'CheckBox',
1335 'label' => ts("Is Deceased"),
1339 'deceased_date' => [
1340 'name' => 'deceased_date',
1341 'type' => CRM_Utils_Type
::T_DATE
,
1342 'title' => ts('Deceased Date'),
1343 'description' => ts('Date of deceased'),
1345 'where' => 'civicrm_contact.deceased_date',
1346 'headerPattern' => '/^deceased|(d(eceased\s)?date)$/i',
1348 'contactType' => 'Individual',
1349 'table_name' => 'civicrm_contact',
1350 'entity' => 'Contact',
1351 'bao' => 'CRM_Contact_BAO_Contact',
1354 'type' => 'Select Date',
1355 'formatType' => 'birth',
1356 'label' => ts("Deceased Date"),
1360 'household_name' => [
1361 'name' => 'household_name',
1362 'type' => CRM_Utils_Type
::T_STRING
,
1363 'title' => ts('Household Name'),
1364 'description' => ts('Household Name.'),
1368 'where' => 'civicrm_contact.household_name',
1369 'headerPattern' => '/^household|(h(ousehold\s)?name)$/i',
1370 'dataPattern' => '/^\w+$/',
1372 'contactType' => 'Household',
1373 'table_name' => 'civicrm_contact',
1374 'entity' => 'Contact',
1375 'bao' => 'CRM_Contact_BAO_Contact',
1379 'label' => ts("Household Name"),
1383 'primary_contact_id' => [
1384 'name' => 'primary_contact_id',
1385 'type' => CRM_Utils_Type
::T_INT
,
1386 'title' => ts('Household Primary Contact ID'),
1387 'description' => ts('Optional FK to Primary Contact for this household.'),
1388 'where' => 'civicrm_contact.primary_contact_id',
1389 'contactType' => 'Household',
1390 'table_name' => 'civicrm_contact',
1391 'entity' => 'Contact',
1392 'bao' => 'CRM_Contact_BAO_Contact',
1394 'FKClassName' => 'CRM_Contact_DAO_Contact',
1396 'label' => ts("Household Primary Contact"),
1401 'organization_name' => [
1402 'name' => 'organization_name',
1403 'type' => CRM_Utils_Type
::T_STRING
,
1404 'title' => ts('Organization Name'),
1405 'description' => ts('Organization Name.'),
1409 'where' => 'civicrm_contact.organization_name',
1410 'headerPattern' => '/^organization|(o(rganization\s)?name)$/i',
1411 'dataPattern' => '/^\w+$/',
1413 'contactType' => 'Organization',
1414 'table_name' => 'civicrm_contact',
1415 'entity' => 'Contact',
1416 'bao' => 'CRM_Contact_BAO_Contact',
1420 'label' => ts("Organization Name"),
1425 'name' => 'sic_code',
1426 'type' => CRM_Utils_Type
::T_STRING
,
1427 'title' => ts('Sic Code'),
1428 'description' => ts('Standard Industry Classification Code.'),
1430 'size' => CRM_Utils_Type
::EIGHT
,
1432 'where' => 'civicrm_contact.sic_code',
1433 'headerPattern' => '/^sic|(s(ic\s)?code)$/i',
1435 'contactType' => 'Organization',
1436 'table_name' => 'civicrm_contact',
1437 'entity' => 'Contact',
1438 'bao' => 'CRM_Contact_BAO_Contact',
1442 'label' => ts("SIC Code"),
1446 'user_unique_id' => [
1447 'name' => 'user_unique_id',
1448 'type' => CRM_Utils_Type
::T_STRING
,
1449 'title' => ts('Unique ID (OpenID)'),
1450 'description' => ts('the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM'),
1452 'size' => CRM_Utils_Type
::HUGE
,
1454 'where' => 'civicrm_contact.user_unique_id',
1455 'headerPattern' => '/^Open\s?ID|u(niq\w*)?\s?ID/i',
1456 'dataPattern' => '/^[\w\/\:\.]+$/',
1459 'table_name' => 'civicrm_contact',
1460 'entity' => 'Contact',
1461 'bao' => 'CRM_Contact_BAO_Contact',
1468 'current_employer_id' => [
1469 'name' => 'employer_id',
1470 'type' => CRM_Utils_Type
::T_INT
,
1471 'title' => ts('Current Employer ID'),
1472 'description' => ts('OPTIONAL FK to civicrm_contact record.'),
1473 'where' => 'civicrm_contact.employer_id',
1475 'contactType' => 'Individual',
1476 'table_name' => 'civicrm_contact',
1477 'entity' => 'Contact',
1478 'bao' => 'CRM_Contact_BAO_Contact',
1480 'FKClassName' => 'CRM_Contact_DAO_Contact',
1482 'type' => 'EntityRef',
1483 'label' => ts("Current Employer"),
1487 'contact_is_deleted' => [
1488 'name' => 'is_deleted',
1489 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1490 'title' => ts('Contact is in Trash'),
1492 'where' => 'civicrm_contact.is_deleted',
1495 'access deleted contacts',
1498 'table_name' => 'civicrm_contact',
1499 'entity' => 'Contact',
1500 'bao' => 'CRM_Contact_BAO_Contact',
1503 'type' => 'CheckBox',
1508 'name' => 'created_date',
1509 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
1510 'title' => ts('Created Date'),
1511 'description' => ts('When was the contact was created.'),
1512 'required' => FALSE,
1513 'where' => 'civicrm_contact.created_date',
1515 'default' => 'NULL',
1516 'table_name' => 'civicrm_contact',
1517 'entity' => 'Contact',
1518 'bao' => 'CRM_Contact_BAO_Contact',
1521 'label' => ts("Created Date"),
1525 'modified_date' => [
1526 'name' => 'modified_date',
1527 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
1528 'title' => ts('Modified Date'),
1529 'description' => ts('When was the contact (or closely related entity) was created or modified or deleted.'),
1530 'required' => FALSE,
1531 'where' => 'civicrm_contact.modified_date',
1533 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
1534 'table_name' => 'civicrm_contact',
1535 'entity' => 'Contact',
1536 'bao' => 'CRM_Contact_BAO_Contact',
1539 'label' => ts("Modified Date"),
1545 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
1547 return Civi
::$statics[__CLASS__
]['fields'];
1551 * Return a mapping from field-name to the corresponding key (as used in fields()).
1554 * Array(string $name => string $uniqueName).
1556 public static function &fieldKeys() {
1557 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
1558 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
1560 return Civi
::$statics[__CLASS__
]['fieldKeys'];
1564 * Returns the names of this table
1568 public static function getTableName() {
1569 return self
::$_tableName;
1573 * Returns if this table needs to be logged
1577 public function getLog() {
1582 * Returns the list of fields that can be imported
1584 * @param bool $prefix
1588 public static function &import($prefix = FALSE) {
1589 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'contact', $prefix, []);
1594 * Returns the list of fields that can be exported
1596 * @param bool $prefix
1600 public static function &export($prefix = FALSE) {
1601 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'contact', $prefix, []);
1606 * Returns the list of indices
1608 * @param bool $localize
1612 public static function indices($localize = TRUE) {
1614 'index_contact_type' => [
1615 'name' => 'index_contact_type',
1617 0 => 'contact_type',
1619 'localizable' => FALSE,
1620 'sig' => 'civicrm_contact::0::contact_type',
1622 'index_contact_sub_type' => [
1623 'name' => 'index_contact_sub_type',
1625 0 => 'contact_sub_type',
1627 'localizable' => FALSE,
1628 'sig' => 'civicrm_contact::0::contact_sub_type',
1630 'UI_external_identifier' => [
1631 'name' => 'UI_external_identifier',
1633 0 => 'external_identifier',
1635 'localizable' => FALSE,
1637 'sig' => 'civicrm_contact::1::external_identifier',
1639 'index_sort_name' => [
1640 'name' => 'index_sort_name',
1644 'localizable' => FALSE,
1645 'sig' => 'civicrm_contact::0::sort_name',
1647 'index_preferred_communication_method' => [
1648 'name' => 'index_preferred_communication_method',
1650 0 => 'preferred_communication_method',
1652 'localizable' => FALSE,
1653 'sig' => 'civicrm_contact::0::preferred_communication_method',
1656 'name' => 'index_hash',
1660 'localizable' => FALSE,
1661 'sig' => 'civicrm_contact::0::hash',
1663 'index_api_key' => [
1664 'name' => 'index_api_key',
1668 'localizable' => FALSE,
1669 'sig' => 'civicrm_contact::0::api_key',
1671 'index_first_name' => [
1672 'name' => 'index_first_name',
1676 'localizable' => FALSE,
1677 'sig' => 'civicrm_contact::0::first_name',
1679 'index_last_name' => [
1680 'name' => 'index_last_name',
1684 'localizable' => FALSE,
1685 'sig' => 'civicrm_contact::0::last_name',
1688 'name' => 'UI_prefix',
1692 'localizable' => FALSE,
1693 'sig' => 'civicrm_contact::0::prefix_id',
1696 'name' => 'UI_suffix',
1700 'localizable' => FALSE,
1701 'sig' => 'civicrm_contact::0::suffix_id',
1703 'index_communication_style_id' => [
1704 'name' => 'index_communication_style_id',
1706 0 => 'communication_style_id',
1708 'localizable' => FALSE,
1709 'sig' => 'civicrm_contact::0::communication_style_id',
1712 'name' => 'UI_gender',
1716 'localizable' => FALSE,
1717 'sig' => 'civicrm_contact::0::gender_id',
1719 'index_is_deceased' => [
1720 'name' => 'index_is_deceased',
1724 'localizable' => FALSE,
1725 'sig' => 'civicrm_contact::0::is_deceased',
1727 'index_household_name' => [
1728 'name' => 'index_household_name',
1730 0 => 'household_name',
1732 'localizable' => FALSE,
1733 'sig' => 'civicrm_contact::0::household_name',
1735 'index_organization_name' => [
1736 'name' => 'index_organization_name',
1738 0 => 'organization_name',
1740 'localizable' => FALSE,
1741 'sig' => 'civicrm_contact::0::organization_name',
1743 'index_is_deleted_sort_name' => [
1744 'name' => 'index_is_deleted_sort_name',
1750 'localizable' => FALSE,
1751 'sig' => 'civicrm_contact::0::is_deleted::sort_name::id',
1753 'index_created_date' => [
1754 'name' => 'index_created_date',
1756 0 => 'created_date',
1758 'localizable' => FALSE,
1759 'sig' => 'civicrm_contact::0::created_date',
1761 'index_modified_date' => [
1762 'name' => 'index_modified_date',
1764 0 => 'modified_date',
1766 'localizable' => FALSE,
1767 'sig' => 'civicrm_contact::0::modified_date',
1770 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;