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:f118596cceae71668861504b7316afa7)
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 * Should CiviCRM log any modifications to this table in the civicrm_log table.
38 public static $_log = TRUE;
55 * May be used to over-ride contact view and edit templates.
59 public $contact_sub_type;
87 * Has the contact opted out from receiving all bulk email from the organization or site domain?
94 * May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.
98 public $legal_identifier;
101 * Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.
105 public $external_identifier;
108 * Name used for sorting different contact types
115 * Formatted name representing preferred format for display/print/other output.
119 public $display_name;
136 * optional URL for preferred image (photo, logo, etc.) to display for this contact.
143 * What is the preferred mode of communication.
147 public $preferred_communication_method;
150 * Which language is preferred for communication. FK to languages in civicrm_option_value.
154 public $preferred_language;
157 * What is the preferred mode of sending an email.
161 public $preferred_mail_format;
164 * Key for validating requests related to this contact.
171 * API Key for validating requests related to this contact.
178 * where contact come from, e.g. import, donate module insert...
206 * Prefix or Title for name (Ms, Mr...). FK to prefix ID
213 * Suffix for name (Jr, Sr...). FK to suffix ID
220 * Formal (academic or similar) title in front of name. (Prof., Dr. etc.)
224 public $formal_title;
227 * Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.
231 public $communication_style_id;
234 * FK to civicrm_option_value.id, that has to be valid registered Email Greeting.
238 public $email_greeting_id;
241 * Custom Email Greeting.
245 public $email_greeting_custom;
248 * Cache Email Greeting.
252 public $email_greeting_display;
255 * FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.
259 public $postal_greeting_id;
262 * Custom Postal greeting.
266 public $postal_greeting_custom;
269 * Cache Postal greeting.
273 public $postal_greeting_display;
276 * FK to civicrm_option_value.id, that has to be valid registered Addressee.
280 public $addressee_id;
287 public $addressee_custom;
294 public $addressee_display;
327 public $deceased_date;
334 public $household_name;
337 * Optional FK to Primary Contact for this household.
341 public $primary_contact_id;
348 public $organization_name;
351 * Standard Industry Classification Code.
358 * the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM
362 public $user_unique_id;
365 * OPTIONAL FK to civicrm_contact record.
377 * When was the contact was created.
381 public $created_date;
384 * When was the contact (or closely related entity) was created or modified or deleted.
388 public $modified_date;
393 public function __construct() {
394 $this->__table
= 'civicrm_contact';
395 parent
::__construct();
399 * Returns localized title of this entity.
401 * @param bool $plural
402 * Whether to return the plural version of the title.
404 public static function getEntityTitle($plural = FALSE) {
405 return $plural ?
ts('Contacts') : ts('Contact');
409 * Returns foreign keys and entity references.
412 * [CRM_Core_Reference_Interface]
414 public static function getReferenceColumns() {
415 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
416 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
417 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'primary_contact_id', 'civicrm_contact', 'id');
418 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'employer_id', 'civicrm_contact', 'id');
419 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
421 return Civi
::$statics[__CLASS__
]['links'];
425 * Returns all the column names of this table
429 public static function &fields() {
430 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
431 Civi
::$statics[__CLASS__
]['fields'] = [
434 'type' => CRM_Utils_Type
::T_INT
,
435 'title' => ts('Contact ID'),
436 'description' => ts('Unique Contact ID'),
439 'where' => 'civicrm_contact.id',
440 'headerPattern' => '/internal|contact?|id$/i',
442 'table_name' => 'civicrm_contact',
443 'entity' => 'Contact',
444 'bao' => 'CRM_Contact_BAO_Contact',
449 'name' => 'contact_type',
450 'type' => CRM_Utils_Type
::T_STRING
,
451 'title' => ts('Contact Type'),
452 'description' => ts('Type of Contact.'),
454 'size' => CRM_Utils_Type
::BIG
,
455 'where' => 'civicrm_contact.contact_type',
457 'contactType' => NULL,
458 'table_name' => 'civicrm_contact',
459 'entity' => 'Contact',
460 'bao' => 'CRM_Contact_BAO_Contact',
465 'pseudoconstant' => [
466 'table' => 'civicrm_contact_type',
467 'keyColumn' => 'name',
468 'labelColumn' => 'label',
469 'condition' => 'parent_id IS NULL',
473 'contact_sub_type' => [
474 'name' => 'contact_sub_type',
475 'type' => CRM_Utils_Type
::T_STRING
,
476 'title' => ts('Contact Subtype'),
477 'description' => ts('May be used to over-ride contact view and edit templates.'),
479 'size' => CRM_Utils_Type
::HUGE
,
481 'where' => 'civicrm_contact.contact_sub_type',
482 'headerPattern' => '/C(ontact )?(subtype|sub-type|sub type)/i',
484 'table_name' => 'civicrm_contact',
485 'entity' => 'Contact',
486 'bao' => 'CRM_Contact_BAO_Contact',
488 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
492 'pseudoconstant' => [
493 'table' => 'civicrm_contact_type',
494 'keyColumn' => 'name',
495 'labelColumn' => 'label',
496 'condition' => 'parent_id IS NOT NULL',
501 'name' => 'do_not_email',
502 'type' => CRM_Utils_Type
::T_BOOLEAN
,
503 'title' => ts('Do Not Email'),
505 'where' => 'civicrm_contact.do_not_email',
506 'headerPattern' => '/d(o )?(not )?(email)/i',
507 'dataPattern' => '/^\d{1,}$/',
510 'table_name' => 'civicrm_contact',
511 'entity' => 'Contact',
512 'bao' => 'CRM_Contact_BAO_Contact',
515 'type' => 'CheckBox',
520 'name' => 'do_not_phone',
521 'type' => CRM_Utils_Type
::T_BOOLEAN
,
522 'title' => ts('Do Not Phone'),
524 'where' => 'civicrm_contact.do_not_phone',
525 'headerPattern' => '/d(o )?(not )?(call|phone)/i',
526 'dataPattern' => '/^\d{1,}$/',
529 'table_name' => 'civicrm_contact',
530 'entity' => 'Contact',
531 'bao' => 'CRM_Contact_BAO_Contact',
534 'type' => 'CheckBox',
539 'name' => 'do_not_mail',
540 'type' => CRM_Utils_Type
::T_BOOLEAN
,
541 'title' => ts('Do Not Mail'),
543 'where' => 'civicrm_contact.do_not_mail',
544 'headerPattern' => '/^(d(o\s)?n(ot\s)?mail)|(\w*)?bulk\s?(\w*)$/i',
545 'dataPattern' => '/^\d{1,}$/',
548 'table_name' => 'civicrm_contact',
549 'entity' => 'Contact',
550 'bao' => 'CRM_Contact_BAO_Contact',
553 'type' => 'CheckBox',
558 'name' => 'do_not_sms',
559 'type' => CRM_Utils_Type
::T_BOOLEAN
,
560 'title' => ts('Do Not Sms'),
562 'where' => 'civicrm_contact.do_not_sms',
563 'headerPattern' => '/d(o )?(not )?(sms)/i',
564 'dataPattern' => '/^\d{1,}$/',
567 'table_name' => 'civicrm_contact',
568 'entity' => 'Contact',
569 'bao' => 'CRM_Contact_BAO_Contact',
572 'type' => 'CheckBox',
577 'name' => 'do_not_trade',
578 'type' => CRM_Utils_Type
::T_BOOLEAN
,
579 'title' => ts('Do Not Trade'),
581 'where' => 'civicrm_contact.do_not_trade',
582 'headerPattern' => '/d(o )?(not )?(trade)/i',
583 'dataPattern' => '/^\d{1,}$/',
586 'table_name' => 'civicrm_contact',
587 'entity' => 'Contact',
588 'bao' => 'CRM_Contact_BAO_Contact',
591 'type' => 'CheckBox',
596 'name' => 'is_opt_out',
597 'type' => CRM_Utils_Type
::T_BOOLEAN
,
598 'title' => ts('No Bulk Emails (User Opt Out)'),
599 'description' => ts('Has the contact opted out from receiving all bulk email from the organization or site domain?'),
602 'where' => 'civicrm_contact.is_opt_out',
605 'table_name' => 'civicrm_contact',
606 'entity' => 'Contact',
607 'bao' => 'CRM_Contact_BAO_Contact',
610 'type' => 'CheckBox',
614 'legal_identifier' => [
615 'name' => 'legal_identifier',
616 'type' => CRM_Utils_Type
::T_STRING
,
617 'title' => ts('Legal Identifier'),
618 'description' => ts('May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.'),
620 'size' => CRM_Utils_Type
::MEDIUM
,
622 'where' => 'civicrm_contact.legal_identifier',
623 'headerPattern' => '/legal\s?id/i',
624 'dataPattern' => '/\w+?\d{5,}/',
626 'table_name' => 'civicrm_contact',
627 'entity' => 'Contact',
628 'bao' => 'CRM_Contact_BAO_Contact',
635 'external_identifier' => [
636 'name' => 'external_identifier',
637 'type' => CRM_Utils_Type
::T_STRING
,
638 'title' => ts('External Identifier'),
639 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
643 'where' => 'civicrm_contact.external_identifier',
644 'headerPattern' => '/external\s?id/i',
645 'dataPattern' => '/^\d{11,}$/',
647 'table_name' => 'civicrm_contact',
648 'entity' => 'Contact',
649 'bao' => 'CRM_Contact_BAO_Contact',
657 'name' => 'sort_name',
658 'type' => CRM_Utils_Type
::T_STRING
,
659 'title' => ts('Sort Name'),
660 'description' => ts('Name used for sorting different contact types'),
663 'where' => 'civicrm_contact.sort_name',
665 'table_name' => 'civicrm_contact',
666 'entity' => 'Contact',
667 'bao' => 'CRM_Contact_BAO_Contact',
675 'name' => 'display_name',
676 'type' => CRM_Utils_Type
::T_STRING
,
677 'title' => ts('Display Name'),
678 'description' => ts('Formatted name representing preferred format for display/print/other output.'),
681 'where' => 'civicrm_contact.display_name',
683 'table_name' => 'civicrm_contact',
684 'entity' => 'Contact',
685 'bao' => 'CRM_Contact_BAO_Contact',
693 'name' => 'nick_name',
694 'type' => CRM_Utils_Type
::T_STRING
,
695 'title' => ts('Nickname'),
696 'description' => ts('Nickname.'),
700 'where' => 'civicrm_contact.nick_name',
701 'headerPattern' => '/n(ick\s)name|nick$/i',
702 'dataPattern' => '/^\w+$/',
704 'table_name' => 'civicrm_contact',
705 'entity' => 'Contact',
706 'bao' => 'CRM_Contact_BAO_Contact',
714 'name' => 'legal_name',
715 'type' => CRM_Utils_Type
::T_STRING
,
716 'title' => ts('Legal Name'),
717 'description' => ts('Legal Name.'),
721 'where' => 'civicrm_contact.legal_name',
722 'headerPattern' => '/^legal|(l(egal\s)?name)$/i',
724 'contactType' => 'Organization',
725 'table_name' => 'civicrm_contact',
726 'entity' => 'Contact',
727 'bao' => 'CRM_Contact_BAO_Contact',
735 'name' => 'image_URL',
736 'type' => CRM_Utils_Type
::T_TEXT
,
737 'title' => ts('Image Url'),
738 'description' => ts('optional URL for preferred image (photo, logo, etc.) to display for this contact.'),
740 'where' => 'civicrm_contact.image_URL',
742 'table_name' => 'civicrm_contact',
743 'entity' => 'Contact',
744 'bao' => 'CRM_Contact_BAO_Contact',
751 'preferred_communication_method' => [
752 'name' => 'preferred_communication_method',
753 'type' => CRM_Utils_Type
::T_STRING
,
754 'title' => ts('Preferred Communication Method'),
755 'description' => ts('What is the preferred mode of communication.'),
757 'size' => CRM_Utils_Type
::HUGE
,
759 'where' => 'civicrm_contact.preferred_communication_method',
760 'headerPattern' => '/^p(ref\w*\s)?c(omm\w*)|( meth\w*)$/i',
761 'dataPattern' => '/^\w+$/',
763 'table_name' => 'civicrm_contact',
764 'entity' => 'Contact',
765 'bao' => 'CRM_Contact_BAO_Contact',
767 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
771 'pseudoconstant' => [
772 'optionGroupName' => 'preferred_communication_method',
773 'optionEditPath' => 'civicrm/admin/options/preferred_communication_method',
777 'preferred_language' => [
778 'name' => 'preferred_language',
779 'type' => CRM_Utils_Type
::T_STRING
,
780 'title' => ts('Preferred Language'),
781 'description' => ts('Which language is preferred for communication. FK to languages in civicrm_option_value.'),
783 'size' => CRM_Utils_Type
::SIX
,
785 'where' => 'civicrm_contact.preferred_language',
786 'headerPattern' => '/^lang/i',
788 'table_name' => 'civicrm_contact',
789 'entity' => 'Contact',
790 'bao' => 'CRM_Contact_BAO_Contact',
795 'pseudoconstant' => [
796 'optionGroupName' => 'languages',
797 'keyColumn' => 'name',
798 'optionEditPath' => 'civicrm/admin/options/languages',
802 'preferred_mail_format' => [
803 'name' => 'preferred_mail_format',
804 'type' => CRM_Utils_Type
::T_STRING
,
805 'title' => ts('Preferred Mail Format'),
806 'description' => ts('What is the preferred mode of sending an email.'),
808 'size' => CRM_Utils_Type
::EIGHT
,
810 'where' => 'civicrm_contact.preferred_mail_format',
811 'headerPattern' => '/^p(ref\w*\s)?m(ail\s)?f(orm\w*)$/i',
814 'table_name' => 'civicrm_contact',
815 'entity' => 'Contact',
816 'bao' => 'CRM_Contact_BAO_Contact',
821 'pseudoconstant' => [
822 'callback' => 'CRM_Core_SelectValues::pmf',
828 'type' => CRM_Utils_Type
::T_STRING
,
829 'title' => ts('Contact Hash'),
830 'description' => ts('Key for validating requests related to this contact.'),
832 'size' => CRM_Utils_Type
::MEDIUM
,
833 'where' => 'civicrm_contact.hash',
835 'table_name' => 'civicrm_contact',
836 'entity' => 'Contact',
837 'bao' => 'CRM_Contact_BAO_Contact',
843 'type' => CRM_Utils_Type
::T_STRING
,
844 'title' => ts('Api Key'),
845 'description' => ts('API Key for validating requests related to this contact.'),
847 'size' => CRM_Utils_Type
::MEDIUM
,
848 'where' => 'civicrm_contact.api_key',
851 'administer CiviCRM',
855 'table_name' => 'civicrm_contact',
856 'entity' => 'Contact',
857 'bao' => 'CRM_Contact_BAO_Contact',
861 'contact_source' => [
863 'type' => CRM_Utils_Type
::T_STRING
,
864 'title' => ts('Contact Source'),
865 'description' => ts('where contact come from, e.g. import, donate module insert...'),
869 'where' => 'civicrm_contact.source',
870 'headerPattern' => '/(C(ontact\s)?Source)$/i',
872 'table_name' => 'civicrm_contact',
873 'entity' => 'Contact',
874 'bao' => 'CRM_Contact_BAO_Contact',
882 'name' => 'first_name',
883 'type' => CRM_Utils_Type
::T_STRING
,
884 'title' => ts('First Name'),
885 'description' => ts('First Name.'),
889 'where' => 'civicrm_contact.first_name',
890 'headerPattern' => '/^first|(f(irst\s)?name)$/i',
891 'dataPattern' => '/^\w+$/',
893 'contactType' => 'Individual',
894 'table_name' => 'civicrm_contact',
895 'entity' => 'Contact',
896 'bao' => 'CRM_Contact_BAO_Contact',
904 'name' => 'middle_name',
905 'type' => CRM_Utils_Type
::T_STRING
,
906 'title' => ts('Middle Name'),
907 'description' => ts('Middle Name.'),
911 'where' => 'civicrm_contact.middle_name',
912 'headerPattern' => '/^middle|(m(iddle\s)?name)$/i',
913 'dataPattern' => '/^\w+$/',
915 'contactType' => 'Individual',
916 'table_name' => 'civicrm_contact',
917 'entity' => 'Contact',
918 'bao' => 'CRM_Contact_BAO_Contact',
926 'name' => 'last_name',
927 'type' => CRM_Utils_Type
::T_STRING
,
928 'title' => ts('Last Name'),
929 'description' => ts('Last Name.'),
933 'where' => 'civicrm_contact.last_name',
934 'headerPattern' => '/^last|(l(ast\s)?name)$/i',
935 'dataPattern' => '/^\w+(\s\w+)?+$/',
937 'contactType' => 'Individual',
938 'table_name' => 'civicrm_contact',
939 'entity' => 'Contact',
940 'bao' => 'CRM_Contact_BAO_Contact',
948 'name' => 'prefix_id',
949 'type' => CRM_Utils_Type
::T_INT
,
950 'title' => ts('Individual Prefix'),
951 'description' => ts('Prefix or Title for name (Ms, Mr...). FK to prefix ID'),
953 'where' => 'civicrm_contact.prefix_id',
954 'headerPattern' => '/^(prefix|title)/i',
955 'dataPattern' => '/^(mr|ms|mrs|sir|dr)\.?$/i',
957 'contactType' => 'Individual',
958 'table_name' => 'civicrm_contact',
959 'entity' => 'Contact',
960 'bao' => 'CRM_Contact_BAO_Contact',
965 'pseudoconstant' => [
966 'optionGroupName' => 'individual_prefix',
967 'optionEditPath' => 'civicrm/admin/options/individual_prefix',
972 'name' => 'suffix_id',
973 'type' => CRM_Utils_Type
::T_INT
,
974 'title' => ts('Individual Suffix'),
975 'description' => ts('Suffix for name (Jr, Sr...). FK to suffix ID'),
977 'where' => 'civicrm_contact.suffix_id',
978 'headerPattern' => '/^suffix$/i',
979 'dataPattern' => '/^(sr|jr)\.?|i{2,}$/',
981 'contactType' => 'Individual',
982 'table_name' => 'civicrm_contact',
983 'entity' => 'Contact',
984 'bao' => 'CRM_Contact_BAO_Contact',
989 'pseudoconstant' => [
990 'optionGroupName' => 'individual_suffix',
991 'optionEditPath' => 'civicrm/admin/options/individual_suffix',
996 'name' => 'formal_title',
997 'type' => CRM_Utils_Type
::T_STRING
,
998 'title' => ts('Formal Title'),
999 'description' => ts('Formal (academic or similar) title in front of name. (Prof., Dr. etc.)'),
1001 'size' => CRM_Utils_Type
::BIG
,
1003 'where' => 'civicrm_contact.formal_title',
1004 'headerPattern' => '/^title/i',
1006 'contactType' => 'Individual',
1007 'table_name' => 'civicrm_contact',
1008 'entity' => 'Contact',
1009 'bao' => 'CRM_Contact_BAO_Contact',
1016 'communication_style_id' => [
1017 'name' => 'communication_style_id',
1018 'type' => CRM_Utils_Type
::T_INT
,
1019 'title' => ts('Communication Style'),
1020 'description' => ts('Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.'),
1022 'where' => 'civicrm_contact.communication_style_id',
1023 'headerPattern' => '/style/i',
1025 'table_name' => 'civicrm_contact',
1026 'entity' => 'Contact',
1027 'bao' => 'CRM_Contact_BAO_Contact',
1032 'pseudoconstant' => [
1033 'optionGroupName' => 'communication_style',
1034 'optionEditPath' => 'civicrm/admin/options/communication_style',
1038 'email_greeting_id' => [
1039 'name' => 'email_greeting_id',
1040 'type' => CRM_Utils_Type
::T_INT
,
1041 'title' => ts('Email Greeting ID'),
1042 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Email Greeting.'),
1043 'where' => 'civicrm_contact.email_greeting_id',
1045 'table_name' => 'civicrm_contact',
1046 'entity' => 'Contact',
1047 'bao' => 'CRM_Contact_BAO_Contact',
1052 'pseudoconstant' => [
1053 'optionGroupName' => 'email_greeting',
1054 'optionEditPath' => 'civicrm/admin/options/email_greeting',
1058 'email_greeting_custom' => [
1059 'name' => 'email_greeting_custom',
1060 'type' => CRM_Utils_Type
::T_STRING
,
1061 'title' => ts('Email Greeting Custom'),
1062 'description' => ts('Custom Email Greeting.'),
1064 'size' => CRM_Utils_Type
::HUGE
,
1066 'where' => 'civicrm_contact.email_greeting_custom',
1068 'table_name' => 'civicrm_contact',
1069 'entity' => 'Contact',
1070 'bao' => 'CRM_Contact_BAO_Contact',
1077 'email_greeting_display' => [
1078 'name' => 'email_greeting_display',
1079 'type' => CRM_Utils_Type
::T_STRING
,
1080 'title' => ts('Email Greeting'),
1081 'description' => ts('Cache Email Greeting.'),
1083 'size' => CRM_Utils_Type
::HUGE
,
1084 'where' => 'civicrm_contact.email_greeting_display',
1085 'table_name' => 'civicrm_contact',
1086 'entity' => 'Contact',
1087 'bao' => 'CRM_Contact_BAO_Contact',
1091 'postal_greeting_id' => [
1092 'name' => 'postal_greeting_id',
1093 'type' => CRM_Utils_Type
::T_INT
,
1094 'title' => ts('Postal Greeting ID'),
1095 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.'),
1096 'where' => 'civicrm_contact.postal_greeting_id',
1098 'table_name' => 'civicrm_contact',
1099 'entity' => 'Contact',
1100 'bao' => 'CRM_Contact_BAO_Contact',
1105 'pseudoconstant' => [
1106 'optionGroupName' => 'postal_greeting',
1107 'optionEditPath' => 'civicrm/admin/options/postal_greeting',
1111 'postal_greeting_custom' => [
1112 'name' => 'postal_greeting_custom',
1113 'type' => CRM_Utils_Type
::T_STRING
,
1114 'title' => ts('Postal Greeting Custom'),
1115 'description' => ts('Custom Postal greeting.'),
1117 'size' => CRM_Utils_Type
::HUGE
,
1119 'where' => 'civicrm_contact.postal_greeting_custom',
1121 'table_name' => 'civicrm_contact',
1122 'entity' => 'Contact',
1123 'bao' => 'CRM_Contact_BAO_Contact',
1130 'postal_greeting_display' => [
1131 'name' => 'postal_greeting_display',
1132 'type' => CRM_Utils_Type
::T_STRING
,
1133 'title' => ts('Postal Greeting'),
1134 'description' => ts('Cache Postal greeting.'),
1136 'size' => CRM_Utils_Type
::HUGE
,
1137 'where' => 'civicrm_contact.postal_greeting_display',
1138 'table_name' => 'civicrm_contact',
1139 'entity' => 'Contact',
1140 'bao' => 'CRM_Contact_BAO_Contact',
1145 'name' => 'addressee_id',
1146 'type' => CRM_Utils_Type
::T_INT
,
1147 'title' => ts('Addressee ID'),
1148 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Addressee.'),
1149 'where' => 'civicrm_contact.addressee_id',
1151 'table_name' => 'civicrm_contact',
1152 'entity' => 'Contact',
1153 'bao' => 'CRM_Contact_BAO_Contact',
1158 'pseudoconstant' => [
1159 'optionGroupName' => 'addressee',
1160 'optionEditPath' => 'civicrm/admin/options/addressee',
1164 'addressee_custom' => [
1165 'name' => 'addressee_custom',
1166 'type' => CRM_Utils_Type
::T_STRING
,
1167 'title' => ts('Addressee Custom'),
1168 'description' => ts('Custom Addressee.'),
1170 'size' => CRM_Utils_Type
::HUGE
,
1172 'where' => 'civicrm_contact.addressee_custom',
1174 'table_name' => 'civicrm_contact',
1175 'entity' => 'Contact',
1176 'bao' => 'CRM_Contact_BAO_Contact',
1183 'addressee_display' => [
1184 'name' => 'addressee_display',
1185 'type' => CRM_Utils_Type
::T_STRING
,
1186 'title' => ts('Addressee'),
1187 'description' => ts('Cache Addressee.'),
1189 'size' => CRM_Utils_Type
::HUGE
,
1190 'where' => 'civicrm_contact.addressee_display',
1191 'table_name' => 'civicrm_contact',
1192 'entity' => 'Contact',
1193 'bao' => 'CRM_Contact_BAO_Contact',
1198 'name' => 'job_title',
1199 'type' => CRM_Utils_Type
::T_STRING
,
1200 'title' => ts('Job Title'),
1201 'description' => ts('Job Title'),
1205 'where' => 'civicrm_contact.job_title',
1206 'headerPattern' => '/^job|(j(ob\s)?title)$/i',
1207 'dataPattern' => '//',
1209 'contactType' => 'Individual',
1210 'table_name' => 'civicrm_contact',
1211 'entity' => 'Contact',
1212 'bao' => 'CRM_Contact_BAO_Contact',
1220 'name' => 'gender_id',
1221 'type' => CRM_Utils_Type
::T_INT
,
1222 'title' => ts('Gender ID'),
1223 'description' => ts('FK to gender ID'),
1225 'where' => 'civicrm_contact.gender_id',
1226 'headerPattern' => '/^gender$/i',
1228 'contactType' => 'Individual',
1229 'table_name' => 'civicrm_contact',
1230 'entity' => 'Contact',
1231 'bao' => 'CRM_Contact_BAO_Contact',
1235 'label' => ts("Gender"),
1237 'pseudoconstant' => [
1238 'optionGroupName' => 'gender',
1239 'optionEditPath' => 'civicrm/admin/options/gender',
1244 'name' => 'birth_date',
1245 'type' => CRM_Utils_Type
::T_DATE
,
1246 'title' => ts('Birth Date'),
1247 'description' => ts('Date of birth'),
1249 'where' => 'civicrm_contact.birth_date',
1250 'headerPattern' => '/^birth|(b(irth\s)?date)|D(\W*)O(\W*)B(\W*)$/i',
1251 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
1253 'contactType' => 'Individual',
1254 'table_name' => 'civicrm_contact',
1255 'entity' => 'Contact',
1256 'bao' => 'CRM_Contact_BAO_Contact',
1259 'type' => 'Select Date',
1260 'formatType' => 'birth',
1265 'name' => 'is_deceased',
1266 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1267 'title' => ts('Deceased'),
1270 'where' => 'civicrm_contact.is_deceased',
1271 'headerPattern' => '/i(s\s)?d(eceased)$/i',
1273 'contactType' => 'Individual',
1275 'table_name' => 'civicrm_contact',
1276 'entity' => 'Contact',
1277 'bao' => 'CRM_Contact_BAO_Contact',
1280 'type' => 'CheckBox',
1284 'deceased_date' => [
1285 'name' => 'deceased_date',
1286 'type' => CRM_Utils_Type
::T_DATE
,
1287 'title' => ts('Deceased Date'),
1288 'description' => ts('Date of deceased'),
1290 'where' => 'civicrm_contact.deceased_date',
1291 'headerPattern' => '/^deceased|(d(eceased\s)?date)$/i',
1293 'contactType' => 'Individual',
1294 'table_name' => 'civicrm_contact',
1295 'entity' => 'Contact',
1296 'bao' => 'CRM_Contact_BAO_Contact',
1299 'type' => 'Select Date',
1300 'formatType' => 'birth',
1304 'household_name' => [
1305 'name' => 'household_name',
1306 'type' => CRM_Utils_Type
::T_STRING
,
1307 'title' => ts('Household Name'),
1308 'description' => ts('Household Name.'),
1312 'where' => 'civicrm_contact.household_name',
1313 'headerPattern' => '/^household|(h(ousehold\s)?name)$/i',
1314 'dataPattern' => '/^\w+$/',
1316 'contactType' => 'Household',
1317 'table_name' => 'civicrm_contact',
1318 'entity' => 'Contact',
1319 'bao' => 'CRM_Contact_BAO_Contact',
1326 'primary_contact_id' => [
1327 'name' => 'primary_contact_id',
1328 'type' => CRM_Utils_Type
::T_INT
,
1329 'title' => ts('Household Primary Contact ID'),
1330 'description' => ts('Optional FK to Primary Contact for this household.'),
1331 'where' => 'civicrm_contact.primary_contact_id',
1332 'contactType' => 'Household',
1333 'table_name' => 'civicrm_contact',
1334 'entity' => 'Contact',
1335 'bao' => 'CRM_Contact_BAO_Contact',
1337 'FKClassName' => 'CRM_Contact_DAO_Contact',
1340 'organization_name' => [
1341 'name' => 'organization_name',
1342 'type' => CRM_Utils_Type
::T_STRING
,
1343 'title' => ts('Organization Name'),
1344 'description' => ts('Organization Name.'),
1348 'where' => 'civicrm_contact.organization_name',
1349 'headerPattern' => '/^organization|(o(rganization\s)?name)$/i',
1350 'dataPattern' => '/^\w+$/',
1352 'contactType' => 'Organization',
1353 'table_name' => 'civicrm_contact',
1354 'entity' => 'Contact',
1355 'bao' => 'CRM_Contact_BAO_Contact',
1363 'name' => 'sic_code',
1364 'type' => CRM_Utils_Type
::T_STRING
,
1365 'title' => ts('Sic Code'),
1366 'description' => ts('Standard Industry Classification Code.'),
1368 'size' => CRM_Utils_Type
::EIGHT
,
1370 'where' => 'civicrm_contact.sic_code',
1371 'headerPattern' => '/^sic|(s(ic\s)?code)$/i',
1373 'contactType' => 'Organization',
1374 'table_name' => 'civicrm_contact',
1375 'entity' => 'Contact',
1376 'bao' => 'CRM_Contact_BAO_Contact',
1383 'user_unique_id' => [
1384 'name' => 'user_unique_id',
1385 'type' => CRM_Utils_Type
::T_STRING
,
1386 'title' => ts('Unique ID (OpenID)'),
1387 'description' => ts('the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM'),
1389 'size' => CRM_Utils_Type
::HUGE
,
1391 'where' => 'civicrm_contact.user_unique_id',
1392 'headerPattern' => '/^Open\s?ID|u(niq\w*)?\s?ID/i',
1393 'dataPattern' => '/^[\w\/\:\.]+$/',
1396 'table_name' => 'civicrm_contact',
1397 'entity' => 'Contact',
1398 'bao' => 'CRM_Contact_BAO_Contact',
1405 'current_employer_id' => [
1406 'name' => 'employer_id',
1407 'type' => CRM_Utils_Type
::T_INT
,
1408 'title' => ts('Current Employer ID'),
1409 'description' => ts('OPTIONAL FK to civicrm_contact record.'),
1410 'where' => 'civicrm_contact.employer_id',
1412 'contactType' => 'Individual',
1413 'table_name' => 'civicrm_contact',
1414 'entity' => 'Contact',
1415 'bao' => 'CRM_Contact_BAO_Contact',
1417 'FKClassName' => 'CRM_Contact_DAO_Contact',
1419 'type' => 'EntityRef',
1420 'label' => ts("Current Employer"),
1424 'contact_is_deleted' => [
1425 'name' => 'is_deleted',
1426 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1427 'title' => ts('Contact is in Trash'),
1429 'where' => 'civicrm_contact.is_deleted',
1432 'access deleted contacts',
1435 'table_name' => 'civicrm_contact',
1436 'entity' => 'Contact',
1437 'bao' => 'CRM_Contact_BAO_Contact',
1440 'type' => 'CheckBox',
1445 'name' => 'created_date',
1446 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
1447 'title' => ts('Created Date'),
1448 'description' => ts('When was the contact was created.'),
1449 'required' => FALSE,
1450 'where' => 'civicrm_contact.created_date',
1452 'default' => 'NULL',
1453 'table_name' => 'civicrm_contact',
1454 'entity' => 'Contact',
1455 'bao' => 'CRM_Contact_BAO_Contact',
1459 'modified_date' => [
1460 'name' => 'modified_date',
1461 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
1462 'title' => ts('Modified Date'),
1463 'description' => ts('When was the contact (or closely related entity) was created or modified or deleted.'),
1464 'required' => FALSE,
1465 'where' => 'civicrm_contact.modified_date',
1467 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
1468 'table_name' => 'civicrm_contact',
1469 'entity' => 'Contact',
1470 'bao' => 'CRM_Contact_BAO_Contact',
1475 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
1477 return Civi
::$statics[__CLASS__
]['fields'];
1481 * Return a mapping from field-name to the corresponding key (as used in fields()).
1484 * Array(string $name => string $uniqueName).
1486 public static function &fieldKeys() {
1487 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
1488 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
1490 return Civi
::$statics[__CLASS__
]['fieldKeys'];
1494 * Returns the names of this table
1498 public static function getTableName() {
1499 return self
::$_tableName;
1503 * Returns if this table needs to be logged
1507 public function getLog() {
1512 * Returns the list of fields that can be imported
1514 * @param bool $prefix
1518 public static function &import($prefix = FALSE) {
1519 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'contact', $prefix, []);
1524 * Returns the list of fields that can be exported
1526 * @param bool $prefix
1530 public static function &export($prefix = FALSE) {
1531 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'contact', $prefix, []);
1536 * Returns the list of indices
1538 * @param bool $localize
1542 public static function indices($localize = TRUE) {
1544 'index_contact_type' => [
1545 'name' => 'index_contact_type',
1547 0 => 'contact_type',
1549 'localizable' => FALSE,
1550 'sig' => 'civicrm_contact::0::contact_type',
1552 'index_contact_sub_type' => [
1553 'name' => 'index_contact_sub_type',
1555 0 => 'contact_sub_type',
1557 'localizable' => FALSE,
1558 'sig' => 'civicrm_contact::0::contact_sub_type',
1560 'UI_external_identifier' => [
1561 'name' => 'UI_external_identifier',
1563 0 => 'external_identifier',
1565 'localizable' => FALSE,
1567 'sig' => 'civicrm_contact::1::external_identifier',
1569 'index_sort_name' => [
1570 'name' => 'index_sort_name',
1574 'localizable' => FALSE,
1575 'sig' => 'civicrm_contact::0::sort_name',
1577 'index_preferred_communication_method' => [
1578 'name' => 'index_preferred_communication_method',
1580 0 => 'preferred_communication_method',
1582 'localizable' => FALSE,
1583 'sig' => 'civicrm_contact::0::preferred_communication_method',
1586 'name' => 'index_hash',
1590 'localizable' => FALSE,
1591 'sig' => 'civicrm_contact::0::hash',
1593 'index_api_key' => [
1594 'name' => 'index_api_key',
1598 'localizable' => FALSE,
1599 'sig' => 'civicrm_contact::0::api_key',
1601 'index_first_name' => [
1602 'name' => 'index_first_name',
1606 'localizable' => FALSE,
1607 'sig' => 'civicrm_contact::0::first_name',
1609 'index_last_name' => [
1610 'name' => 'index_last_name',
1614 'localizable' => FALSE,
1615 'sig' => 'civicrm_contact::0::last_name',
1618 'name' => 'UI_prefix',
1622 'localizable' => FALSE,
1623 'sig' => 'civicrm_contact::0::prefix_id',
1626 'name' => 'UI_suffix',
1630 'localizable' => FALSE,
1631 'sig' => 'civicrm_contact::0::suffix_id',
1633 'index_communication_style_id' => [
1634 'name' => 'index_communication_style_id',
1636 0 => 'communication_style_id',
1638 'localizable' => FALSE,
1639 'sig' => 'civicrm_contact::0::communication_style_id',
1642 'name' => 'UI_gender',
1646 'localizable' => FALSE,
1647 'sig' => 'civicrm_contact::0::gender_id',
1649 'index_is_deceased' => [
1650 'name' => 'index_is_deceased',
1654 'localizable' => FALSE,
1655 'sig' => 'civicrm_contact::0::is_deceased',
1657 'index_household_name' => [
1658 'name' => 'index_household_name',
1660 0 => 'household_name',
1662 'localizable' => FALSE,
1663 'sig' => 'civicrm_contact::0::household_name',
1665 'index_organization_name' => [
1666 'name' => 'index_organization_name',
1668 0 => 'organization_name',
1670 'localizable' => FALSE,
1671 'sig' => 'civicrm_contact::0::organization_name',
1673 'index_is_deleted_sort_name' => [
1674 'name' => 'index_is_deleted_sort_name',
1680 'localizable' => FALSE,
1681 'sig' => 'civicrm_contact::0::is_deleted::sort_name::id',
1683 'index_created_date' => [
1684 'name' => 'index_created_date',
1686 0 => 'created_date',
1688 'localizable' => FALSE,
1689 'sig' => 'civicrm_contact::0::created_date',
1691 'index_modified_date' => [
1692 'name' => 'index_modified_date',
1694 0 => 'modified_date',
1696 'localizable' => FALSE,
1697 'sig' => 'civicrm_contact::0::modified_date',
1700 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;