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