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