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:f58884560d4f49764182cd97f1bbbcdf)
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 public static function getEntityTitle() {
402 return ts('Contacts');
406 * Returns foreign keys and entity references.
409 * [CRM_Core_Reference_Interface]
411 public static function getReferenceColumns() {
412 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
413 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
414 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'primary_contact_id', 'civicrm_contact', 'id');
415 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'employer_id', 'civicrm_contact', 'id');
416 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
418 return Civi
::$statics[__CLASS__
]['links'];
422 * Returns all the column names of this table
426 public static function &fields() {
427 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
428 Civi
::$statics[__CLASS__
]['fields'] = [
431 'type' => CRM_Utils_Type
::T_INT
,
432 'title' => ts('Contact ID'),
433 'description' => ts('Unique Contact ID'),
436 'where' => 'civicrm_contact.id',
437 'headerPattern' => '/internal|contact?|id$/i',
439 'table_name' => 'civicrm_contact',
440 'entity' => 'Contact',
441 'bao' => 'CRM_Contact_BAO_Contact',
446 'name' => 'contact_type',
447 'type' => CRM_Utils_Type
::T_STRING
,
448 'title' => ts('Contact Type'),
449 'description' => ts('Type of Contact.'),
451 'size' => CRM_Utils_Type
::BIG
,
452 'where' => 'civicrm_contact.contact_type',
454 'contactType' => NULL,
455 'table_name' => 'civicrm_contact',
456 'entity' => 'Contact',
457 'bao' => 'CRM_Contact_BAO_Contact',
462 'pseudoconstant' => [
463 'table' => 'civicrm_contact_type',
464 'keyColumn' => 'name',
465 'labelColumn' => 'label',
466 'condition' => 'parent_id IS NULL',
470 'contact_sub_type' => [
471 'name' => 'contact_sub_type',
472 'type' => CRM_Utils_Type
::T_STRING
,
473 'title' => ts('Contact Subtype'),
474 'description' => ts('May be used to over-ride contact view and edit templates.'),
476 'size' => CRM_Utils_Type
::HUGE
,
478 'where' => 'civicrm_contact.contact_sub_type',
479 'headerPattern' => '/C(ontact )?(subtype|sub-type|sub type)/i',
481 'table_name' => 'civicrm_contact',
482 'entity' => 'Contact',
483 'bao' => 'CRM_Contact_BAO_Contact',
485 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
489 'pseudoconstant' => [
490 'table' => 'civicrm_contact_type',
491 'keyColumn' => 'name',
492 'labelColumn' => 'label',
493 'condition' => 'parent_id IS NOT NULL',
498 'name' => 'do_not_email',
499 'type' => CRM_Utils_Type
::T_BOOLEAN
,
500 'title' => ts('Do Not Email'),
502 'where' => 'civicrm_contact.do_not_email',
503 'headerPattern' => '/d(o )?(not )?(email)/i',
504 'dataPattern' => '/^\d{1,}$/',
507 'table_name' => 'civicrm_contact',
508 'entity' => 'Contact',
509 'bao' => 'CRM_Contact_BAO_Contact',
512 'type' => 'CheckBox',
517 'name' => 'do_not_phone',
518 'type' => CRM_Utils_Type
::T_BOOLEAN
,
519 'title' => ts('Do Not Phone'),
521 'where' => 'civicrm_contact.do_not_phone',
522 'headerPattern' => '/d(o )?(not )?(call|phone)/i',
523 'dataPattern' => '/^\d{1,}$/',
526 'table_name' => 'civicrm_contact',
527 'entity' => 'Contact',
528 'bao' => 'CRM_Contact_BAO_Contact',
531 'type' => 'CheckBox',
536 'name' => 'do_not_mail',
537 'type' => CRM_Utils_Type
::T_BOOLEAN
,
538 'title' => ts('Do Not Mail'),
540 'where' => 'civicrm_contact.do_not_mail',
541 'headerPattern' => '/^(d(o\s)?n(ot\s)?mail)|(\w*)?bulk\s?(\w*)$/i',
542 'dataPattern' => '/^\d{1,}$/',
545 'table_name' => 'civicrm_contact',
546 'entity' => 'Contact',
547 'bao' => 'CRM_Contact_BAO_Contact',
550 'type' => 'CheckBox',
555 'name' => 'do_not_sms',
556 'type' => CRM_Utils_Type
::T_BOOLEAN
,
557 'title' => ts('Do Not Sms'),
559 'where' => 'civicrm_contact.do_not_sms',
560 'headerPattern' => '/d(o )?(not )?(sms)/i',
561 'dataPattern' => '/^\d{1,}$/',
564 'table_name' => 'civicrm_contact',
565 'entity' => 'Contact',
566 'bao' => 'CRM_Contact_BAO_Contact',
569 'type' => 'CheckBox',
574 'name' => 'do_not_trade',
575 'type' => CRM_Utils_Type
::T_BOOLEAN
,
576 'title' => ts('Do Not Trade'),
578 'where' => 'civicrm_contact.do_not_trade',
579 'headerPattern' => '/d(o )?(not )?(trade)/i',
580 'dataPattern' => '/^\d{1,}$/',
583 'table_name' => 'civicrm_contact',
584 'entity' => 'Contact',
585 'bao' => 'CRM_Contact_BAO_Contact',
588 'type' => 'CheckBox',
593 'name' => 'is_opt_out',
594 'type' => CRM_Utils_Type
::T_BOOLEAN
,
595 'title' => ts('No Bulk Emails (User Opt Out)'),
596 'description' => ts('Has the contact opted out from receiving all bulk email from the organization or site domain?'),
599 'where' => 'civicrm_contact.is_opt_out',
602 'table_name' => 'civicrm_contact',
603 'entity' => 'Contact',
604 'bao' => 'CRM_Contact_BAO_Contact',
607 'type' => 'CheckBox',
611 'legal_identifier' => [
612 'name' => 'legal_identifier',
613 'type' => CRM_Utils_Type
::T_STRING
,
614 'title' => ts('Legal Identifier'),
615 'description' => ts('May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.'),
617 'size' => CRM_Utils_Type
::MEDIUM
,
619 'where' => 'civicrm_contact.legal_identifier',
620 'headerPattern' => '/legal\s?id/i',
621 'dataPattern' => '/\w+?\d{5,}/',
623 'table_name' => 'civicrm_contact',
624 'entity' => 'Contact',
625 'bao' => 'CRM_Contact_BAO_Contact',
632 'external_identifier' => [
633 'name' => 'external_identifier',
634 'type' => CRM_Utils_Type
::T_STRING
,
635 'title' => ts('External Identifier'),
636 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
640 'where' => 'civicrm_contact.external_identifier',
641 'headerPattern' => '/external\s?id/i',
642 'dataPattern' => '/^\d{11,}$/',
644 'table_name' => 'civicrm_contact',
645 'entity' => 'Contact',
646 'bao' => 'CRM_Contact_BAO_Contact',
654 'name' => 'sort_name',
655 'type' => CRM_Utils_Type
::T_STRING
,
656 'title' => ts('Sort Name'),
657 'description' => ts('Name used for sorting different contact types'),
660 'where' => 'civicrm_contact.sort_name',
662 'table_name' => 'civicrm_contact',
663 'entity' => 'Contact',
664 'bao' => 'CRM_Contact_BAO_Contact',
672 'name' => 'display_name',
673 'type' => CRM_Utils_Type
::T_STRING
,
674 'title' => ts('Display Name'),
675 'description' => ts('Formatted name representing preferred format for display/print/other output.'),
678 'where' => 'civicrm_contact.display_name',
680 'table_name' => 'civicrm_contact',
681 'entity' => 'Contact',
682 'bao' => 'CRM_Contact_BAO_Contact',
690 'name' => 'nick_name',
691 'type' => CRM_Utils_Type
::T_STRING
,
692 'title' => ts('Nickname'),
693 'description' => ts('Nickname.'),
697 'where' => 'civicrm_contact.nick_name',
698 'headerPattern' => '/n(ick\s)name|nick$/i',
699 'dataPattern' => '/^\w+$/',
701 'table_name' => 'civicrm_contact',
702 'entity' => 'Contact',
703 'bao' => 'CRM_Contact_BAO_Contact',
711 'name' => 'legal_name',
712 'type' => CRM_Utils_Type
::T_STRING
,
713 'title' => ts('Legal Name'),
714 'description' => ts('Legal Name.'),
718 'where' => 'civicrm_contact.legal_name',
719 'headerPattern' => '/^legal|(l(egal\s)?name)$/i',
721 'contactType' => 'Organization',
722 'table_name' => 'civicrm_contact',
723 'entity' => 'Contact',
724 'bao' => 'CRM_Contact_BAO_Contact',
732 'name' => 'image_URL',
733 'type' => CRM_Utils_Type
::T_TEXT
,
734 'title' => ts('Image Url'),
735 'description' => ts('optional URL for preferred image (photo, logo, etc.) to display for this contact.'),
737 'where' => 'civicrm_contact.image_URL',
739 'table_name' => 'civicrm_contact',
740 'entity' => 'Contact',
741 'bao' => 'CRM_Contact_BAO_Contact',
748 'preferred_communication_method' => [
749 'name' => 'preferred_communication_method',
750 'type' => CRM_Utils_Type
::T_STRING
,
751 'title' => ts('Preferred Communication Method'),
752 'description' => ts('What is the preferred mode of communication.'),
754 'size' => CRM_Utils_Type
::HUGE
,
756 'where' => 'civicrm_contact.preferred_communication_method',
757 'headerPattern' => '/^p(ref\w*\s)?c(omm\w*)|( meth\w*)$/i',
758 'dataPattern' => '/^\w+$/',
760 'table_name' => 'civicrm_contact',
761 'entity' => 'Contact',
762 'bao' => 'CRM_Contact_BAO_Contact',
764 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
768 'pseudoconstant' => [
769 'optionGroupName' => 'preferred_communication_method',
770 'optionEditPath' => 'civicrm/admin/options/preferred_communication_method',
774 'preferred_language' => [
775 'name' => 'preferred_language',
776 'type' => CRM_Utils_Type
::T_STRING
,
777 'title' => ts('Preferred Language'),
778 'description' => ts('Which language is preferred for communication. FK to languages in civicrm_option_value.'),
780 'size' => CRM_Utils_Type
::SIX
,
782 'where' => 'civicrm_contact.preferred_language',
783 'headerPattern' => '/^lang/i',
785 'table_name' => 'civicrm_contact',
786 'entity' => 'Contact',
787 'bao' => 'CRM_Contact_BAO_Contact',
792 'pseudoconstant' => [
793 'optionGroupName' => 'languages',
794 'keyColumn' => 'name',
795 'optionEditPath' => 'civicrm/admin/options/languages',
799 'preferred_mail_format' => [
800 'name' => 'preferred_mail_format',
801 'type' => CRM_Utils_Type
::T_STRING
,
802 'title' => ts('Preferred Mail Format'),
803 'description' => ts('What is the preferred mode of sending an email.'),
805 'size' => CRM_Utils_Type
::EIGHT
,
807 'where' => 'civicrm_contact.preferred_mail_format',
808 'headerPattern' => '/^p(ref\w*\s)?m(ail\s)?f(orm\w*)$/i',
811 'table_name' => 'civicrm_contact',
812 'entity' => 'Contact',
813 'bao' => 'CRM_Contact_BAO_Contact',
818 'pseudoconstant' => [
819 'callback' => 'CRM_Core_SelectValues::pmf',
825 'type' => CRM_Utils_Type
::T_STRING
,
826 'title' => ts('Contact Hash'),
827 'description' => ts('Key for validating requests related to this contact.'),
829 'size' => CRM_Utils_Type
::MEDIUM
,
830 'where' => 'civicrm_contact.hash',
832 'table_name' => 'civicrm_contact',
833 'entity' => 'Contact',
834 'bao' => 'CRM_Contact_BAO_Contact',
840 'type' => CRM_Utils_Type
::T_STRING
,
841 'title' => ts('Api Key'),
842 'description' => ts('API Key for validating requests related to this contact.'),
844 'size' => CRM_Utils_Type
::MEDIUM
,
845 'where' => 'civicrm_contact.api_key',
848 'administer CiviCRM',
852 'table_name' => 'civicrm_contact',
853 'entity' => 'Contact',
854 'bao' => 'CRM_Contact_BAO_Contact',
858 'contact_source' => [
860 'type' => CRM_Utils_Type
::T_STRING
,
861 'title' => ts('Contact Source'),
862 'description' => ts('where contact come from, e.g. import, donate module insert...'),
866 'where' => 'civicrm_contact.source',
867 'headerPattern' => '/(C(ontact\s)?Source)$/i',
869 'table_name' => 'civicrm_contact',
870 'entity' => 'Contact',
871 'bao' => 'CRM_Contact_BAO_Contact',
879 'name' => 'first_name',
880 'type' => CRM_Utils_Type
::T_STRING
,
881 'title' => ts('First Name'),
882 'description' => ts('First Name.'),
886 'where' => 'civicrm_contact.first_name',
887 'headerPattern' => '/^first|(f(irst\s)?name)$/i',
888 'dataPattern' => '/^\w+$/',
890 'contactType' => 'Individual',
891 'table_name' => 'civicrm_contact',
892 'entity' => 'Contact',
893 'bao' => 'CRM_Contact_BAO_Contact',
901 'name' => 'middle_name',
902 'type' => CRM_Utils_Type
::T_STRING
,
903 'title' => ts('Middle Name'),
904 'description' => ts('Middle Name.'),
908 'where' => 'civicrm_contact.middle_name',
909 'headerPattern' => '/^middle|(m(iddle\s)?name)$/i',
910 'dataPattern' => '/^\w+$/',
912 'contactType' => 'Individual',
913 'table_name' => 'civicrm_contact',
914 'entity' => 'Contact',
915 'bao' => 'CRM_Contact_BAO_Contact',
923 'name' => 'last_name',
924 'type' => CRM_Utils_Type
::T_STRING
,
925 'title' => ts('Last Name'),
926 'description' => ts('Last Name.'),
930 'where' => 'civicrm_contact.last_name',
931 'headerPattern' => '/^last|(l(ast\s)?name)$/i',
932 'dataPattern' => '/^\w+(\s\w+)?+$/',
934 'contactType' => 'Individual',
935 'table_name' => 'civicrm_contact',
936 'entity' => 'Contact',
937 'bao' => 'CRM_Contact_BAO_Contact',
945 'name' => 'prefix_id',
946 'type' => CRM_Utils_Type
::T_INT
,
947 'title' => ts('Individual Prefix'),
948 'description' => ts('Prefix or Title for name (Ms, Mr...). FK to prefix ID'),
950 'where' => 'civicrm_contact.prefix_id',
951 'headerPattern' => '/^(prefix|title)/i',
952 'dataPattern' => '/^(mr|ms|mrs|sir|dr)\.?$/i',
954 'contactType' => 'Individual',
955 'table_name' => 'civicrm_contact',
956 'entity' => 'Contact',
957 'bao' => 'CRM_Contact_BAO_Contact',
962 'pseudoconstant' => [
963 'optionGroupName' => 'individual_prefix',
964 'optionEditPath' => 'civicrm/admin/options/individual_prefix',
969 'name' => 'suffix_id',
970 'type' => CRM_Utils_Type
::T_INT
,
971 'title' => ts('Individual Suffix'),
972 'description' => ts('Suffix for name (Jr, Sr...). FK to suffix ID'),
974 'where' => 'civicrm_contact.suffix_id',
975 'headerPattern' => '/^suffix$/i',
976 'dataPattern' => '/^(sr|jr)\.?|i{2,}$/',
978 'contactType' => 'Individual',
979 'table_name' => 'civicrm_contact',
980 'entity' => 'Contact',
981 'bao' => 'CRM_Contact_BAO_Contact',
986 'pseudoconstant' => [
987 'optionGroupName' => 'individual_suffix',
988 'optionEditPath' => 'civicrm/admin/options/individual_suffix',
993 'name' => 'formal_title',
994 'type' => CRM_Utils_Type
::T_STRING
,
995 'title' => ts('Formal Title'),
996 'description' => ts('Formal (academic or similar) title in front of name. (Prof., Dr. etc.)'),
998 'size' => CRM_Utils_Type
::BIG
,
1000 'where' => 'civicrm_contact.formal_title',
1001 'headerPattern' => '/^title/i',
1003 'contactType' => 'Individual',
1004 'table_name' => 'civicrm_contact',
1005 'entity' => 'Contact',
1006 'bao' => 'CRM_Contact_BAO_Contact',
1013 'communication_style_id' => [
1014 'name' => 'communication_style_id',
1015 'type' => CRM_Utils_Type
::T_INT
,
1016 'title' => ts('Communication Style'),
1017 'description' => ts('Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.'),
1019 'where' => 'civicrm_contact.communication_style_id',
1020 'headerPattern' => '/style/i',
1022 'table_name' => 'civicrm_contact',
1023 'entity' => 'Contact',
1024 'bao' => 'CRM_Contact_BAO_Contact',
1029 'pseudoconstant' => [
1030 'optionGroupName' => 'communication_style',
1031 'optionEditPath' => 'civicrm/admin/options/communication_style',
1035 'email_greeting_id' => [
1036 'name' => 'email_greeting_id',
1037 'type' => CRM_Utils_Type
::T_INT
,
1038 'title' => ts('Email Greeting ID'),
1039 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Email Greeting.'),
1040 'where' => 'civicrm_contact.email_greeting_id',
1042 'table_name' => 'civicrm_contact',
1043 'entity' => 'Contact',
1044 'bao' => 'CRM_Contact_BAO_Contact',
1049 'pseudoconstant' => [
1050 'optionGroupName' => 'email_greeting',
1051 'optionEditPath' => 'civicrm/admin/options/email_greeting',
1055 'email_greeting_custom' => [
1056 'name' => 'email_greeting_custom',
1057 'type' => CRM_Utils_Type
::T_STRING
,
1058 'title' => ts('Email Greeting Custom'),
1059 'description' => ts('Custom Email Greeting.'),
1061 'size' => CRM_Utils_Type
::HUGE
,
1063 'where' => 'civicrm_contact.email_greeting_custom',
1065 'table_name' => 'civicrm_contact',
1066 'entity' => 'Contact',
1067 'bao' => 'CRM_Contact_BAO_Contact',
1074 'email_greeting_display' => [
1075 'name' => 'email_greeting_display',
1076 'type' => CRM_Utils_Type
::T_STRING
,
1077 'title' => ts('Email Greeting'),
1078 'description' => ts('Cache Email Greeting.'),
1080 'size' => CRM_Utils_Type
::HUGE
,
1081 'where' => 'civicrm_contact.email_greeting_display',
1082 'table_name' => 'civicrm_contact',
1083 'entity' => 'Contact',
1084 'bao' => 'CRM_Contact_BAO_Contact',
1088 'postal_greeting_id' => [
1089 'name' => 'postal_greeting_id',
1090 'type' => CRM_Utils_Type
::T_INT
,
1091 'title' => ts('Postal Greeting ID'),
1092 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.'),
1093 'where' => 'civicrm_contact.postal_greeting_id',
1095 'table_name' => 'civicrm_contact',
1096 'entity' => 'Contact',
1097 'bao' => 'CRM_Contact_BAO_Contact',
1102 'pseudoconstant' => [
1103 'optionGroupName' => 'postal_greeting',
1104 'optionEditPath' => 'civicrm/admin/options/postal_greeting',
1108 'postal_greeting_custom' => [
1109 'name' => 'postal_greeting_custom',
1110 'type' => CRM_Utils_Type
::T_STRING
,
1111 'title' => ts('Postal Greeting Custom'),
1112 'description' => ts('Custom Postal greeting.'),
1114 'size' => CRM_Utils_Type
::HUGE
,
1116 'where' => 'civicrm_contact.postal_greeting_custom',
1118 'table_name' => 'civicrm_contact',
1119 'entity' => 'Contact',
1120 'bao' => 'CRM_Contact_BAO_Contact',
1127 'postal_greeting_display' => [
1128 'name' => 'postal_greeting_display',
1129 'type' => CRM_Utils_Type
::T_STRING
,
1130 'title' => ts('Postal Greeting'),
1131 'description' => ts('Cache Postal greeting.'),
1133 'size' => CRM_Utils_Type
::HUGE
,
1134 'where' => 'civicrm_contact.postal_greeting_display',
1135 'table_name' => 'civicrm_contact',
1136 'entity' => 'Contact',
1137 'bao' => 'CRM_Contact_BAO_Contact',
1142 'name' => 'addressee_id',
1143 'type' => CRM_Utils_Type
::T_INT
,
1144 'title' => ts('Addressee ID'),
1145 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Addressee.'),
1146 'where' => 'civicrm_contact.addressee_id',
1148 'table_name' => 'civicrm_contact',
1149 'entity' => 'Contact',
1150 'bao' => 'CRM_Contact_BAO_Contact',
1155 'pseudoconstant' => [
1156 'optionGroupName' => 'addressee',
1157 'optionEditPath' => 'civicrm/admin/options/addressee',
1161 'addressee_custom' => [
1162 'name' => 'addressee_custom',
1163 'type' => CRM_Utils_Type
::T_STRING
,
1164 'title' => ts('Addressee Custom'),
1165 'description' => ts('Custom Addressee.'),
1167 'size' => CRM_Utils_Type
::HUGE
,
1169 'where' => 'civicrm_contact.addressee_custom',
1171 'table_name' => 'civicrm_contact',
1172 'entity' => 'Contact',
1173 'bao' => 'CRM_Contact_BAO_Contact',
1180 'addressee_display' => [
1181 'name' => 'addressee_display',
1182 'type' => CRM_Utils_Type
::T_STRING
,
1183 'title' => ts('Addressee'),
1184 'description' => ts('Cache Addressee.'),
1186 'size' => CRM_Utils_Type
::HUGE
,
1187 'where' => 'civicrm_contact.addressee_display',
1188 'table_name' => 'civicrm_contact',
1189 'entity' => 'Contact',
1190 'bao' => 'CRM_Contact_BAO_Contact',
1195 'name' => 'job_title',
1196 'type' => CRM_Utils_Type
::T_STRING
,
1197 'title' => ts('Job Title'),
1198 'description' => ts('Job Title'),
1202 'where' => 'civicrm_contact.job_title',
1203 'headerPattern' => '/^job|(j(ob\s)?title)$/i',
1204 'dataPattern' => '//',
1206 'contactType' => 'Individual',
1207 'table_name' => 'civicrm_contact',
1208 'entity' => 'Contact',
1209 'bao' => 'CRM_Contact_BAO_Contact',
1217 'name' => 'gender_id',
1218 'type' => CRM_Utils_Type
::T_INT
,
1219 'title' => ts('Gender ID'),
1220 'description' => ts('FK to gender ID'),
1222 'where' => 'civicrm_contact.gender_id',
1223 'headerPattern' => '/^gender$/i',
1225 'contactType' => 'Individual',
1226 'table_name' => 'civicrm_contact',
1227 'entity' => 'Contact',
1228 'bao' => 'CRM_Contact_BAO_Contact',
1232 'label' => ts("Gender"),
1234 'pseudoconstant' => [
1235 'optionGroupName' => 'gender',
1236 'optionEditPath' => 'civicrm/admin/options/gender',
1241 'name' => 'birth_date',
1242 'type' => CRM_Utils_Type
::T_DATE
,
1243 'title' => ts('Birth Date'),
1244 'description' => ts('Date of birth'),
1246 'where' => 'civicrm_contact.birth_date',
1247 'headerPattern' => '/^birth|(b(irth\s)?date)|D(\W*)O(\W*)B(\W*)$/i',
1248 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
1250 'contactType' => 'Individual',
1251 'table_name' => 'civicrm_contact',
1252 'entity' => 'Contact',
1253 'bao' => 'CRM_Contact_BAO_Contact',
1256 'type' => 'Select Date',
1257 'formatType' => 'birth',
1262 'name' => 'is_deceased',
1263 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1264 'title' => ts('Deceased'),
1267 'where' => 'civicrm_contact.is_deceased',
1268 'headerPattern' => '/i(s\s)?d(eceased)$/i',
1270 'contactType' => 'Individual',
1272 'table_name' => 'civicrm_contact',
1273 'entity' => 'Contact',
1274 'bao' => 'CRM_Contact_BAO_Contact',
1277 'type' => 'CheckBox',
1281 'deceased_date' => [
1282 'name' => 'deceased_date',
1283 'type' => CRM_Utils_Type
::T_DATE
,
1284 'title' => ts('Deceased Date'),
1285 'description' => ts('Date of deceased'),
1287 'where' => 'civicrm_contact.deceased_date',
1288 'headerPattern' => '/^deceased|(d(eceased\s)?date)$/i',
1290 'contactType' => 'Individual',
1291 'table_name' => 'civicrm_contact',
1292 'entity' => 'Contact',
1293 'bao' => 'CRM_Contact_BAO_Contact',
1296 'type' => 'Select Date',
1297 'formatType' => 'birth',
1301 'household_name' => [
1302 'name' => 'household_name',
1303 'type' => CRM_Utils_Type
::T_STRING
,
1304 'title' => ts('Household Name'),
1305 'description' => ts('Household Name.'),
1309 'where' => 'civicrm_contact.household_name',
1310 'headerPattern' => '/^household|(h(ousehold\s)?name)$/i',
1311 'dataPattern' => '/^\w+$/',
1313 'contactType' => 'Household',
1314 'table_name' => 'civicrm_contact',
1315 'entity' => 'Contact',
1316 'bao' => 'CRM_Contact_BAO_Contact',
1323 'primary_contact_id' => [
1324 'name' => 'primary_contact_id',
1325 'type' => CRM_Utils_Type
::T_INT
,
1326 'title' => ts('Household Primary Contact ID'),
1327 'description' => ts('Optional FK to Primary Contact for this household.'),
1328 'where' => 'civicrm_contact.primary_contact_id',
1329 'contactType' => 'Household',
1330 'table_name' => 'civicrm_contact',
1331 'entity' => 'Contact',
1332 'bao' => 'CRM_Contact_BAO_Contact',
1334 'FKClassName' => 'CRM_Contact_DAO_Contact',
1337 'organization_name' => [
1338 'name' => 'organization_name',
1339 'type' => CRM_Utils_Type
::T_STRING
,
1340 'title' => ts('Organization Name'),
1341 'description' => ts('Organization Name.'),
1345 'where' => 'civicrm_contact.organization_name',
1346 'headerPattern' => '/^organization|(o(rganization\s)?name)$/i',
1347 'dataPattern' => '/^\w+$/',
1349 'contactType' => 'Organization',
1350 'table_name' => 'civicrm_contact',
1351 'entity' => 'Contact',
1352 'bao' => 'CRM_Contact_BAO_Contact',
1360 'name' => 'sic_code',
1361 'type' => CRM_Utils_Type
::T_STRING
,
1362 'title' => ts('Sic Code'),
1363 'description' => ts('Standard Industry Classification Code.'),
1365 'size' => CRM_Utils_Type
::EIGHT
,
1367 'where' => 'civicrm_contact.sic_code',
1368 'headerPattern' => '/^sic|(s(ic\s)?code)$/i',
1370 'contactType' => 'Organization',
1371 'table_name' => 'civicrm_contact',
1372 'entity' => 'Contact',
1373 'bao' => 'CRM_Contact_BAO_Contact',
1380 'user_unique_id' => [
1381 'name' => 'user_unique_id',
1382 'type' => CRM_Utils_Type
::T_STRING
,
1383 'title' => ts('Unique ID (OpenID)'),
1384 'description' => ts('the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM'),
1386 'size' => CRM_Utils_Type
::HUGE
,
1388 'where' => 'civicrm_contact.user_unique_id',
1389 'headerPattern' => '/^Open\s?ID|u(niq\w*)?\s?ID/i',
1390 'dataPattern' => '/^[\w\/\:\.]+$/',
1393 'table_name' => 'civicrm_contact',
1394 'entity' => 'Contact',
1395 'bao' => 'CRM_Contact_BAO_Contact',
1402 'current_employer_id' => [
1403 'name' => 'employer_id',
1404 'type' => CRM_Utils_Type
::T_INT
,
1405 'title' => ts('Current Employer ID'),
1406 'description' => ts('OPTIONAL FK to civicrm_contact record.'),
1407 'where' => 'civicrm_contact.employer_id',
1409 'contactType' => 'Individual',
1410 'table_name' => 'civicrm_contact',
1411 'entity' => 'Contact',
1412 'bao' => 'CRM_Contact_BAO_Contact',
1414 'FKClassName' => 'CRM_Contact_DAO_Contact',
1416 'type' => 'EntityRef',
1417 'label' => ts("Current Employer"),
1421 'contact_is_deleted' => [
1422 'name' => 'is_deleted',
1423 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1424 'title' => ts('Contact is in Trash'),
1426 'where' => 'civicrm_contact.is_deleted',
1429 'access deleted contacts',
1432 'table_name' => 'civicrm_contact',
1433 'entity' => 'Contact',
1434 'bao' => 'CRM_Contact_BAO_Contact',
1437 'type' => 'CheckBox',
1442 'name' => 'created_date',
1443 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
1444 'title' => ts('Created Date'),
1445 'description' => ts('When was the contact was created.'),
1446 'required' => FALSE,
1447 'where' => 'civicrm_contact.created_date',
1449 'default' => 'NULL',
1450 'table_name' => 'civicrm_contact',
1451 'entity' => 'Contact',
1452 'bao' => 'CRM_Contact_BAO_Contact',
1456 'modified_date' => [
1457 'name' => 'modified_date',
1458 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
1459 'title' => ts('Modified Date'),
1460 'description' => ts('When was the contact (or closely related entity) was created or modified or deleted.'),
1461 'required' => FALSE,
1462 'where' => 'civicrm_contact.modified_date',
1464 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
1465 'table_name' => 'civicrm_contact',
1466 'entity' => 'Contact',
1467 'bao' => 'CRM_Contact_BAO_Contact',
1472 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
1474 return Civi
::$statics[__CLASS__
]['fields'];
1478 * Return a mapping from field-name to the corresponding key (as used in fields()).
1481 * Array(string $name => string $uniqueName).
1483 public static function &fieldKeys() {
1484 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
1485 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
1487 return Civi
::$statics[__CLASS__
]['fieldKeys'];
1491 * Returns the names of this table
1495 public static function getTableName() {
1496 return self
::$_tableName;
1500 * Returns if this table needs to be logged
1504 public function getLog() {
1509 * Returns the list of fields that can be imported
1511 * @param bool $prefix
1515 public static function &import($prefix = FALSE) {
1516 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'contact', $prefix, []);
1521 * Returns the list of fields that can be exported
1523 * @param bool $prefix
1527 public static function &export($prefix = FALSE) {
1528 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'contact', $prefix, []);
1533 * Returns the list of indices
1535 * @param bool $localize
1539 public static function indices($localize = TRUE) {
1541 'index_contact_type' => [
1542 'name' => 'index_contact_type',
1544 0 => 'contact_type',
1546 'localizable' => FALSE,
1547 'sig' => 'civicrm_contact::0::contact_type',
1549 'index_contact_sub_type' => [
1550 'name' => 'index_contact_sub_type',
1552 0 => 'contact_sub_type',
1554 'localizable' => FALSE,
1555 'sig' => 'civicrm_contact::0::contact_sub_type',
1557 'UI_external_identifier' => [
1558 'name' => 'UI_external_identifier',
1560 0 => 'external_identifier',
1562 'localizable' => FALSE,
1564 'sig' => 'civicrm_contact::1::external_identifier',
1566 'index_sort_name' => [
1567 'name' => 'index_sort_name',
1571 'localizable' => FALSE,
1572 'sig' => 'civicrm_contact::0::sort_name',
1574 'index_preferred_communication_method' => [
1575 'name' => 'index_preferred_communication_method',
1577 0 => 'preferred_communication_method',
1579 'localizable' => FALSE,
1580 'sig' => 'civicrm_contact::0::preferred_communication_method',
1583 'name' => 'index_hash',
1587 'localizable' => FALSE,
1588 'sig' => 'civicrm_contact::0::hash',
1590 'index_api_key' => [
1591 'name' => 'index_api_key',
1595 'localizable' => FALSE,
1596 'sig' => 'civicrm_contact::0::api_key',
1598 'index_first_name' => [
1599 'name' => 'index_first_name',
1603 'localizable' => FALSE,
1604 'sig' => 'civicrm_contact::0::first_name',
1606 'index_last_name' => [
1607 'name' => 'index_last_name',
1611 'localizable' => FALSE,
1612 'sig' => 'civicrm_contact::0::last_name',
1615 'name' => 'UI_prefix',
1619 'localizable' => FALSE,
1620 'sig' => 'civicrm_contact::0::prefix_id',
1623 'name' => 'UI_suffix',
1627 'localizable' => FALSE,
1628 'sig' => 'civicrm_contact::0::suffix_id',
1630 'index_communication_style_id' => [
1631 'name' => 'index_communication_style_id',
1633 0 => 'communication_style_id',
1635 'localizable' => FALSE,
1636 'sig' => 'civicrm_contact::0::communication_style_id',
1639 'name' => 'UI_gender',
1643 'localizable' => FALSE,
1644 'sig' => 'civicrm_contact::0::gender_id',
1646 'index_is_deceased' => [
1647 'name' => 'index_is_deceased',
1651 'localizable' => FALSE,
1652 'sig' => 'civicrm_contact::0::is_deceased',
1654 'index_household_name' => [
1655 'name' => 'index_household_name',
1657 0 => 'household_name',
1659 'localizable' => FALSE,
1660 'sig' => 'civicrm_contact::0::household_name',
1662 'index_organization_name' => [
1663 'name' => 'index_organization_name',
1665 0 => 'organization_name',
1667 'localizable' => FALSE,
1668 'sig' => 'civicrm_contact::0::organization_name',
1670 'index_is_deleted_sort_name' => [
1671 'name' => 'index_is_deleted_sort_name',
1677 'localizable' => FALSE,
1678 'sig' => 'civicrm_contact::0::is_deleted::sort_name::id',
1680 'index_created_date' => [
1681 'name' => 'index_created_date',
1683 0 => 'created_date',
1685 'localizable' => FALSE,
1686 'sig' => 'civicrm_contact::0::created_date',
1688 'index_modified_date' => [
1689 'name' => 'index_modified_date',
1691 0 => 'modified_date',
1693 'localizable' => FALSE,
1694 'sig' => 'civicrm_contact::0::modified_date',
1697 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;