Merge pull request #16429 from ixiam/dev/core#1113
[civicrm-core.git] / CRM / Contact / DAO / Contact.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Contact/Contact.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:da59563e28c0229228f7c2baa20caabf)
10 */
11
12 /**
13 * Database access object for the Contact entity.
14 */
15 class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_contact';
23
24 /**
25 * Icon associated with this entity.
26 *
27 * @var string
28 */
29 public static $_icon = 'fa-address-book-o';
30
31 /**
32 * Should CiviCRM log any modifications to this table in the civicrm_log table.
33 *
34 * @var bool
35 */
36 public static $_log = TRUE;
37
38 /**
39 * Unique Contact ID
40 *
41 * @var int
42 */
43 public $id;
44
45 /**
46 * Type of Contact.
47 *
48 * @var string
49 */
50 public $contact_type;
51
52 /**
53 * May be used to over-ride contact view and edit templates.
54 *
55 * @var string
56 */
57 public $contact_sub_type;
58
59 /**
60 * @var bool
61 */
62 public $do_not_email;
63
64 /**
65 * @var bool
66 */
67 public $do_not_phone;
68
69 /**
70 * @var bool
71 */
72 public $do_not_mail;
73
74 /**
75 * @var bool
76 */
77 public $do_not_sms;
78
79 /**
80 * @var bool
81 */
82 public $do_not_trade;
83
84 /**
85 * Has the contact opted out from receiving all bulk email from the organization or site domain?
86 *
87 * @var bool
88 */
89 public $is_opt_out;
90
91 /**
92 * May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.
93 *
94 * @var string
95 */
96 public $legal_identifier;
97
98 /**
99 * Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.
100 *
101 * @var string
102 */
103 public $external_identifier;
104
105 /**
106 * Name used for sorting different contact types
107 *
108 * @var string
109 */
110 public $sort_name;
111
112 /**
113 * Formatted name representing preferred format for display/print/other output.
114 *
115 * @var string
116 */
117 public $display_name;
118
119 /**
120 * Nickname.
121 *
122 * @var string
123 */
124 public $nick_name;
125
126 /**
127 * Legal Name.
128 *
129 * @var string
130 */
131 public $legal_name;
132
133 /**
134 * optional URL for preferred image (photo, logo, etc.) to display for this contact.
135 *
136 * @var text
137 */
138 public $image_URL;
139
140 /**
141 * What is the preferred mode of communication.
142 *
143 * @var string
144 */
145 public $preferred_communication_method;
146
147 /**
148 * Which language is preferred for communication. FK to languages in civicrm_option_value.
149 *
150 * @var string
151 */
152 public $preferred_language;
153
154 /**
155 * What is the preferred mode of sending an email.
156 *
157 * @var string
158 */
159 public $preferred_mail_format;
160
161 /**
162 * Key for validating requests related to this contact.
163 *
164 * @var string
165 */
166 public $hash;
167
168 /**
169 * API Key for validating requests related to this contact.
170 *
171 * @var string
172 */
173 public $api_key;
174
175 /**
176 * where contact come from, e.g. import, donate module insert...
177 *
178 * @var string
179 */
180 public $source;
181
182 /**
183 * First Name.
184 *
185 * @var string
186 */
187 public $first_name;
188
189 /**
190 * Middle Name.
191 *
192 * @var string
193 */
194 public $middle_name;
195
196 /**
197 * Last Name.
198 *
199 * @var string
200 */
201 public $last_name;
202
203 /**
204 * Prefix or Title for name (Ms, Mr...). FK to prefix ID
205 *
206 * @var int
207 */
208 public $prefix_id;
209
210 /**
211 * Suffix for name (Jr, Sr...). FK to suffix ID
212 *
213 * @var int
214 */
215 public $suffix_id;
216
217 /**
218 * Formal (academic or similar) title in front of name. (Prof., Dr. etc.)
219 *
220 * @var string
221 */
222 public $formal_title;
223
224 /**
225 * Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.
226 *
227 * @var int
228 */
229 public $communication_style_id;
230
231 /**
232 * FK to civicrm_option_value.id, that has to be valid registered Email Greeting.
233 *
234 * @var int
235 */
236 public $email_greeting_id;
237
238 /**
239 * Custom Email Greeting.
240 *
241 * @var string
242 */
243 public $email_greeting_custom;
244
245 /**
246 * Cache Email Greeting.
247 *
248 * @var string
249 */
250 public $email_greeting_display;
251
252 /**
253 * FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.
254 *
255 * @var int
256 */
257 public $postal_greeting_id;
258
259 /**
260 * Custom Postal greeting.
261 *
262 * @var string
263 */
264 public $postal_greeting_custom;
265
266 /**
267 * Cache Postal greeting.
268 *
269 * @var string
270 */
271 public $postal_greeting_display;
272
273 /**
274 * FK to civicrm_option_value.id, that has to be valid registered Addressee.
275 *
276 * @var int
277 */
278 public $addressee_id;
279
280 /**
281 * Custom Addressee.
282 *
283 * @var string
284 */
285 public $addressee_custom;
286
287 /**
288 * Cache Addressee.
289 *
290 * @var string
291 */
292 public $addressee_display;
293
294 /**
295 * Job Title
296 *
297 * @var string
298 */
299 public $job_title;
300
301 /**
302 * FK to gender ID
303 *
304 * @var int
305 */
306 public $gender_id;
307
308 /**
309 * Date of birth
310 *
311 * @var date
312 */
313 public $birth_date;
314
315 /**
316 * @var bool
317 */
318 public $is_deceased;
319
320 /**
321 * Date of deceased
322 *
323 * @var date
324 */
325 public $deceased_date;
326
327 /**
328 * Household Name.
329 *
330 * @var string
331 */
332 public $household_name;
333
334 /**
335 * Optional FK to Primary Contact for this household.
336 *
337 * @var int
338 */
339 public $primary_contact_id;
340
341 /**
342 * Organization Name.
343 *
344 * @var string
345 */
346 public $organization_name;
347
348 /**
349 * Standard Industry Classification Code.
350 *
351 * @var string
352 */
353 public $sic_code;
354
355 /**
356 * the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM
357 *
358 * @var string
359 */
360 public $user_unique_id;
361
362 /**
363 * OPTIONAL FK to civicrm_contact record.
364 *
365 * @var int
366 */
367 public $employer_id;
368
369 /**
370 * @var bool
371 */
372 public $is_deleted;
373
374 /**
375 * When was the contact was created.
376 *
377 * @var timestamp
378 */
379 public $created_date;
380
381 /**
382 * When was the contact (or closely related entity) was created or modified or deleted.
383 *
384 * @var timestamp
385 */
386 public $modified_date;
387
388 /**
389 * Class constructor.
390 */
391 public function __construct() {
392 $this->__table = 'civicrm_contact';
393 parent::__construct();
394 }
395
396 /**
397 * Returns localized title of this entity.
398 */
399 public static function getEntityTitle() {
400 return ts('Contacts');
401 }
402
403 /**
404 * Returns foreign keys and entity references.
405 *
406 * @return array
407 * [CRM_Core_Reference_Interface]
408 */
409 public static function getReferenceColumns() {
410 if (!isset(Civi::$statics[__CLASS__]['links'])) {
411 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
412 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'primary_contact_id', 'civicrm_contact', 'id');
413 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'employer_id', 'civicrm_contact', 'id');
414 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
415 }
416 return Civi::$statics[__CLASS__]['links'];
417 }
418
419 /**
420 * Returns all the column names of this table
421 *
422 * @return array
423 */
424 public static function &fields() {
425 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
426 Civi::$statics[__CLASS__]['fields'] = [
427 'id' => [
428 'name' => 'id',
429 'type' => CRM_Utils_Type::T_INT,
430 'title' => ts('Contact ID'),
431 'description' => ts('Unique Contact ID'),
432 'required' => TRUE,
433 'import' => TRUE,
434 'where' => 'civicrm_contact.id',
435 'headerPattern' => '/internal|contact?|id$/i',
436 'export' => TRUE,
437 'table_name' => 'civicrm_contact',
438 'entity' => 'Contact',
439 'bao' => 'CRM_Contact_BAO_Contact',
440 'localizable' => 0,
441 'add' => '1.1',
442 ],
443 'contact_type' => [
444 'name' => 'contact_type',
445 'type' => CRM_Utils_Type::T_STRING,
446 'title' => ts('Contact Type'),
447 'description' => ts('Type of Contact.'),
448 'maxlength' => 64,
449 'size' => CRM_Utils_Type::BIG,
450 'where' => 'civicrm_contact.contact_type',
451 'export' => TRUE,
452 'contactType' => NULL,
453 'table_name' => 'civicrm_contact',
454 'entity' => 'Contact',
455 'bao' => 'CRM_Contact_BAO_Contact',
456 'localizable' => 0,
457 'html' => [
458 'type' => 'Select',
459 ],
460 'pseudoconstant' => [
461 'table' => 'civicrm_contact_type',
462 'keyColumn' => 'name',
463 'labelColumn' => 'label',
464 'condition' => 'parent_id IS NULL',
465 ],
466 'add' => '1.1',
467 ],
468 'contact_sub_type' => [
469 'name' => 'contact_sub_type',
470 'type' => CRM_Utils_Type::T_STRING,
471 'title' => ts('Contact Subtype'),
472 'description' => ts('May be used to over-ride contact view and edit templates.'),
473 'maxlength' => 255,
474 'size' => CRM_Utils_Type::HUGE,
475 'import' => TRUE,
476 'where' => 'civicrm_contact.contact_sub_type',
477 'headerPattern' => '/C(ontact )?(subtype|sub-type|sub type)/i',
478 'export' => TRUE,
479 'table_name' => 'civicrm_contact',
480 'entity' => 'Contact',
481 'bao' => 'CRM_Contact_BAO_Contact',
482 'localizable' => 0,
483 'serialize' => self::SERIALIZE_SEPARATOR_BOOKEND,
484 'html' => [
485 'type' => 'Select',
486 ],
487 'pseudoconstant' => [
488 'table' => 'civicrm_contact_type',
489 'keyColumn' => 'name',
490 'labelColumn' => 'label',
491 'condition' => 'parent_id IS NOT NULL',
492 ],
493 'add' => '1.5',
494 ],
495 'do_not_email' => [
496 'name' => 'do_not_email',
497 'type' => CRM_Utils_Type::T_BOOLEAN,
498 'title' => ts('Do Not Email'),
499 'import' => TRUE,
500 'where' => 'civicrm_contact.do_not_email',
501 'headerPattern' => '/d(o )?(not )?(email)/i',
502 'dataPattern' => '/^\d{1,}$/',
503 'export' => TRUE,
504 'default' => '0',
505 'table_name' => 'civicrm_contact',
506 'entity' => 'Contact',
507 'bao' => 'CRM_Contact_BAO_Contact',
508 'localizable' => 0,
509 'html' => [
510 'type' => 'CheckBox',
511 ],
512 'add' => '1.1',
513 ],
514 'do_not_phone' => [
515 'name' => 'do_not_phone',
516 'type' => CRM_Utils_Type::T_BOOLEAN,
517 'title' => ts('Do Not Phone'),
518 'import' => TRUE,
519 'where' => 'civicrm_contact.do_not_phone',
520 'headerPattern' => '/d(o )?(not )?(call|phone)/i',
521 'dataPattern' => '/^\d{1,}$/',
522 'export' => TRUE,
523 'default' => '0',
524 'table_name' => 'civicrm_contact',
525 'entity' => 'Contact',
526 'bao' => 'CRM_Contact_BAO_Contact',
527 'localizable' => 0,
528 'html' => [
529 'type' => 'CheckBox',
530 ],
531 'add' => '1.1',
532 ],
533 'do_not_mail' => [
534 'name' => 'do_not_mail',
535 'type' => CRM_Utils_Type::T_BOOLEAN,
536 'title' => ts('Do Not Mail'),
537 'import' => TRUE,
538 'where' => 'civicrm_contact.do_not_mail',
539 'headerPattern' => '/^(d(o\s)?n(ot\s)?mail)|(\w*)?bulk\s?(\w*)$/i',
540 'dataPattern' => '/^\d{1,}$/',
541 'export' => TRUE,
542 'default' => '0',
543 'table_name' => 'civicrm_contact',
544 'entity' => 'Contact',
545 'bao' => 'CRM_Contact_BAO_Contact',
546 'localizable' => 0,
547 'html' => [
548 'type' => 'CheckBox',
549 ],
550 'add' => '1.1',
551 ],
552 'do_not_sms' => [
553 'name' => 'do_not_sms',
554 'type' => CRM_Utils_Type::T_BOOLEAN,
555 'title' => ts('Do Not Sms'),
556 'import' => TRUE,
557 'where' => 'civicrm_contact.do_not_sms',
558 'headerPattern' => '/d(o )?(not )?(sms)/i',
559 'dataPattern' => '/^\d{1,}$/',
560 'export' => TRUE,
561 'default' => '0',
562 'table_name' => 'civicrm_contact',
563 'entity' => 'Contact',
564 'bao' => 'CRM_Contact_BAO_Contact',
565 'localizable' => 0,
566 'html' => [
567 'type' => 'CheckBox',
568 ],
569 'add' => '3.0',
570 ],
571 'do_not_trade' => [
572 'name' => 'do_not_trade',
573 'type' => CRM_Utils_Type::T_BOOLEAN,
574 'title' => ts('Do Not Trade'),
575 'import' => TRUE,
576 'where' => 'civicrm_contact.do_not_trade',
577 'headerPattern' => '/d(o )?(not )?(trade)/i',
578 'dataPattern' => '/^\d{1,}$/',
579 'export' => TRUE,
580 'default' => '0',
581 'table_name' => 'civicrm_contact',
582 'entity' => 'Contact',
583 'bao' => 'CRM_Contact_BAO_Contact',
584 'localizable' => 0,
585 'html' => [
586 'type' => 'CheckBox',
587 ],
588 'add' => '1.1',
589 ],
590 'is_opt_out' => [
591 'name' => 'is_opt_out',
592 'type' => CRM_Utils_Type::T_BOOLEAN,
593 'title' => ts('No Bulk Emails (User Opt Out)'),
594 'description' => ts('Has the contact opted out from receiving all bulk email from the organization or site domain?'),
595 'required' => TRUE,
596 'import' => TRUE,
597 'where' => 'civicrm_contact.is_opt_out',
598 'export' => TRUE,
599 'default' => '0',
600 'table_name' => 'civicrm_contact',
601 'entity' => 'Contact',
602 'bao' => 'CRM_Contact_BAO_Contact',
603 'localizable' => 0,
604 'html' => [
605 'type' => 'CheckBox',
606 ],
607 'add' => '1.1',
608 ],
609 'legal_identifier' => [
610 'name' => 'legal_identifier',
611 'type' => CRM_Utils_Type::T_STRING,
612 'title' => ts('Legal Identifier'),
613 'description' => ts('May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.'),
614 'maxlength' => 32,
615 'size' => CRM_Utils_Type::MEDIUM,
616 'import' => TRUE,
617 'where' => 'civicrm_contact.legal_identifier',
618 'headerPattern' => '/legal\s?id/i',
619 'dataPattern' => '/\w+?\d{5,}/',
620 'export' => TRUE,
621 'table_name' => 'civicrm_contact',
622 'entity' => 'Contact',
623 'bao' => 'CRM_Contact_BAO_Contact',
624 'localizable' => 0,
625 'html' => [
626 'type' => 'Text',
627 ],
628 'add' => '1.1',
629 ],
630 'external_identifier' => [
631 'name' => 'external_identifier',
632 'type' => CRM_Utils_Type::T_STRING,
633 'title' => ts('External Identifier'),
634 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
635 'maxlength' => 64,
636 'size' => 8,
637 'import' => TRUE,
638 'where' => 'civicrm_contact.external_identifier',
639 'headerPattern' => '/external\s?id/i',
640 'dataPattern' => '/^\d{11,}$/',
641 'export' => TRUE,
642 'table_name' => 'civicrm_contact',
643 'entity' => 'Contact',
644 'bao' => 'CRM_Contact_BAO_Contact',
645 'localizable' => 0,
646 'html' => [
647 'type' => 'Text',
648 ],
649 'add' => '1.1',
650 ],
651 'sort_name' => [
652 'name' => 'sort_name',
653 'type' => CRM_Utils_Type::T_STRING,
654 'title' => ts('Sort Name'),
655 'description' => ts('Name used for sorting different contact types'),
656 'maxlength' => 128,
657 'size' => 30,
658 'where' => 'civicrm_contact.sort_name',
659 'export' => TRUE,
660 'table_name' => 'civicrm_contact',
661 'entity' => 'Contact',
662 'bao' => 'CRM_Contact_BAO_Contact',
663 'localizable' => 0,
664 'html' => [
665 'type' => 'Text',
666 ],
667 'add' => '1.1',
668 ],
669 'display_name' => [
670 'name' => 'display_name',
671 'type' => CRM_Utils_Type::T_STRING,
672 'title' => ts('Display Name'),
673 'description' => ts('Formatted name representing preferred format for display/print/other output.'),
674 'maxlength' => 128,
675 'size' => 30,
676 'where' => 'civicrm_contact.display_name',
677 'export' => TRUE,
678 'table_name' => 'civicrm_contact',
679 'entity' => 'Contact',
680 'bao' => 'CRM_Contact_BAO_Contact',
681 'localizable' => 0,
682 'html' => [
683 'type' => 'Text',
684 ],
685 'add' => '1.1',
686 ],
687 'nick_name' => [
688 'name' => 'nick_name',
689 'type' => CRM_Utils_Type::T_STRING,
690 'title' => ts('Nickname'),
691 'description' => ts('Nickname.'),
692 'maxlength' => 128,
693 'size' => 30,
694 'import' => TRUE,
695 'where' => 'civicrm_contact.nick_name',
696 'headerPattern' => '/n(ick\s)name|nick$/i',
697 'dataPattern' => '/^\w+$/',
698 'export' => TRUE,
699 'table_name' => 'civicrm_contact',
700 'entity' => 'Contact',
701 'bao' => 'CRM_Contact_BAO_Contact',
702 'localizable' => 0,
703 'html' => [
704 'type' => 'Text',
705 ],
706 'add' => '1.1',
707 ],
708 'legal_name' => [
709 'name' => 'legal_name',
710 'type' => CRM_Utils_Type::T_STRING,
711 'title' => ts('Legal Name'),
712 'description' => ts('Legal Name.'),
713 'maxlength' => 128,
714 'size' => 30,
715 'import' => TRUE,
716 'where' => 'civicrm_contact.legal_name',
717 'headerPattern' => '/^legal|(l(egal\s)?name)$/i',
718 'export' => TRUE,
719 'contactType' => 'Organization',
720 'table_name' => 'civicrm_contact',
721 'entity' => 'Contact',
722 'bao' => 'CRM_Contact_BAO_Contact',
723 'localizable' => 0,
724 'html' => [
725 'type' => 'Text',
726 ],
727 'add' => '1.1',
728 ],
729 'image_URL' => [
730 'name' => 'image_URL',
731 'type' => CRM_Utils_Type::T_TEXT,
732 'title' => ts('Image Url'),
733 'description' => ts('optional URL for preferred image (photo, logo, etc.) to display for this contact.'),
734 'import' => TRUE,
735 'where' => 'civicrm_contact.image_URL',
736 'export' => TRUE,
737 'table_name' => 'civicrm_contact',
738 'entity' => 'Contact',
739 'bao' => 'CRM_Contact_BAO_Contact',
740 'localizable' => 0,
741 'html' => [
742 'type' => 'File',
743 ],
744 'add' => '1.1',
745 ],
746 'preferred_communication_method' => [
747 'name' => 'preferred_communication_method',
748 'type' => CRM_Utils_Type::T_STRING,
749 'title' => ts('Preferred Communication Method'),
750 'description' => ts('What is the preferred mode of communication.'),
751 'maxlength' => 255,
752 'size' => CRM_Utils_Type::HUGE,
753 'import' => TRUE,
754 'where' => 'civicrm_contact.preferred_communication_method',
755 'headerPattern' => '/^p(ref\w*\s)?c(omm\w*)|( meth\w*)$/i',
756 'dataPattern' => '/^\w+$/',
757 'export' => TRUE,
758 'table_name' => 'civicrm_contact',
759 'entity' => 'Contact',
760 'bao' => 'CRM_Contact_BAO_Contact',
761 'localizable' => 0,
762 'serialize' => self::SERIALIZE_SEPARATOR_BOOKEND,
763 'html' => [
764 'type' => 'Select',
765 ],
766 'pseudoconstant' => [
767 'optionGroupName' => 'preferred_communication_method',
768 'optionEditPath' => 'civicrm/admin/options/preferred_communication_method',
769 ],
770 'add' => '1.1',
771 ],
772 'preferred_language' => [
773 'name' => 'preferred_language',
774 'type' => CRM_Utils_Type::T_STRING,
775 'title' => ts('Preferred Language'),
776 'description' => ts('Which language is preferred for communication. FK to languages in civicrm_option_value.'),
777 'maxlength' => 5,
778 'size' => CRM_Utils_Type::SIX,
779 'import' => TRUE,
780 'where' => 'civicrm_contact.preferred_language',
781 'headerPattern' => '/^lang/i',
782 'export' => TRUE,
783 'table_name' => 'civicrm_contact',
784 'entity' => 'Contact',
785 'bao' => 'CRM_Contact_BAO_Contact',
786 'localizable' => 0,
787 'html' => [
788 'type' => 'Select',
789 ],
790 'pseudoconstant' => [
791 'optionGroupName' => 'languages',
792 'keyColumn' => 'name',
793 'optionEditPath' => 'civicrm/admin/options/languages',
794 ],
795 'add' => '3.2',
796 ],
797 'preferred_mail_format' => [
798 'name' => 'preferred_mail_format',
799 'type' => CRM_Utils_Type::T_STRING,
800 'title' => ts('Preferred Mail Format'),
801 'description' => ts('What is the preferred mode of sending an email.'),
802 'maxlength' => 8,
803 'size' => CRM_Utils_Type::EIGHT,
804 'import' => TRUE,
805 'where' => 'civicrm_contact.preferred_mail_format',
806 'headerPattern' => '/^p(ref\w*\s)?m(ail\s)?f(orm\w*)$/i',
807 'export' => TRUE,
808 'default' => 'Both',
809 'table_name' => 'civicrm_contact',
810 'entity' => 'Contact',
811 'bao' => 'CRM_Contact_BAO_Contact',
812 'localizable' => 0,
813 'html' => [
814 'type' => 'Select',
815 ],
816 'pseudoconstant' => [
817 'callback' => 'CRM_Core_SelectValues::pmf',
818 ],
819 'add' => '1.1',
820 ],
821 'hash' => [
822 'name' => 'hash',
823 'type' => CRM_Utils_Type::T_STRING,
824 'title' => ts('Contact Hash'),
825 'description' => ts('Key for validating requests related to this contact.'),
826 'maxlength' => 32,
827 'size' => CRM_Utils_Type::MEDIUM,
828 'where' => 'civicrm_contact.hash',
829 'export' => TRUE,
830 'table_name' => 'civicrm_contact',
831 'entity' => 'Contact',
832 'bao' => 'CRM_Contact_BAO_Contact',
833 'localizable' => 0,
834 'add' => '1.1',
835 ],
836 'api_key' => [
837 'name' => 'api_key',
838 'type' => CRM_Utils_Type::T_STRING,
839 'title' => ts('Api Key'),
840 'description' => ts('API Key for validating requests related to this contact.'),
841 'maxlength' => 32,
842 'size' => CRM_Utils_Type::MEDIUM,
843 'where' => 'civicrm_contact.api_key',
844 'permission' => [
845 [
846 'administer CiviCRM',
847 'edit api keys',
848 ],
849 ],
850 'table_name' => 'civicrm_contact',
851 'entity' => 'Contact',
852 'bao' => 'CRM_Contact_BAO_Contact',
853 'localizable' => 0,
854 'add' => '2.2',
855 ],
856 'contact_source' => [
857 'name' => 'source',
858 'type' => CRM_Utils_Type::T_STRING,
859 'title' => ts('Contact Source'),
860 'description' => ts('where contact come from, e.g. import, donate module insert...'),
861 'maxlength' => 255,
862 'size' => 30,
863 'import' => TRUE,
864 'where' => 'civicrm_contact.source',
865 'headerPattern' => '/(C(ontact\s)?Source)$/i',
866 'export' => TRUE,
867 'table_name' => 'civicrm_contact',
868 'entity' => 'Contact',
869 'bao' => 'CRM_Contact_BAO_Contact',
870 'localizable' => 0,
871 'html' => [
872 'type' => 'Text',
873 ],
874 'add' => '1.1',
875 ],
876 'first_name' => [
877 'name' => 'first_name',
878 'type' => CRM_Utils_Type::T_STRING,
879 'title' => ts('First Name'),
880 'description' => ts('First Name.'),
881 'maxlength' => 64,
882 'size' => 30,
883 'import' => TRUE,
884 'where' => 'civicrm_contact.first_name',
885 'headerPattern' => '/^first|(f(irst\s)?name)$/i',
886 'dataPattern' => '/^\w+$/',
887 'export' => TRUE,
888 'contactType' => 'Individual',
889 'table_name' => 'civicrm_contact',
890 'entity' => 'Contact',
891 'bao' => 'CRM_Contact_BAO_Contact',
892 'localizable' => 0,
893 'html' => [
894 'type' => 'Text',
895 ],
896 'add' => '1.1',
897 ],
898 'middle_name' => [
899 'name' => 'middle_name',
900 'type' => CRM_Utils_Type::T_STRING,
901 'title' => ts('Middle Name'),
902 'description' => ts('Middle Name.'),
903 'maxlength' => 64,
904 'size' => 30,
905 'import' => TRUE,
906 'where' => 'civicrm_contact.middle_name',
907 'headerPattern' => '/^middle|(m(iddle\s)?name)$/i',
908 'dataPattern' => '/^\w+$/',
909 'export' => TRUE,
910 'contactType' => 'Individual',
911 'table_name' => 'civicrm_contact',
912 'entity' => 'Contact',
913 'bao' => 'CRM_Contact_BAO_Contact',
914 'localizable' => 0,
915 'html' => [
916 'type' => 'Text',
917 ],
918 'add' => '1.1',
919 ],
920 'last_name' => [
921 'name' => 'last_name',
922 'type' => CRM_Utils_Type::T_STRING,
923 'title' => ts('Last Name'),
924 'description' => ts('Last Name.'),
925 'maxlength' => 64,
926 'size' => 30,
927 'import' => TRUE,
928 'where' => 'civicrm_contact.last_name',
929 'headerPattern' => '/^last|(l(ast\s)?name)$/i',
930 'dataPattern' => '/^\w+(\s\w+)?+$/',
931 'export' => TRUE,
932 'contactType' => 'Individual',
933 'table_name' => 'civicrm_contact',
934 'entity' => 'Contact',
935 'bao' => 'CRM_Contact_BAO_Contact',
936 'localizable' => 0,
937 'html' => [
938 'type' => 'Text',
939 ],
940 'add' => '1.1',
941 ],
942 'prefix_id' => [
943 'name' => 'prefix_id',
944 'type' => CRM_Utils_Type::T_INT,
945 'title' => ts('Individual Prefix'),
946 'description' => ts('Prefix or Title for name (Ms, Mr...). FK to prefix ID'),
947 'import' => TRUE,
948 'where' => 'civicrm_contact.prefix_id',
949 'headerPattern' => '/^(prefix|title)/i',
950 'dataPattern' => '/^(mr|ms|mrs|sir|dr)\.?$/i',
951 'export' => TRUE,
952 'contactType' => 'Individual',
953 'table_name' => 'civicrm_contact',
954 'entity' => 'Contact',
955 'bao' => 'CRM_Contact_BAO_Contact',
956 'localizable' => 0,
957 'html' => [
958 'type' => 'Select',
959 ],
960 'pseudoconstant' => [
961 'optionGroupName' => 'individual_prefix',
962 'optionEditPath' => 'civicrm/admin/options/individual_prefix',
963 ],
964 'add' => '1.2',
965 ],
966 'suffix_id' => [
967 'name' => 'suffix_id',
968 'type' => CRM_Utils_Type::T_INT,
969 'title' => ts('Individual Suffix'),
970 'description' => ts('Suffix for name (Jr, Sr...). FK to suffix ID'),
971 'import' => TRUE,
972 'where' => 'civicrm_contact.suffix_id',
973 'headerPattern' => '/^suffix$/i',
974 'dataPattern' => '/^(sr|jr)\.?|i{2,}$/',
975 'export' => TRUE,
976 'contactType' => 'Individual',
977 'table_name' => 'civicrm_contact',
978 'entity' => 'Contact',
979 'bao' => 'CRM_Contact_BAO_Contact',
980 'localizable' => 0,
981 'html' => [
982 'type' => 'Select',
983 ],
984 'pseudoconstant' => [
985 'optionGroupName' => 'individual_suffix',
986 'optionEditPath' => 'civicrm/admin/options/individual_suffix',
987 ],
988 'add' => '1.2',
989 ],
990 'formal_title' => [
991 'name' => 'formal_title',
992 'type' => CRM_Utils_Type::T_STRING,
993 'title' => ts('Formal Title'),
994 'description' => ts('Formal (academic or similar) title in front of name. (Prof., Dr. etc.)'),
995 'maxlength' => 64,
996 'size' => CRM_Utils_Type::BIG,
997 'import' => TRUE,
998 'where' => 'civicrm_contact.formal_title',
999 'headerPattern' => '/^title/i',
1000 'export' => TRUE,
1001 'contactType' => 'Individual',
1002 'table_name' => 'civicrm_contact',
1003 'entity' => 'Contact',
1004 'bao' => 'CRM_Contact_BAO_Contact',
1005 'localizable' => 0,
1006 'html' => [
1007 'type' => 'Text',
1008 ],
1009 'add' => '4.5',
1010 ],
1011 'communication_style_id' => [
1012 'name' => 'communication_style_id',
1013 'type' => CRM_Utils_Type::T_INT,
1014 'title' => ts('Communication Style'),
1015 'description' => ts('Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.'),
1016 'import' => TRUE,
1017 'where' => 'civicrm_contact.communication_style_id',
1018 'headerPattern' => '/style/i',
1019 'export' => TRUE,
1020 'table_name' => 'civicrm_contact',
1021 'entity' => 'Contact',
1022 'bao' => 'CRM_Contact_BAO_Contact',
1023 'localizable' => 0,
1024 'html' => [
1025 'type' => 'Select',
1026 ],
1027 'pseudoconstant' => [
1028 'optionGroupName' => 'communication_style',
1029 'optionEditPath' => 'civicrm/admin/options/communication_style',
1030 ],
1031 'add' => '4.4',
1032 ],
1033 'email_greeting_id' => [
1034 'name' => 'email_greeting_id',
1035 'type' => CRM_Utils_Type::T_INT,
1036 'title' => ts('Email Greeting ID'),
1037 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Email Greeting.'),
1038 'where' => 'civicrm_contact.email_greeting_id',
1039 'export' => TRUE,
1040 'table_name' => 'civicrm_contact',
1041 'entity' => 'Contact',
1042 'bao' => 'CRM_Contact_BAO_Contact',
1043 'localizable' => 0,
1044 'html' => [
1045 'type' => 'Select',
1046 ],
1047 'pseudoconstant' => [
1048 'optionGroupName' => 'email_greeting',
1049 'optionEditPath' => 'civicrm/admin/options/email_greeting',
1050 ],
1051 'add' => '3.0',
1052 ],
1053 'email_greeting_custom' => [
1054 'name' => 'email_greeting_custom',
1055 'type' => CRM_Utils_Type::T_STRING,
1056 'title' => ts('Email Greeting Custom'),
1057 'description' => ts('Custom Email Greeting.'),
1058 'maxlength' => 128,
1059 'size' => CRM_Utils_Type::HUGE,
1060 'import' => TRUE,
1061 'where' => 'civicrm_contact.email_greeting_custom',
1062 'export' => FALSE,
1063 'table_name' => 'civicrm_contact',
1064 'entity' => 'Contact',
1065 'bao' => 'CRM_Contact_BAO_Contact',
1066 'localizable' => 0,
1067 'html' => [
1068 'type' => 'Text',
1069 ],
1070 'add' => '3.0',
1071 ],
1072 'email_greeting_display' => [
1073 'name' => 'email_greeting_display',
1074 'type' => CRM_Utils_Type::T_STRING,
1075 'title' => ts('Email Greeting'),
1076 'description' => ts('Cache Email Greeting.'),
1077 'maxlength' => 255,
1078 'size' => CRM_Utils_Type::HUGE,
1079 'where' => 'civicrm_contact.email_greeting_display',
1080 'table_name' => 'civicrm_contact',
1081 'entity' => 'Contact',
1082 'bao' => 'CRM_Contact_BAO_Contact',
1083 'localizable' => 0,
1084 'add' => '3.0',
1085 ],
1086 'postal_greeting_id' => [
1087 'name' => 'postal_greeting_id',
1088 'type' => CRM_Utils_Type::T_INT,
1089 'title' => ts('Postal Greeting ID'),
1090 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.'),
1091 'where' => 'civicrm_contact.postal_greeting_id',
1092 'export' => TRUE,
1093 'table_name' => 'civicrm_contact',
1094 'entity' => 'Contact',
1095 'bao' => 'CRM_Contact_BAO_Contact',
1096 'localizable' => 0,
1097 'html' => [
1098 'type' => 'Select',
1099 ],
1100 'pseudoconstant' => [
1101 'optionGroupName' => 'postal_greeting',
1102 'optionEditPath' => 'civicrm/admin/options/postal_greeting',
1103 ],
1104 'add' => '3.0',
1105 ],
1106 'postal_greeting_custom' => [
1107 'name' => 'postal_greeting_custom',
1108 'type' => CRM_Utils_Type::T_STRING,
1109 'title' => ts('Postal Greeting Custom'),
1110 'description' => ts('Custom Postal greeting.'),
1111 'maxlength' => 128,
1112 'size' => CRM_Utils_Type::HUGE,
1113 'import' => TRUE,
1114 'where' => 'civicrm_contact.postal_greeting_custom',
1115 'export' => FALSE,
1116 'table_name' => 'civicrm_contact',
1117 'entity' => 'Contact',
1118 'bao' => 'CRM_Contact_BAO_Contact',
1119 'localizable' => 0,
1120 'html' => [
1121 'type' => 'Text',
1122 ],
1123 'add' => '3.0',
1124 ],
1125 'postal_greeting_display' => [
1126 'name' => 'postal_greeting_display',
1127 'type' => CRM_Utils_Type::T_STRING,
1128 'title' => ts('Postal Greeting'),
1129 'description' => ts('Cache Postal greeting.'),
1130 'maxlength' => 255,
1131 'size' => CRM_Utils_Type::HUGE,
1132 'where' => 'civicrm_contact.postal_greeting_display',
1133 'table_name' => 'civicrm_contact',
1134 'entity' => 'Contact',
1135 'bao' => 'CRM_Contact_BAO_Contact',
1136 'localizable' => 0,
1137 'add' => '3.0',
1138 ],
1139 'addressee_id' => [
1140 'name' => 'addressee_id',
1141 'type' => CRM_Utils_Type::T_INT,
1142 'title' => ts('Addressee ID'),
1143 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Addressee.'),
1144 'where' => 'civicrm_contact.addressee_id',
1145 'export' => TRUE,
1146 'table_name' => 'civicrm_contact',
1147 'entity' => 'Contact',
1148 'bao' => 'CRM_Contact_BAO_Contact',
1149 'localizable' => 0,
1150 'html' => [
1151 'type' => 'Select',
1152 ],
1153 'pseudoconstant' => [
1154 'optionGroupName' => 'addressee',
1155 'optionEditPath' => 'civicrm/admin/options/addressee',
1156 ],
1157 'add' => '3.0',
1158 ],
1159 'addressee_custom' => [
1160 'name' => 'addressee_custom',
1161 'type' => CRM_Utils_Type::T_STRING,
1162 'title' => ts('Addressee Custom'),
1163 'description' => ts('Custom Addressee.'),
1164 'maxlength' => 128,
1165 'size' => CRM_Utils_Type::HUGE,
1166 'import' => TRUE,
1167 'where' => 'civicrm_contact.addressee_custom',
1168 'export' => FALSE,
1169 'table_name' => 'civicrm_contact',
1170 'entity' => 'Contact',
1171 'bao' => 'CRM_Contact_BAO_Contact',
1172 'localizable' => 0,
1173 'html' => [
1174 'type' => 'Text',
1175 ],
1176 'add' => '3.0',
1177 ],
1178 'addressee_display' => [
1179 'name' => 'addressee_display',
1180 'type' => CRM_Utils_Type::T_STRING,
1181 'title' => ts('Addressee'),
1182 'description' => ts('Cache Addressee.'),
1183 'maxlength' => 255,
1184 'size' => CRM_Utils_Type::HUGE,
1185 'where' => 'civicrm_contact.addressee_display',
1186 'table_name' => 'civicrm_contact',
1187 'entity' => 'Contact',
1188 'bao' => 'CRM_Contact_BAO_Contact',
1189 'localizable' => 0,
1190 'add' => '3.0',
1191 ],
1192 'job_title' => [
1193 'name' => 'job_title',
1194 'type' => CRM_Utils_Type::T_STRING,
1195 'title' => ts('Job Title'),
1196 'description' => ts('Job Title'),
1197 'maxlength' => 255,
1198 'size' => 30,
1199 'import' => TRUE,
1200 'where' => 'civicrm_contact.job_title',
1201 'headerPattern' => '/^job|(j(ob\s)?title)$/i',
1202 'dataPattern' => '//',
1203 'export' => TRUE,
1204 'contactType' => 'Individual',
1205 'table_name' => 'civicrm_contact',
1206 'entity' => 'Contact',
1207 'bao' => 'CRM_Contact_BAO_Contact',
1208 'localizable' => 0,
1209 'html' => [
1210 'type' => 'Text',
1211 ],
1212 'add' => '1.1',
1213 ],
1214 'gender_id' => [
1215 'name' => 'gender_id',
1216 'type' => CRM_Utils_Type::T_INT,
1217 'title' => ts('Gender'),
1218 'description' => ts('FK to gender ID'),
1219 'import' => TRUE,
1220 'where' => 'civicrm_contact.gender_id',
1221 'headerPattern' => '/^gender$/i',
1222 'export' => TRUE,
1223 'contactType' => 'Individual',
1224 'table_name' => 'civicrm_contact',
1225 'entity' => 'Contact',
1226 'bao' => 'CRM_Contact_BAO_Contact',
1227 'localizable' => 0,
1228 'html' => [
1229 'type' => 'Select',
1230 ],
1231 'pseudoconstant' => [
1232 'optionGroupName' => 'gender',
1233 'optionEditPath' => 'civicrm/admin/options/gender',
1234 ],
1235 'add' => '1.2',
1236 ],
1237 'birth_date' => [
1238 'name' => 'birth_date',
1239 'type' => CRM_Utils_Type::T_DATE,
1240 'title' => ts('Birth Date'),
1241 'description' => ts('Date of birth'),
1242 'import' => TRUE,
1243 'where' => 'civicrm_contact.birth_date',
1244 'headerPattern' => '/^birth|(b(irth\s)?date)|D(\W*)O(\W*)B(\W*)$/i',
1245 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
1246 'export' => TRUE,
1247 'contactType' => 'Individual',
1248 'table_name' => 'civicrm_contact',
1249 'entity' => 'Contact',
1250 'bao' => 'CRM_Contact_BAO_Contact',
1251 'localizable' => 0,
1252 'html' => [
1253 'type' => 'Select Date',
1254 'formatType' => 'birth',
1255 ],
1256 'add' => '1.1',
1257 ],
1258 'is_deceased' => [
1259 'name' => 'is_deceased',
1260 'type' => CRM_Utils_Type::T_BOOLEAN,
1261 'title' => ts('Deceased'),
1262 'required' => TRUE,
1263 'import' => TRUE,
1264 'where' => 'civicrm_contact.is_deceased',
1265 'headerPattern' => '/i(s\s)?d(eceased)$/i',
1266 'export' => TRUE,
1267 'contactType' => 'Individual',
1268 'default' => '0',
1269 'table_name' => 'civicrm_contact',
1270 'entity' => 'Contact',
1271 'bao' => 'CRM_Contact_BAO_Contact',
1272 'localizable' => 0,
1273 'html' => [
1274 'type' => 'CheckBox',
1275 ],
1276 'add' => '1.1',
1277 ],
1278 'deceased_date' => [
1279 'name' => 'deceased_date',
1280 'type' => CRM_Utils_Type::T_DATE,
1281 'title' => ts('Deceased Date'),
1282 'description' => ts('Date of deceased'),
1283 'import' => TRUE,
1284 'where' => 'civicrm_contact.deceased_date',
1285 'headerPattern' => '/^deceased|(d(eceased\s)?date)$/i',
1286 'export' => TRUE,
1287 'contactType' => 'Individual',
1288 'table_name' => 'civicrm_contact',
1289 'entity' => 'Contact',
1290 'bao' => 'CRM_Contact_BAO_Contact',
1291 'localizable' => 0,
1292 'html' => [
1293 'type' => 'Select Date',
1294 'formatType' => 'birth',
1295 ],
1296 'add' => '1.5',
1297 ],
1298 'household_name' => [
1299 'name' => 'household_name',
1300 'type' => CRM_Utils_Type::T_STRING,
1301 'title' => ts('Household Name'),
1302 'description' => ts('Household Name.'),
1303 'maxlength' => 128,
1304 'size' => 30,
1305 'import' => TRUE,
1306 'where' => 'civicrm_contact.household_name',
1307 'headerPattern' => '/^household|(h(ousehold\s)?name)$/i',
1308 'dataPattern' => '/^\w+$/',
1309 'export' => TRUE,
1310 'contactType' => 'Household',
1311 'table_name' => 'civicrm_contact',
1312 'entity' => 'Contact',
1313 'bao' => 'CRM_Contact_BAO_Contact',
1314 'localizable' => 0,
1315 'html' => [
1316 'type' => 'Text',
1317 ],
1318 'add' => '1.1',
1319 ],
1320 'primary_contact_id' => [
1321 'name' => 'primary_contact_id',
1322 'type' => CRM_Utils_Type::T_INT,
1323 'title' => ts('Household Primary Contact ID'),
1324 'description' => ts('Optional FK to Primary Contact for this household.'),
1325 'where' => 'civicrm_contact.primary_contact_id',
1326 'contactType' => 'Household',
1327 'table_name' => 'civicrm_contact',
1328 'entity' => 'Contact',
1329 'bao' => 'CRM_Contact_BAO_Contact',
1330 'localizable' => 0,
1331 'FKClassName' => 'CRM_Contact_DAO_Contact',
1332 'add' => '1.1',
1333 ],
1334 'organization_name' => [
1335 'name' => 'organization_name',
1336 'type' => CRM_Utils_Type::T_STRING,
1337 'title' => ts('Organization Name'),
1338 'description' => ts('Organization Name.'),
1339 'maxlength' => 128,
1340 'size' => 30,
1341 'import' => TRUE,
1342 'where' => 'civicrm_contact.organization_name',
1343 'headerPattern' => '/^organization|(o(rganization\s)?name)$/i',
1344 'dataPattern' => '/^\w+$/',
1345 'export' => TRUE,
1346 'contactType' => 'Organization',
1347 'table_name' => 'civicrm_contact',
1348 'entity' => 'Contact',
1349 'bao' => 'CRM_Contact_BAO_Contact',
1350 'localizable' => 0,
1351 'html' => [
1352 'type' => 'Text',
1353 ],
1354 'add' => '1.1',
1355 ],
1356 'sic_code' => [
1357 'name' => 'sic_code',
1358 'type' => CRM_Utils_Type::T_STRING,
1359 'title' => ts('Sic Code'),
1360 'description' => ts('Standard Industry Classification Code.'),
1361 'maxlength' => 8,
1362 'size' => CRM_Utils_Type::EIGHT,
1363 'import' => TRUE,
1364 'where' => 'civicrm_contact.sic_code',
1365 'headerPattern' => '/^sic|(s(ic\s)?code)$/i',
1366 'export' => TRUE,
1367 'contactType' => 'Organization',
1368 'table_name' => 'civicrm_contact',
1369 'entity' => 'Contact',
1370 'bao' => 'CRM_Contact_BAO_Contact',
1371 'localizable' => 0,
1372 'html' => [
1373 'type' => 'Text',
1374 ],
1375 'add' => '1.1',
1376 ],
1377 'user_unique_id' => [
1378 'name' => 'user_unique_id',
1379 'type' => CRM_Utils_Type::T_STRING,
1380 'title' => ts('Unique ID (OpenID)'),
1381 'description' => ts('the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM'),
1382 'maxlength' => 255,
1383 'size' => CRM_Utils_Type::HUGE,
1384 'import' => TRUE,
1385 'where' => 'civicrm_contact.user_unique_id',
1386 'headerPattern' => '/^Open\s?ID|u(niq\w*)?\s?ID/i',
1387 'dataPattern' => '/^[\w\/\:\.]+$/',
1388 'export' => TRUE,
1389 'rule' => 'url',
1390 'table_name' => 'civicrm_contact',
1391 'entity' => 'Contact',
1392 'bao' => 'CRM_Contact_BAO_Contact',
1393 'localizable' => 0,
1394 'html' => [
1395 'type' => 'Text',
1396 ],
1397 'add' => '2.0',
1398 ],
1399 'current_employer_id' => [
1400 'name' => 'employer_id',
1401 'type' => CRM_Utils_Type::T_INT,
1402 'title' => ts('Current Employer'),
1403 'description' => ts('OPTIONAL FK to civicrm_contact record.'),
1404 'where' => 'civicrm_contact.employer_id',
1405 'export' => TRUE,
1406 'contactType' => 'Individual',
1407 'table_name' => 'civicrm_contact',
1408 'entity' => 'Contact',
1409 'bao' => 'CRM_Contact_BAO_Contact',
1410 'localizable' => 0,
1411 'FKClassName' => 'CRM_Contact_DAO_Contact',
1412 'html' => [
1413 'type' => 'EntityRef',
1414 ],
1415 'add' => '2.1',
1416 ],
1417 'contact_is_deleted' => [
1418 'name' => 'is_deleted',
1419 'type' => CRM_Utils_Type::T_BOOLEAN,
1420 'title' => ts('Contact is in Trash'),
1421 'required' => TRUE,
1422 'where' => 'civicrm_contact.is_deleted',
1423 'export' => TRUE,
1424 'permission' => [
1425 'access deleted contacts',
1426 ],
1427 'default' => '0',
1428 'table_name' => 'civicrm_contact',
1429 'entity' => 'Contact',
1430 'bao' => 'CRM_Contact_BAO_Contact',
1431 'localizable' => 0,
1432 'html' => [
1433 'type' => 'CheckBox',
1434 ],
1435 'add' => '3.2',
1436 ],
1437 'created_date' => [
1438 'name' => 'created_date',
1439 'type' => CRM_Utils_Type::T_TIMESTAMP,
1440 'title' => ts('Created Date'),
1441 'description' => ts('When was the contact was created.'),
1442 'required' => FALSE,
1443 'where' => 'civicrm_contact.created_date',
1444 'export' => TRUE,
1445 'default' => 'NULL',
1446 'table_name' => 'civicrm_contact',
1447 'entity' => 'Contact',
1448 'bao' => 'CRM_Contact_BAO_Contact',
1449 'localizable' => 0,
1450 'add' => '4.3',
1451 ],
1452 'modified_date' => [
1453 'name' => 'modified_date',
1454 'type' => CRM_Utils_Type::T_TIMESTAMP,
1455 'title' => ts('Modified Date'),
1456 'description' => ts('When was the contact (or closely related entity) was created or modified or deleted.'),
1457 'required' => FALSE,
1458 'where' => 'civicrm_contact.modified_date',
1459 'export' => TRUE,
1460 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
1461 'table_name' => 'civicrm_contact',
1462 'entity' => 'Contact',
1463 'bao' => 'CRM_Contact_BAO_Contact',
1464 'localizable' => 0,
1465 'add' => '4.3',
1466 ],
1467 ];
1468 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
1469 }
1470 return Civi::$statics[__CLASS__]['fields'];
1471 }
1472
1473 /**
1474 * Return a mapping from field-name to the corresponding key (as used in fields()).
1475 *
1476 * @return array
1477 * Array(string $name => string $uniqueName).
1478 */
1479 public static function &fieldKeys() {
1480 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
1481 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
1482 }
1483 return Civi::$statics[__CLASS__]['fieldKeys'];
1484 }
1485
1486 /**
1487 * Returns the names of this table
1488 *
1489 * @return string
1490 */
1491 public static function getTableName() {
1492 return self::$_tableName;
1493 }
1494
1495 /**
1496 * Returns if this table needs to be logged
1497 *
1498 * @return bool
1499 */
1500 public function getLog() {
1501 return self::$_log;
1502 }
1503
1504 /**
1505 * Returns the list of fields that can be imported
1506 *
1507 * @param bool $prefix
1508 *
1509 * @return array
1510 */
1511 public static function &import($prefix = FALSE) {
1512 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contact', $prefix, []);
1513 return $r;
1514 }
1515
1516 /**
1517 * Returns the list of fields that can be exported
1518 *
1519 * @param bool $prefix
1520 *
1521 * @return array
1522 */
1523 public static function &export($prefix = FALSE) {
1524 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contact', $prefix, []);
1525 return $r;
1526 }
1527
1528 /**
1529 * Returns the list of indices
1530 *
1531 * @param bool $localize
1532 *
1533 * @return array
1534 */
1535 public static function indices($localize = TRUE) {
1536 $indices = [
1537 'index_contact_type' => [
1538 'name' => 'index_contact_type',
1539 'field' => [
1540 0 => 'contact_type',
1541 ],
1542 'localizable' => FALSE,
1543 'sig' => 'civicrm_contact::0::contact_type',
1544 ],
1545 'index_contact_sub_type' => [
1546 'name' => 'index_contact_sub_type',
1547 'field' => [
1548 0 => 'contact_sub_type',
1549 ],
1550 'localizable' => FALSE,
1551 'sig' => 'civicrm_contact::0::contact_sub_type',
1552 ],
1553 'UI_external_identifier' => [
1554 'name' => 'UI_external_identifier',
1555 'field' => [
1556 0 => 'external_identifier',
1557 ],
1558 'localizable' => FALSE,
1559 'unique' => TRUE,
1560 'sig' => 'civicrm_contact::1::external_identifier',
1561 ],
1562 'index_sort_name' => [
1563 'name' => 'index_sort_name',
1564 'field' => [
1565 0 => 'sort_name',
1566 ],
1567 'localizable' => FALSE,
1568 'sig' => 'civicrm_contact::0::sort_name',
1569 ],
1570 'index_preferred_communication_method' => [
1571 'name' => 'index_preferred_communication_method',
1572 'field' => [
1573 0 => 'preferred_communication_method',
1574 ],
1575 'localizable' => FALSE,
1576 'sig' => 'civicrm_contact::0::preferred_communication_method',
1577 ],
1578 'index_hash' => [
1579 'name' => 'index_hash',
1580 'field' => [
1581 0 => 'hash',
1582 ],
1583 'localizable' => FALSE,
1584 'sig' => 'civicrm_contact::0::hash',
1585 ],
1586 'index_api_key' => [
1587 'name' => 'index_api_key',
1588 'field' => [
1589 0 => 'api_key',
1590 ],
1591 'localizable' => FALSE,
1592 'sig' => 'civicrm_contact::0::api_key',
1593 ],
1594 'index_first_name' => [
1595 'name' => 'index_first_name',
1596 'field' => [
1597 0 => 'first_name',
1598 ],
1599 'localizable' => FALSE,
1600 'sig' => 'civicrm_contact::0::first_name',
1601 ],
1602 'index_last_name' => [
1603 'name' => 'index_last_name',
1604 'field' => [
1605 0 => 'last_name',
1606 ],
1607 'localizable' => FALSE,
1608 'sig' => 'civicrm_contact::0::last_name',
1609 ],
1610 'UI_prefix' => [
1611 'name' => 'UI_prefix',
1612 'field' => [
1613 0 => 'prefix_id',
1614 ],
1615 'localizable' => FALSE,
1616 'sig' => 'civicrm_contact::0::prefix_id',
1617 ],
1618 'UI_suffix' => [
1619 'name' => 'UI_suffix',
1620 'field' => [
1621 0 => 'suffix_id',
1622 ],
1623 'localizable' => FALSE,
1624 'sig' => 'civicrm_contact::0::suffix_id',
1625 ],
1626 'index_communication_style_id' => [
1627 'name' => 'index_communication_style_id',
1628 'field' => [
1629 0 => 'communication_style_id',
1630 ],
1631 'localizable' => FALSE,
1632 'sig' => 'civicrm_contact::0::communication_style_id',
1633 ],
1634 'UI_gender' => [
1635 'name' => 'UI_gender',
1636 'field' => [
1637 0 => 'gender_id',
1638 ],
1639 'localizable' => FALSE,
1640 'sig' => 'civicrm_contact::0::gender_id',
1641 ],
1642 'index_is_deceased' => [
1643 'name' => 'index_is_deceased',
1644 'field' => [
1645 0 => 'is_deceased',
1646 ],
1647 'localizable' => FALSE,
1648 'sig' => 'civicrm_contact::0::is_deceased',
1649 ],
1650 'index_household_name' => [
1651 'name' => 'index_household_name',
1652 'field' => [
1653 0 => 'household_name',
1654 ],
1655 'localizable' => FALSE,
1656 'sig' => 'civicrm_contact::0::household_name',
1657 ],
1658 'index_organization_name' => [
1659 'name' => 'index_organization_name',
1660 'field' => [
1661 0 => 'organization_name',
1662 ],
1663 'localizable' => FALSE,
1664 'sig' => 'civicrm_contact::0::organization_name',
1665 ],
1666 'index_is_deleted_sort_name' => [
1667 'name' => 'index_is_deleted_sort_name',
1668 'field' => [
1669 0 => 'is_deleted',
1670 1 => 'sort_name',
1671 2 => 'id',
1672 ],
1673 'localizable' => FALSE,
1674 'sig' => 'civicrm_contact::0::is_deleted::sort_name::id',
1675 ],
1676 'index_created_date' => [
1677 'name' => 'index_created_date',
1678 'field' => [
1679 0 => 'created_date',
1680 ],
1681 'localizable' => FALSE,
1682 'sig' => 'civicrm_contact::0::created_date',
1683 ],
1684 'index_modified_date' => [
1685 'name' => 'index_modified_date',
1686 'field' => [
1687 0 => 'modified_date',
1688 ],
1689 'localizable' => FALSE,
1690 'sig' => 'civicrm_contact::0::modified_date',
1691 ],
1692 ];
1693 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
1694 }
1695
1696 }