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