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