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:67196fefde2ec151c97d463869102e21)
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]',
62 * @var int|string|null
63 * (SQL type: int unsigned)
64 * Note that values will be retrieved from the database as a string.
72 * (SQL type: varchar(64))
73 * Note that values will be retrieved from the database as a string.
78 * May be used to over-ride contact view and edit templates.
81 * (SQL type: varchar(255))
82 * Note that values will be retrieved from the database as a string.
84 public $contact_sub_type;
89 * Note that values will be retrieved from the database as a string.
96 * Note that values will be retrieved from the database as a string.
102 * (SQL type: tinyint)
103 * Note that values will be retrieved from the database as a string.
109 * (SQL type: tinyint)
110 * Note that values will be retrieved from the database as a string.
116 * (SQL type: tinyint)
117 * Note that values will be retrieved from the database as a string.
119 public $do_not_trade;
122 * Has the contact opted out from receiving all bulk email from the organization or site domain?
125 * (SQL type: tinyint)
126 * Note that values will be retrieved from the database as a string.
131 * May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.
134 * (SQL type: varchar(32))
135 * Note that values will be retrieved from the database as a string.
137 public $legal_identifier;
140 * Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.
143 * (SQL type: varchar(64))
144 * Note that values will be retrieved from the database as a string.
146 public $external_identifier;
149 * Name used for sorting different contact types
152 * (SQL type: varchar(128))
153 * Note that values will be retrieved from the database as a string.
158 * Formatted name representing preferred format for display/print/other output.
161 * (SQL type: varchar(128))
162 * Note that values will be retrieved from the database as a string.
164 public $display_name;
170 * (SQL type: varchar(128))
171 * Note that values will be retrieved from the database as a string.
179 * (SQL type: varchar(128))
180 * Note that values will be retrieved from the database as a string.
185 * optional URL for preferred image (photo, logo, etc.) to display for this contact.
189 * Note that values will be retrieved from the database as a string.
194 * What is the preferred mode of communication.
197 * (SQL type: varchar(255))
198 * Note that values will be retrieved from the database as a string.
200 public $preferred_communication_method;
203 * Which language is preferred for communication. FK to languages in civicrm_option_value.
206 * (SQL type: varchar(5))
207 * Note that values will be retrieved from the database as a string.
209 public $preferred_language;
212 * What is the preferred mode of sending an email.
215 * (SQL type: varchar(8))
216 * Note that values will be retrieved from the database as a string.
218 public $preferred_mail_format;
221 * Key for validating requests related to this contact.
224 * (SQL type: varchar(32))
225 * Note that values will be retrieved from the database as a string.
230 * API Key for validating requests related to this contact.
233 * (SQL type: varchar(32))
234 * Note that values will be retrieved from the database as a string.
239 * where contact come from, e.g. import, donate module insert...
242 * (SQL type: varchar(255))
243 * Note that values will be retrieved from the database as a string.
251 * (SQL type: varchar(64))
252 * Note that values will be retrieved from the database as a string.
260 * (SQL type: varchar(64))
261 * Note that values will be retrieved from the database as a string.
269 * (SQL type: varchar(64))
270 * Note that values will be retrieved from the database as a string.
275 * Prefix or Title for name (Ms, Mr...). FK to prefix ID
277 * @var int|string|null
278 * (SQL type: int unsigned)
279 * Note that values will be retrieved from the database as a string.
284 * Suffix for name (Jr, Sr...). FK to suffix ID
286 * @var int|string|null
287 * (SQL type: int unsigned)
288 * Note that values will be retrieved from the database as a string.
293 * Formal (academic or similar) title in front of name. (Prof., Dr. etc.)
296 * (SQL type: varchar(64))
297 * Note that values will be retrieved from the database as a string.
299 public $formal_title;
302 * Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.
304 * @var int|string|null
305 * (SQL type: int unsigned)
306 * Note that values will be retrieved from the database as a string.
308 public $communication_style_id;
311 * FK to civicrm_option_value.id, that has to be valid registered Email Greeting.
313 * @var int|string|null
314 * (SQL type: int unsigned)
315 * Note that values will be retrieved from the database as a string.
317 public $email_greeting_id;
320 * Custom Email Greeting.
323 * (SQL type: varchar(128))
324 * Note that values will be retrieved from the database as a string.
326 public $email_greeting_custom;
329 * Cache Email Greeting.
332 * (SQL type: varchar(255))
333 * Note that values will be retrieved from the database as a string.
335 public $email_greeting_display;
338 * FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.
340 * @var int|string|null
341 * (SQL type: int unsigned)
342 * Note that values will be retrieved from the database as a string.
344 public $postal_greeting_id;
347 * Custom Postal greeting.
350 * (SQL type: varchar(128))
351 * Note that values will be retrieved from the database as a string.
353 public $postal_greeting_custom;
356 * Cache Postal greeting.
359 * (SQL type: varchar(255))
360 * Note that values will be retrieved from the database as a string.
362 public $postal_greeting_display;
365 * FK to civicrm_option_value.id, that has to be valid registered Addressee.
367 * @var int|string|null
368 * (SQL type: int unsigned)
369 * Note that values will be retrieved from the database as a string.
371 public $addressee_id;
377 * (SQL type: varchar(128))
378 * Note that values will be retrieved from the database as a string.
380 public $addressee_custom;
386 * (SQL type: varchar(255))
387 * Note that values will be retrieved from the database as a string.
389 public $addressee_display;
395 * (SQL type: varchar(255))
396 * Note that values will be retrieved from the database as a string.
403 * @var int|string|null
404 * (SQL type: int unsigned)
405 * Note that values will be retrieved from the database as a string.
414 * Note that values will be retrieved from the database as a string.
420 * (SQL type: tinyint)
421 * Note that values will be retrieved from the database as a string.
430 * Note that values will be retrieved from the database as a string.
432 public $deceased_date;
438 * (SQL type: varchar(128))
439 * Note that values will be retrieved from the database as a string.
441 public $household_name;
444 * Optional FK to Primary Contact for this household.
446 * @var int|string|null
447 * (SQL type: int unsigned)
448 * Note that values will be retrieved from the database as a string.
450 public $primary_contact_id;
456 * (SQL type: varchar(128))
457 * Note that values will be retrieved from the database as a string.
459 public $organization_name;
462 * Standard Industry Classification Code.
465 * (SQL type: varchar(8))
466 * Note that values will be retrieved from the database as a string.
471 * the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM
474 * (SQL type: varchar(255))
475 * Note that values will be retrieved from the database as a string.
477 public $user_unique_id;
480 * OPTIONAL FK to civicrm_contact record.
482 * @var int|string|null
483 * (SQL type: int unsigned)
484 * Note that values will be retrieved from the database as a string.
490 * (SQL type: tinyint)
491 * Note that values will be retrieved from the database as a string.
496 * When was the contact was created.
499 * (SQL type: timestamp)
500 * Note that values will be retrieved from the database as a string.
502 public $created_date;
505 * When was the contact (or closely related entity) was created or modified or deleted.
508 * (SQL type: timestamp)
509 * Note that values will be retrieved from the database as a string.
511 public $modified_date;
516 public function __construct() {
517 $this->__table
= 'civicrm_contact';
518 parent
::__construct();
522 * Returns localized title of this entity.
524 * @param bool $plural
525 * Whether to return the plural version of the title.
527 public static function getEntityTitle($plural = FALSE) {
528 return $plural ?
ts('Contacts') : ts('Contact');
532 * Returns user-friendly description of this entity.
536 public static function getEntityDescription() {
537 return ts('Individuals, organizations, households, etc.');
541 * Returns foreign keys and entity references.
544 * [CRM_Core_Reference_Interface]
546 public static function getReferenceColumns() {
547 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
548 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
549 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'primary_contact_id', 'civicrm_contact', 'id');
550 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'employer_id', 'civicrm_contact', 'id');
551 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
553 return Civi
::$statics[__CLASS__
]['links'];
557 * Returns all the column names of this table
561 public static function &fields() {
562 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
563 Civi
::$statics[__CLASS__
]['fields'] = [
566 'type' => CRM_Utils_Type
::T_INT
,
567 'title' => ts('Contact ID'),
568 'description' => ts('Unique Contact ID'),
571 'where' => 'civicrm_contact.id',
572 'headerPattern' => '/internal|contact?|id$/i',
574 'table_name' => 'civicrm_contact',
575 'entity' => 'Contact',
576 'bao' => 'CRM_Contact_BAO_Contact',
585 'name' => 'contact_type',
586 'type' => CRM_Utils_Type
::T_STRING
,
587 'title' => ts('Contact Type'),
588 'description' => ts('Type of Contact.'),
590 'size' => CRM_Utils_Type
::BIG
,
591 'where' => 'civicrm_contact.contact_type',
593 'contactType' => NULL,
594 'table_name' => 'civicrm_contact',
595 'entity' => 'Contact',
596 'bao' => 'CRM_Contact_BAO_Contact',
601 'pseudoconstant' => [
602 'table' => 'civicrm_contact_type',
603 'keyColumn' => 'name',
604 'labelColumn' => 'label',
605 'condition' => 'parent_id IS NULL',
610 'contact_sub_type' => [
611 'name' => 'contact_sub_type',
612 'type' => CRM_Utils_Type
::T_STRING
,
613 'title' => ts('Contact Subtype'),
614 'description' => ts('May be used to over-ride contact view and edit templates.'),
616 'size' => CRM_Utils_Type
::HUGE
,
618 'where' => 'civicrm_contact.contact_sub_type',
619 'headerPattern' => '/C(ontact )?(subtype|sub-type|sub type)/i',
621 'table_name' => 'civicrm_contact',
622 'entity' => 'Contact',
623 'bao' => 'CRM_Contact_BAO_Contact',
625 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
629 'pseudoconstant' => [
630 'table' => 'civicrm_contact_type',
631 'keyColumn' => 'name',
632 'labelColumn' => 'label',
633 'condition' => 'parent_id IS NOT NULL',
638 'name' => 'do_not_email',
639 'type' => CRM_Utils_Type
::T_BOOLEAN
,
640 'title' => ts('Do Not Email'),
643 'where' => 'civicrm_contact.do_not_email',
644 'headerPattern' => '/d(o )?(not )?(email)/i',
645 'dataPattern' => '/^\d{1,}$/',
648 'table_name' => 'civicrm_contact',
649 'entity' => 'Contact',
650 'bao' => 'CRM_Contact_BAO_Contact',
653 'type' => 'CheckBox',
654 'label' => ts("Do Not Email"),
659 'name' => 'do_not_phone',
660 'type' => CRM_Utils_Type
::T_BOOLEAN
,
661 'title' => ts('Do Not Phone'),
664 'where' => 'civicrm_contact.do_not_phone',
665 'headerPattern' => '/d(o )?(not )?(call|phone)/i',
666 'dataPattern' => '/^\d{1,}$/',
669 'table_name' => 'civicrm_contact',
670 'entity' => 'Contact',
671 'bao' => 'CRM_Contact_BAO_Contact',
674 'type' => 'CheckBox',
675 'label' => ts("Do Not Phone"),
680 'name' => 'do_not_mail',
681 'type' => CRM_Utils_Type
::T_BOOLEAN
,
682 'title' => ts('Do Not Mail'),
685 'where' => 'civicrm_contact.do_not_mail',
686 'headerPattern' => '/^(d(o\s)?n(ot\s)?mail)|(\w*)?bulk\s?(\w*)$/i',
687 'dataPattern' => '/^\d{1,}$/',
690 'table_name' => 'civicrm_contact',
691 'entity' => 'Contact',
692 'bao' => 'CRM_Contact_BAO_Contact',
695 'type' => 'CheckBox',
696 'label' => ts("Do Not Mail"),
701 'name' => 'do_not_sms',
702 'type' => CRM_Utils_Type
::T_BOOLEAN
,
703 'title' => ts('Do Not Sms'),
706 'where' => 'civicrm_contact.do_not_sms',
707 'headerPattern' => '/d(o )?(not )?(sms)/i',
708 'dataPattern' => '/^\d{1,}$/',
711 'table_name' => 'civicrm_contact',
712 'entity' => 'Contact',
713 'bao' => 'CRM_Contact_BAO_Contact',
716 'type' => 'CheckBox',
717 'label' => ts("Do Not Sms"),
722 'name' => 'do_not_trade',
723 'type' => CRM_Utils_Type
::T_BOOLEAN
,
724 'title' => ts('Do Not Trade'),
727 'where' => 'civicrm_contact.do_not_trade',
728 'headerPattern' => '/d(o )?(not )?(trade)/i',
729 'dataPattern' => '/^\d{1,}$/',
732 'table_name' => 'civicrm_contact',
733 'entity' => 'Contact',
734 'bao' => 'CRM_Contact_BAO_Contact',
737 'type' => 'CheckBox',
738 'label' => ts("Do Not Trade"),
743 'name' => 'is_opt_out',
744 'type' => CRM_Utils_Type
::T_BOOLEAN
,
745 'title' => ts('No Bulk Emails (User Opt Out)'),
746 'description' => ts('Has the contact opted out from receiving all bulk email from the organization or site domain?'),
749 'where' => 'civicrm_contact.is_opt_out',
752 'table_name' => 'civicrm_contact',
753 'entity' => 'Contact',
754 'bao' => 'CRM_Contact_BAO_Contact',
757 'type' => 'CheckBox',
758 'label' => ts("Is Opt Out"),
762 'legal_identifier' => [
763 'name' => 'legal_identifier',
764 'type' => CRM_Utils_Type
::T_STRING
,
765 'title' => ts('Legal Identifier'),
766 'description' => ts('May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.'),
768 'size' => CRM_Utils_Type
::MEDIUM
,
770 'where' => 'civicrm_contact.legal_identifier',
771 'headerPattern' => '/legal\s?id/i',
772 'dataPattern' => '/\w+?\d{5,}/',
774 'table_name' => 'civicrm_contact',
775 'entity' => 'Contact',
776 'bao' => 'CRM_Contact_BAO_Contact',
780 'label' => ts("Legal Identifier"),
784 'external_identifier' => [
785 'name' => 'external_identifier',
786 'type' => CRM_Utils_Type
::T_STRING
,
787 'title' => ts('External Identifier'),
788 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
792 'where' => 'civicrm_contact.external_identifier',
793 'headerPattern' => '/external\s?id/i',
794 'dataPattern' => '/^\d{11,}$/',
796 'table_name' => 'civicrm_contact',
797 'entity' => 'Contact',
798 'bao' => 'CRM_Contact_BAO_Contact',
802 'label' => ts("External Identifier"),
807 'name' => 'sort_name',
808 'type' => CRM_Utils_Type
::T_STRING
,
809 'title' => ts('Sort Name'),
810 'description' => ts('Name used for sorting different contact types'),
813 'where' => 'civicrm_contact.sort_name',
815 'table_name' => 'civicrm_contact',
816 'entity' => 'Contact',
817 'bao' => 'CRM_Contact_BAO_Contact',
826 'name' => 'display_name',
827 'type' => CRM_Utils_Type
::T_STRING
,
828 'title' => ts('Display Name'),
829 'description' => ts('Formatted name representing preferred format for display/print/other output.'),
832 'where' => 'civicrm_contact.display_name',
834 'table_name' => 'civicrm_contact',
835 'entity' => 'Contact',
836 'bao' => 'CRM_Contact_BAO_Contact',
845 'name' => 'nick_name',
846 'type' => CRM_Utils_Type
::T_STRING
,
847 'title' => ts('Nickname'),
848 'description' => ts('Nickname.'),
852 'where' => 'civicrm_contact.nick_name',
853 'headerPattern' => '/n(ick\s)name|nick$/i',
854 'dataPattern' => '/^\w+$/',
856 'table_name' => 'civicrm_contact',
857 'entity' => 'Contact',
858 'bao' => 'CRM_Contact_BAO_Contact',
866 'name' => 'legal_name',
867 'type' => CRM_Utils_Type
::T_STRING
,
868 'title' => ts('Legal Name'),
869 'description' => ts('Legal Name.'),
873 'where' => 'civicrm_contact.legal_name',
874 'headerPattern' => '/^legal|(l(egal\s)?name)$/i',
876 'contactType' => 'Organization',
877 'table_name' => 'civicrm_contact',
878 'entity' => 'Contact',
879 'bao' => 'CRM_Contact_BAO_Contact',
883 'label' => ts("Legal Name"),
888 'name' => 'image_URL',
889 'type' => CRM_Utils_Type
::T_TEXT
,
890 'title' => ts('Image Url'),
891 'description' => ts('optional URL for preferred image (photo, logo, etc.) to display for this contact.'),
893 'where' => 'civicrm_contact.image_URL',
895 'table_name' => 'civicrm_contact',
896 'entity' => 'Contact',
897 'bao' => 'CRM_Contact_BAO_Contact',
901 'label' => ts("Image URL"),
905 'preferred_communication_method' => [
906 'name' => 'preferred_communication_method',
907 'type' => CRM_Utils_Type
::T_STRING
,
908 'title' => ts('Preferred Communication Method'),
909 'description' => ts('What is the preferred mode of communication.'),
911 'size' => CRM_Utils_Type
::HUGE
,
913 'where' => 'civicrm_contact.preferred_communication_method',
914 'headerPattern' => '/^p(ref\w*\s)?c(omm\w*)|( meth\w*)$/i',
915 'dataPattern' => '/^\w+$/',
917 'table_name' => 'civicrm_contact',
918 'entity' => 'Contact',
919 'bao' => 'CRM_Contact_BAO_Contact',
921 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
925 'pseudoconstant' => [
926 'optionGroupName' => 'preferred_communication_method',
927 'optionEditPath' => 'civicrm/admin/options/preferred_communication_method',
931 'preferred_language' => [
932 'name' => 'preferred_language',
933 'type' => CRM_Utils_Type
::T_STRING
,
934 'title' => ts('Preferred Language'),
935 'description' => ts('Which language is preferred for communication. FK to languages in civicrm_option_value.'),
937 'size' => CRM_Utils_Type
::SIX
,
939 'where' => 'civicrm_contact.preferred_language',
940 'headerPattern' => '/^lang/i',
942 'table_name' => 'civicrm_contact',
943 'entity' => 'Contact',
944 'bao' => 'CRM_Contact_BAO_Contact',
949 'pseudoconstant' => [
950 'optionGroupName' => 'languages',
951 'keyColumn' => 'name',
952 'optionEditPath' => 'civicrm/admin/options/languages',
956 'preferred_mail_format' => [
957 'name' => 'preferred_mail_format',
958 'type' => CRM_Utils_Type
::T_STRING
,
959 'title' => ts('Preferred Mail Format'),
960 'description' => ts('What is the preferred mode of sending an email.'),
962 'size' => CRM_Utils_Type
::EIGHT
,
964 'where' => 'civicrm_contact.preferred_mail_format',
965 'headerPattern' => '/^p(ref\w*\s)?m(ail\s)?f(orm\w*)$/i',
968 'table_name' => 'civicrm_contact',
969 'entity' => 'Contact',
970 'bao' => 'CRM_Contact_BAO_Contact',
974 'label' => ts("Preferred Mail Format"),
976 'pseudoconstant' => [
977 'callback' => 'CRM_Core_SelectValues::pmf',
983 'type' => CRM_Utils_Type
::T_STRING
,
984 'title' => ts('Contact Hash'),
985 'description' => ts('Key for validating requests related to this contact.'),
987 'size' => CRM_Utils_Type
::MEDIUM
,
988 'where' => 'civicrm_contact.hash',
990 'table_name' => 'civicrm_contact',
991 'entity' => 'Contact',
992 'bao' => 'CRM_Contact_BAO_Contact',
999 'type' => CRM_Utils_Type
::T_STRING
,
1000 'title' => ts('Api Key'),
1001 'description' => ts('API Key for validating requests related to this contact.'),
1003 'size' => CRM_Utils_Type
::MEDIUM
,
1004 'where' => 'civicrm_contact.api_key',
1007 'administer CiviCRM',
1011 'table_name' => 'civicrm_contact',
1012 'entity' => 'Contact',
1013 'bao' => 'CRM_Contact_BAO_Contact',
1016 'label' => ts("API KEY"),
1021 'contact_source' => [
1023 'type' => CRM_Utils_Type
::T_STRING
,
1024 'title' => ts('Contact Source'),
1025 'description' => ts('where contact come from, e.g. import, donate module insert...'),
1029 'where' => 'civicrm_contact.source',
1030 'headerPattern' => '/(C(ontact\s)?Source)$/i',
1032 'table_name' => 'civicrm_contact',
1033 'entity' => 'Contact',
1034 'bao' => 'CRM_Contact_BAO_Contact',
1042 'name' => 'first_name',
1043 'type' => CRM_Utils_Type
::T_STRING
,
1044 'title' => ts('First Name'),
1045 'description' => ts('First Name.'),
1049 'where' => 'civicrm_contact.first_name',
1050 'headerPattern' => '/^first|(f(irst\s)?name)$/i',
1051 'dataPattern' => '/^\w+$/',
1053 'contactType' => 'Individual',
1054 'table_name' => 'civicrm_contact',
1055 'entity' => 'Contact',
1056 'bao' => 'CRM_Contact_BAO_Contact',
1060 'label' => ts("First Name"),
1065 'name' => 'middle_name',
1066 'type' => CRM_Utils_Type
::T_STRING
,
1067 'title' => ts('Middle Name'),
1068 'description' => ts('Middle Name.'),
1072 'where' => 'civicrm_contact.middle_name',
1073 'headerPattern' => '/^middle|(m(iddle\s)?name)$/i',
1074 'dataPattern' => '/^\w+$/',
1076 'contactType' => 'Individual',
1077 'table_name' => 'civicrm_contact',
1078 'entity' => 'Contact',
1079 'bao' => 'CRM_Contact_BAO_Contact',
1083 'label' => ts("Middle Name"),
1088 'name' => 'last_name',
1089 'type' => CRM_Utils_Type
::T_STRING
,
1090 'title' => ts('Last Name'),
1091 'description' => ts('Last Name.'),
1095 'where' => 'civicrm_contact.last_name',
1096 'headerPattern' => '/^last|(l(ast\s)?name)$/i',
1097 'dataPattern' => '/^\w+(\s\w+)?+$/',
1099 'contactType' => 'Individual',
1100 'table_name' => 'civicrm_contact',
1101 'entity' => 'Contact',
1102 'bao' => 'CRM_Contact_BAO_Contact',
1106 'label' => ts("Last Name"),
1111 'name' => 'prefix_id',
1112 'type' => CRM_Utils_Type
::T_INT
,
1113 'title' => ts('Individual Prefix'),
1114 'description' => ts('Prefix or Title for name (Ms, Mr...). FK to prefix ID'),
1116 'where' => 'civicrm_contact.prefix_id',
1117 'headerPattern' => '/^(prefix|title)/i',
1118 'dataPattern' => '/^(mr|ms|mrs|sir|dr)\.?$/i',
1120 'contactType' => 'Individual',
1121 'table_name' => 'civicrm_contact',
1122 'entity' => 'Contact',
1123 'bao' => 'CRM_Contact_BAO_Contact',
1128 'pseudoconstant' => [
1129 'optionGroupName' => 'individual_prefix',
1130 'optionEditPath' => 'civicrm/admin/options/individual_prefix',
1135 'name' => 'suffix_id',
1136 'type' => CRM_Utils_Type
::T_INT
,
1137 'title' => ts('Individual Suffix'),
1138 'description' => ts('Suffix for name (Jr, Sr...). FK to suffix ID'),
1140 'where' => 'civicrm_contact.suffix_id',
1141 'headerPattern' => '/^suffix$/i',
1142 'dataPattern' => '/^(sr|jr)\.?|i{2,}$/',
1144 'contactType' => 'Individual',
1145 'table_name' => 'civicrm_contact',
1146 'entity' => 'Contact',
1147 'bao' => 'CRM_Contact_BAO_Contact',
1152 'pseudoconstant' => [
1153 'optionGroupName' => 'individual_suffix',
1154 'optionEditPath' => 'civicrm/admin/options/individual_suffix',
1159 'name' => 'formal_title',
1160 'type' => CRM_Utils_Type
::T_STRING
,
1161 'title' => ts('Formal Title'),
1162 'description' => ts('Formal (academic or similar) title in front of name. (Prof., Dr. etc.)'),
1164 'size' => CRM_Utils_Type
::BIG
,
1166 'where' => 'civicrm_contact.formal_title',
1167 'headerPattern' => '/^title/i',
1169 'contactType' => 'Individual',
1170 'table_name' => 'civicrm_contact',
1171 'entity' => 'Contact',
1172 'bao' => 'CRM_Contact_BAO_Contact',
1176 'label' => ts("Formal Title"),
1180 'communication_style_id' => [
1181 'name' => 'communication_style_id',
1182 'type' => CRM_Utils_Type
::T_INT
,
1183 'title' => ts('Communication Style'),
1184 'description' => ts('Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.'),
1186 'where' => 'civicrm_contact.communication_style_id',
1187 'headerPattern' => '/style/i',
1189 'table_name' => 'civicrm_contact',
1190 'entity' => 'Contact',
1191 'bao' => 'CRM_Contact_BAO_Contact',
1196 'pseudoconstant' => [
1197 'optionGroupName' => 'communication_style',
1198 'optionEditPath' => 'civicrm/admin/options/communication_style',
1202 'email_greeting_id' => [
1203 'name' => 'email_greeting_id',
1204 'type' => CRM_Utils_Type
::T_INT
,
1205 'title' => ts('Email Greeting ID'),
1206 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Email Greeting.'),
1207 'where' => 'civicrm_contact.email_greeting_id',
1209 'table_name' => 'civicrm_contact',
1210 'entity' => 'Contact',
1211 'bao' => 'CRM_Contact_BAO_Contact',
1216 'pseudoconstant' => [
1217 'optionGroupName' => 'email_greeting',
1218 'optionEditPath' => 'civicrm/admin/options/email_greeting',
1222 'email_greeting_custom' => [
1223 'name' => 'email_greeting_custom',
1224 'type' => CRM_Utils_Type
::T_STRING
,
1225 'title' => ts('Email Greeting Custom'),
1226 'description' => ts('Custom Email Greeting.'),
1228 'size' => CRM_Utils_Type
::HUGE
,
1230 'where' => 'civicrm_contact.email_greeting_custom',
1232 'table_name' => 'civicrm_contact',
1233 'entity' => 'Contact',
1234 'bao' => 'CRM_Contact_BAO_Contact',
1238 'label' => ts("Email Greeting Custom"),
1242 'email_greeting_display' => [
1243 'name' => 'email_greeting_display',
1244 'type' => CRM_Utils_Type
::T_STRING
,
1245 'title' => ts('Email Greeting'),
1246 'description' => ts('Cache Email Greeting.'),
1248 'size' => CRM_Utils_Type
::HUGE
,
1249 'where' => 'civicrm_contact.email_greeting_display',
1250 'table_name' => 'civicrm_contact',
1251 'entity' => 'Contact',
1252 'bao' => 'CRM_Contact_BAO_Contact',
1257 'postal_greeting_id' => [
1258 'name' => 'postal_greeting_id',
1259 'type' => CRM_Utils_Type
::T_INT
,
1260 'title' => ts('Postal Greeting ID'),
1261 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.'),
1262 'where' => 'civicrm_contact.postal_greeting_id',
1264 'table_name' => 'civicrm_contact',
1265 'entity' => 'Contact',
1266 'bao' => 'CRM_Contact_BAO_Contact',
1271 'pseudoconstant' => [
1272 'optionGroupName' => 'postal_greeting',
1273 'optionEditPath' => 'civicrm/admin/options/postal_greeting',
1277 'postal_greeting_custom' => [
1278 'name' => 'postal_greeting_custom',
1279 'type' => CRM_Utils_Type
::T_STRING
,
1280 'title' => ts('Postal Greeting Custom'),
1281 'description' => ts('Custom Postal greeting.'),
1283 'size' => CRM_Utils_Type
::HUGE
,
1285 'where' => 'civicrm_contact.postal_greeting_custom',
1287 'table_name' => 'civicrm_contact',
1288 'entity' => 'Contact',
1289 'bao' => 'CRM_Contact_BAO_Contact',
1293 'label' => ts("Postal Greeting Custom"),
1297 'postal_greeting_display' => [
1298 'name' => 'postal_greeting_display',
1299 'type' => CRM_Utils_Type
::T_STRING
,
1300 'title' => ts('Postal Greeting'),
1301 'description' => ts('Cache Postal greeting.'),
1303 'size' => CRM_Utils_Type
::HUGE
,
1304 'where' => 'civicrm_contact.postal_greeting_display',
1305 'table_name' => 'civicrm_contact',
1306 'entity' => 'Contact',
1307 'bao' => 'CRM_Contact_BAO_Contact',
1313 'name' => 'addressee_id',
1314 'type' => CRM_Utils_Type
::T_INT
,
1315 'title' => ts('Addressee ID'),
1316 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Addressee.'),
1317 'where' => 'civicrm_contact.addressee_id',
1319 'table_name' => 'civicrm_contact',
1320 'entity' => 'Contact',
1321 'bao' => 'CRM_Contact_BAO_Contact',
1326 'pseudoconstant' => [
1327 'optionGroupName' => 'addressee',
1328 'optionEditPath' => 'civicrm/admin/options/addressee',
1332 'addressee_custom' => [
1333 'name' => 'addressee_custom',
1334 'type' => CRM_Utils_Type
::T_STRING
,
1335 'title' => ts('Addressee Custom'),
1336 'description' => ts('Custom Addressee.'),
1338 'size' => CRM_Utils_Type
::HUGE
,
1340 'where' => 'civicrm_contact.addressee_custom',
1342 'table_name' => 'civicrm_contact',
1343 'entity' => 'Contact',
1344 'bao' => 'CRM_Contact_BAO_Contact',
1348 'label' => ts("Addressee Custom"),
1352 'addressee_display' => [
1353 'name' => 'addressee_display',
1354 'type' => CRM_Utils_Type
::T_STRING
,
1355 'title' => ts('Addressee'),
1356 'description' => ts('Cache Addressee.'),
1358 'size' => CRM_Utils_Type
::HUGE
,
1359 'where' => 'civicrm_contact.addressee_display',
1360 'table_name' => 'civicrm_contact',
1361 'entity' => 'Contact',
1362 'bao' => 'CRM_Contact_BAO_Contact',
1368 'name' => 'job_title',
1369 'type' => CRM_Utils_Type
::T_STRING
,
1370 'title' => ts('Job Title'),
1371 'description' => ts('Job Title'),
1375 'where' => 'civicrm_contact.job_title',
1376 'headerPattern' => '/^job|(j(ob\s)?title)$/i',
1377 'dataPattern' => '//',
1379 'contactType' => 'Individual',
1380 'table_name' => 'civicrm_contact',
1381 'entity' => 'Contact',
1382 'bao' => 'CRM_Contact_BAO_Contact',
1386 'label' => ts("Job Title"),
1391 'name' => 'gender_id',
1392 'type' => CRM_Utils_Type
::T_INT
,
1393 'title' => ts('Gender ID'),
1394 'description' => ts('FK to gender ID'),
1396 'where' => 'civicrm_contact.gender_id',
1397 'headerPattern' => '/^gender$/i',
1399 'contactType' => 'Individual',
1400 'table_name' => 'civicrm_contact',
1401 'entity' => 'Contact',
1402 'bao' => 'CRM_Contact_BAO_Contact',
1406 'label' => ts("Gender"),
1408 'pseudoconstant' => [
1409 'optionGroupName' => 'gender',
1410 'optionEditPath' => 'civicrm/admin/options/gender',
1415 'name' => 'birth_date',
1416 'type' => CRM_Utils_Type
::T_DATE
,
1417 'title' => ts('Birth Date'),
1418 'description' => ts('Date of birth'),
1420 'where' => 'civicrm_contact.birth_date',
1421 'headerPattern' => '/^birth|(b(irth\s)?date)|D(\W*)O(\W*)B(\W*)$/i',
1422 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
1424 'contactType' => 'Individual',
1425 'table_name' => 'civicrm_contact',
1426 'entity' => 'Contact',
1427 'bao' => 'CRM_Contact_BAO_Contact',
1430 'type' => 'Select Date',
1431 'formatType' => 'birth',
1432 'label' => ts("Birth Date"),
1437 'name' => 'is_deceased',
1438 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1439 'title' => ts('Deceased'),
1442 'where' => 'civicrm_contact.is_deceased',
1443 'headerPattern' => '/i(s\s)?d(eceased)$/i',
1445 'contactType' => 'Individual',
1447 'table_name' => 'civicrm_contact',
1448 'entity' => 'Contact',
1449 'bao' => 'CRM_Contact_BAO_Contact',
1452 'type' => 'CheckBox',
1453 'label' => ts("Is Deceased"),
1457 'deceased_date' => [
1458 'name' => 'deceased_date',
1459 'type' => CRM_Utils_Type
::T_DATE
,
1460 'title' => ts('Deceased Date'),
1461 'description' => ts('Date of deceased'),
1463 'where' => 'civicrm_contact.deceased_date',
1464 'headerPattern' => '/^deceased|(d(eceased\s)?date)$/i',
1466 'contactType' => 'Individual',
1467 'table_name' => 'civicrm_contact',
1468 'entity' => 'Contact',
1469 'bao' => 'CRM_Contact_BAO_Contact',
1472 'type' => 'Select Date',
1473 'formatType' => 'birth',
1474 'label' => ts("Deceased Date"),
1478 'household_name' => [
1479 'name' => 'household_name',
1480 'type' => CRM_Utils_Type
::T_STRING
,
1481 'title' => ts('Household Name'),
1482 'description' => ts('Household Name.'),
1486 'where' => 'civicrm_contact.household_name',
1487 'headerPattern' => '/^household|(h(ousehold\s)?name)$/i',
1488 'dataPattern' => '/^\w+$/',
1490 'contactType' => 'Household',
1491 'table_name' => 'civicrm_contact',
1492 'entity' => 'Contact',
1493 'bao' => 'CRM_Contact_BAO_Contact',
1497 'label' => ts("Household Name"),
1501 'primary_contact_id' => [
1502 'name' => 'primary_contact_id',
1503 'type' => CRM_Utils_Type
::T_INT
,
1504 'title' => ts('Household Primary Contact ID'),
1505 'description' => ts('Optional FK to Primary Contact for this household.'),
1506 'where' => 'civicrm_contact.primary_contact_id',
1507 'contactType' => 'Household',
1508 'table_name' => 'civicrm_contact',
1509 'entity' => 'Contact',
1510 'bao' => 'CRM_Contact_BAO_Contact',
1512 'FKClassName' => 'CRM_Contact_DAO_Contact',
1514 'label' => ts("Household Primary Contact"),
1519 'organization_name' => [
1520 'name' => 'organization_name',
1521 'type' => CRM_Utils_Type
::T_STRING
,
1522 'title' => ts('Organization Name'),
1523 'description' => ts('Organization Name.'),
1527 'where' => 'civicrm_contact.organization_name',
1528 'headerPattern' => '/^organization|(o(rganization\s)?name)$/i',
1529 'dataPattern' => '/^\w+$/',
1531 'contactType' => 'Organization',
1532 'table_name' => 'civicrm_contact',
1533 'entity' => 'Contact',
1534 'bao' => 'CRM_Contact_BAO_Contact',
1538 'label' => ts("Organization Name"),
1543 'name' => 'sic_code',
1544 'type' => CRM_Utils_Type
::T_STRING
,
1545 'title' => ts('Sic Code'),
1546 'description' => ts('Standard Industry Classification Code.'),
1548 'size' => CRM_Utils_Type
::EIGHT
,
1550 'where' => 'civicrm_contact.sic_code',
1551 'headerPattern' => '/^sic|(s(ic\s)?code)$/i',
1553 'contactType' => 'Organization',
1554 'table_name' => 'civicrm_contact',
1555 'entity' => 'Contact',
1556 'bao' => 'CRM_Contact_BAO_Contact',
1560 'label' => ts("SIC Code"),
1564 'user_unique_id' => [
1565 'name' => 'user_unique_id',
1566 'type' => CRM_Utils_Type
::T_STRING
,
1567 'title' => ts('Unique ID (OpenID)'),
1568 'description' => ts('the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM'),
1570 'size' => CRM_Utils_Type
::HUGE
,
1572 'where' => 'civicrm_contact.user_unique_id',
1573 'headerPattern' => '/^Open\s?ID|u(niq\w*)?\s?ID/i',
1574 'dataPattern' => '/^[\w\/\:\.]+$/',
1577 'table_name' => 'civicrm_contact',
1578 'entity' => 'Contact',
1579 'bao' => 'CRM_Contact_BAO_Contact',
1586 'current_employer_id' => [
1587 'name' => 'employer_id',
1588 'type' => CRM_Utils_Type
::T_INT
,
1589 'title' => ts('Current Employer ID'),
1590 'description' => ts('OPTIONAL FK to civicrm_contact record.'),
1591 'where' => 'civicrm_contact.employer_id',
1593 'contactType' => 'Individual',
1594 'table_name' => 'civicrm_contact',
1595 'entity' => 'Contact',
1596 'bao' => 'CRM_Contact_BAO_Contact',
1598 'FKClassName' => 'CRM_Contact_DAO_Contact',
1600 'type' => 'EntityRef',
1601 'label' => ts("Current Employer"),
1605 'contact_is_deleted' => [
1606 'name' => 'is_deleted',
1607 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1608 'title' => ts('Contact is in Trash'),
1610 'where' => 'civicrm_contact.is_deleted',
1613 'table_name' => 'civicrm_contact',
1614 'entity' => 'Contact',
1615 'bao' => 'CRM_Contact_BAO_Contact',
1618 'type' => 'CheckBox',
1623 'name' => 'created_date',
1624 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
1625 'title' => ts('Created Date'),
1626 'description' => ts('When was the contact was created.'),
1627 'required' => FALSE,
1628 'where' => 'civicrm_contact.created_date',
1631 'table_name' => 'civicrm_contact',
1632 'entity' => 'Contact',
1633 'bao' => 'CRM_Contact_BAO_Contact',
1636 'label' => ts("Created Date"),
1640 'modified_date' => [
1641 'name' => 'modified_date',
1642 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
1643 'title' => ts('Modified Date'),
1644 'description' => ts('When was the contact (or closely related entity) was created or modified or deleted.'),
1645 'required' => FALSE,
1646 'where' => 'civicrm_contact.modified_date',
1648 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
1649 'table_name' => 'civicrm_contact',
1650 'entity' => 'Contact',
1651 'bao' => 'CRM_Contact_BAO_Contact',
1654 'label' => ts("Modified Date"),
1660 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
1662 return Civi
::$statics[__CLASS__
]['fields'];
1666 * Return a mapping from field-name to the corresponding key (as used in fields()).
1669 * Array(string $name => string $uniqueName).
1671 public static function &fieldKeys() {
1672 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
1673 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
1675 return Civi
::$statics[__CLASS__
]['fieldKeys'];
1679 * Returns the names of this table
1683 public static function getTableName() {
1684 return self
::$_tableName;
1688 * Returns if this table needs to be logged
1692 public function getLog() {
1697 * Returns the list of fields that can be imported
1699 * @param bool $prefix
1703 public static function &import($prefix = FALSE) {
1704 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'contact', $prefix, []);
1709 * Returns the list of fields that can be exported
1711 * @param bool $prefix
1715 public static function &export($prefix = FALSE) {
1716 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'contact', $prefix, []);
1721 * Returns the list of indices
1723 * @param bool $localize
1727 public static function indices($localize = TRUE) {
1729 'index_contact_type' => [
1730 'name' => 'index_contact_type',
1732 0 => 'contact_type',
1734 'localizable' => FALSE,
1735 'sig' => 'civicrm_contact::0::contact_type',
1737 'index_contact_sub_type' => [
1738 'name' => 'index_contact_sub_type',
1740 0 => 'contact_sub_type',
1742 'localizable' => FALSE,
1743 'sig' => 'civicrm_contact::0::contact_sub_type',
1745 'UI_external_identifier' => [
1746 'name' => 'UI_external_identifier',
1748 0 => 'external_identifier',
1750 'localizable' => FALSE,
1752 'sig' => 'civicrm_contact::1::external_identifier',
1754 'index_sort_name' => [
1755 'name' => 'index_sort_name',
1759 'localizable' => FALSE,
1760 'sig' => 'civicrm_contact::0::sort_name',
1762 'index_preferred_communication_method' => [
1763 'name' => 'index_preferred_communication_method',
1765 0 => 'preferred_communication_method',
1767 'localizable' => FALSE,
1768 'sig' => 'civicrm_contact::0::preferred_communication_method',
1771 'name' => 'index_hash',
1775 'localizable' => FALSE,
1776 'sig' => 'civicrm_contact::0::hash',
1778 'index_api_key' => [
1779 'name' => 'index_api_key',
1783 'localizable' => FALSE,
1784 'sig' => 'civicrm_contact::0::api_key',
1786 'index_first_name' => [
1787 'name' => 'index_first_name',
1791 'localizable' => FALSE,
1792 'sig' => 'civicrm_contact::0::first_name',
1794 'index_last_name' => [
1795 'name' => 'index_last_name',
1799 'localizable' => FALSE,
1800 'sig' => 'civicrm_contact::0::last_name',
1803 'name' => 'UI_prefix',
1807 'localizable' => FALSE,
1808 'sig' => 'civicrm_contact::0::prefix_id',
1811 'name' => 'UI_suffix',
1815 'localizable' => FALSE,
1816 'sig' => 'civicrm_contact::0::suffix_id',
1818 'index_communication_style_id' => [
1819 'name' => 'index_communication_style_id',
1821 0 => 'communication_style_id',
1823 'localizable' => FALSE,
1824 'sig' => 'civicrm_contact::0::communication_style_id',
1827 'name' => 'UI_gender',
1831 'localizable' => FALSE,
1832 'sig' => 'civicrm_contact::0::gender_id',
1834 'index_is_deceased' => [
1835 'name' => 'index_is_deceased',
1839 'localizable' => FALSE,
1840 'sig' => 'civicrm_contact::0::is_deceased',
1842 'index_household_name' => [
1843 'name' => 'index_household_name',
1845 0 => 'household_name',
1847 'localizable' => FALSE,
1848 'sig' => 'civicrm_contact::0::household_name',
1850 'index_organization_name' => [
1851 'name' => 'index_organization_name',
1853 0 => 'organization_name',
1855 'localizable' => FALSE,
1856 'sig' => 'civicrm_contact::0::organization_name',
1858 'index_is_deleted_sort_name' => [
1859 'name' => 'index_is_deleted_sort_name',
1865 'localizable' => FALSE,
1866 'sig' => 'civicrm_contact::0::is_deleted::sort_name::id',
1868 'index_created_date' => [
1869 'name' => 'index_created_date',
1871 0 => 'created_date',
1873 'localizable' => FALSE,
1874 'sig' => 'civicrm_contact::0::created_date',
1876 'index_modified_date' => [
1877 'name' => 'index_modified_date',
1879 0 => 'modified_date',
1881 'localizable' => FALSE,
1882 'sig' => 'civicrm_contact::0::modified_date',
1885 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;