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