Merge pull request #11791 from civicrm/4.7.31-rc
[civicrm-core.git] / CRM / Core / DAO / Address.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2018
6 *
7 * Generated from xml/schema/CRM/Core/Address.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:472057d193d1e875a14e7719a2d6a2ee)
10 */
11
12 /**
13 * Database access object for the Address entity.
14 */
15 class CRM_Core_DAO_Address extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 static $_tableName = 'civicrm_address';
23
24 /**
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
26 *
27 * @var bool
28 */
29 static $_log = TRUE;
30
31 /**
32 * Unique Address ID
33 *
34 * @var int unsigned
35 */
36 public $id;
37
38 /**
39 * FK to Contact ID
40 *
41 * @var int unsigned
42 */
43 public $contact_id;
44
45 /**
46 * Which Location does this address belong to.
47 *
48 * @var int unsigned
49 */
50 public $location_type_id;
51
52 /**
53 * Is this the primary address.
54 *
55 * @var boolean
56 */
57 public $is_primary;
58
59 /**
60 * Is this the billing address.
61 *
62 * @var boolean
63 */
64 public $is_billing;
65
66 /**
67 * Concatenation of all routable street address components (prefix, street number, street name, suffix, unit
68 number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail
69 delivery, etc.).
70 *
71 * @var string
72 */
73 public $street_address;
74
75 /**
76 * Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.
77 *
78 * @var int
79 */
80 public $street_number;
81
82 /**
83 * Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A
84 *
85 * @var string
86 */
87 public $street_number_suffix;
88
89 /**
90 * Directional prefix, e.g. SE Main St, SE is the prefix.
91 *
92 * @var string
93 */
94 public $street_number_predirectional;
95
96 /**
97 * Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.
98 *
99 * @var string
100 */
101 public $street_name;
102
103 /**
104 * St, Rd, Dr, etc.
105 *
106 * @var string
107 */
108 public $street_type;
109
110 /**
111 * Directional prefix, e.g. Main St S, S is the suffix.
112 *
113 * @var string
114 */
115 public $street_number_postdirectional;
116
117 /**
118 * Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200
119 *
120 * @var string
121 */
122 public $street_unit;
123
124 /**
125 * Supplemental Address Information, Line 1
126 *
127 * @var string
128 */
129 public $supplemental_address_1;
130
131 /**
132 * Supplemental Address Information, Line 2
133 *
134 * @var string
135 */
136 public $supplemental_address_2;
137
138 /**
139 * Supplemental Address Information, Line 3
140 *
141 * @var string
142 */
143 public $supplemental_address_3;
144
145 /**
146 * City, Town or Village Name.
147 *
148 * @var string
149 */
150 public $city;
151
152 /**
153 * Which County does this address belong to.
154 *
155 * @var int unsigned
156 */
157 public $county_id;
158
159 /**
160 * Which State_Province does this address belong to.
161 *
162 * @var int unsigned
163 */
164 public $state_province_id;
165
166 /**
167 * Store the suffix, like the +4 part in the USPS system.
168 *
169 * @var string
170 */
171 public $postal_code_suffix;
172
173 /**
174 * Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.
175 *
176 * @var string
177 */
178 public $postal_code;
179
180 /**
181 * USPS Bulk mailing code.
182 *
183 * @var string
184 */
185 public $usps_adc;
186
187 /**
188 * Which Country does this address belong to.
189 *
190 * @var int unsigned
191 */
192 public $country_id;
193
194 /**
195 * Latitude
196 *
197 * @var float
198 */
199 public $geo_code_1;
200
201 /**
202 * Longitude
203 *
204 * @var float
205 */
206 public $geo_code_2;
207
208 /**
209 * Is this a manually entered geo code
210 *
211 * @var boolean
212 */
213 public $manual_geo_code;
214
215 /**
216 * Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".
217 *
218 * @var string
219 */
220 public $timezone;
221
222 /**
223 * @var string
224 */
225 public $name;
226
227 /**
228 * FK to Address ID
229 *
230 * @var int unsigned
231 */
232 public $master_id;
233
234 /**
235 * Class constructor.
236 */
237 public function __construct() {
238 $this->__table = 'civicrm_address';
239 parent::__construct();
240 }
241
242 /**
243 * Returns foreign keys and entity references.
244 *
245 * @return array
246 * [CRM_Core_Reference_Interface]
247 */
248 public static function getReferenceColumns() {
249 if (!isset(Civi::$statics[__CLASS__]['links'])) {
250 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
251 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
252 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'county_id', 'civicrm_county', 'id');
253 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'state_province_id', 'civicrm_state_province', 'id');
254 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'country_id', 'civicrm_country', 'id');
255 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'master_id', 'civicrm_address', 'id');
256 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
257 }
258 return Civi::$statics[__CLASS__]['links'];
259 }
260
261 /**
262 * Returns all the column names of this table
263 *
264 * @return array
265 */
266 public static function &fields() {
267 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
268 Civi::$statics[__CLASS__]['fields'] = [
269 'id' => [
270 'name' => 'id',
271 'type' => CRM_Utils_Type::T_INT,
272 'title' => ts('Address ID'),
273 'description' => 'Unique Address ID',
274 'required' => TRUE,
275 'table_name' => 'civicrm_address',
276 'entity' => 'Address',
277 'bao' => 'CRM_Core_BAO_Address',
278 'localizable' => 0,
279 ],
280 'contact_id' => [
281 'name' => 'contact_id',
282 'type' => CRM_Utils_Type::T_INT,
283 'title' => ts('Contact ID'),
284 'description' => 'FK to Contact ID',
285 'table_name' => 'civicrm_address',
286 'entity' => 'Address',
287 'bao' => 'CRM_Core_BAO_Address',
288 'localizable' => 0,
289 'FKClassName' => 'CRM_Contact_DAO_Contact',
290 ],
291 'location_type_id' => [
292 'name' => 'location_type_id',
293 'type' => CRM_Utils_Type::T_INT,
294 'title' => ts('Address Location Type'),
295 'description' => 'Which Location does this address belong to.',
296 'table_name' => 'civicrm_address',
297 'entity' => 'Address',
298 'bao' => 'CRM_Core_BAO_Address',
299 'localizable' => 0,
300 'html' => [
301 'type' => 'Select',
302 ],
303 'pseudoconstant' => [
304 'table' => 'civicrm_location_type',
305 'keyColumn' => 'id',
306 'labelColumn' => 'display_name',
307 ]
308 ],
309 'is_primary' => [
310 'name' => 'is_primary',
311 'type' => CRM_Utils_Type::T_BOOLEAN,
312 'title' => ts('Is Address Primary?'),
313 'description' => 'Is this the primary address.',
314 'table_name' => 'civicrm_address',
315 'entity' => 'Address',
316 'bao' => 'CRM_Core_BAO_Address',
317 'localizable' => 0,
318 'html' => [
319 'type' => 'CheckBox',
320 ],
321 ],
322 'is_billing' => [
323 'name' => 'is_billing',
324 'type' => CRM_Utils_Type::T_BOOLEAN,
325 'title' => ts('Is Billing Address'),
326 'description' => 'Is this the billing address.',
327 'table_name' => 'civicrm_address',
328 'entity' => 'Address',
329 'bao' => 'CRM_Core_BAO_Address',
330 'localizable' => 0,
331 'html' => [
332 'type' => 'CheckBox',
333 ],
334 ],
335 'street_address' => [
336 'name' => 'street_address',
337 'type' => CRM_Utils_Type::T_STRING,
338 'title' => ts('Street Address'),
339 'description' => 'Concatenation of all routable street address components (prefix, street number, street name, suffix, unit
340 number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail
341 delivery, etc.).
342 ',
343 'maxlength' => 96,
344 'size' => CRM_Utils_Type::HUGE,
345 'import' => TRUE,
346 'where' => 'civicrm_address.street_address',
347 'headerPattern' => '/(street|address)/i',
348 'dataPattern' => '/^(\d{1,5}( [0-9A-Za-z]+)+)$|^(P\.?O\.\? Box \d{1,5})$/i',
349 'export' => TRUE,
350 'table_name' => 'civicrm_address',
351 'entity' => 'Address',
352 'bao' => 'CRM_Core_BAO_Address',
353 'localizable' => 0,
354 'html' => [
355 'type' => 'Text',
356 ],
357 ],
358 'street_number' => [
359 'name' => 'street_number',
360 'type' => CRM_Utils_Type::T_INT,
361 'title' => ts('Street Number'),
362 'description' => 'Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.',
363 'export' => TRUE,
364 'where' => 'civicrm_address.street_number',
365 'headerPattern' => '',
366 'dataPattern' => '',
367 'table_name' => 'civicrm_address',
368 'entity' => 'Address',
369 'bao' => 'CRM_Core_BAO_Address',
370 'localizable' => 0,
371 'html' => [
372 'type' => 'Text',
373 ],
374 ],
375 'street_number_suffix' => [
376 'name' => 'street_number_suffix',
377 'type' => CRM_Utils_Type::T_STRING,
378 'title' => ts('Street Number Suffix'),
379 'description' => 'Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A
380 ',
381 'maxlength' => 8,
382 'size' => CRM_Utils_Type::EIGHT,
383 'export' => TRUE,
384 'where' => 'civicrm_address.street_number_suffix',
385 'headerPattern' => '',
386 'dataPattern' => '',
387 'table_name' => 'civicrm_address',
388 'entity' => 'Address',
389 'bao' => 'CRM_Core_BAO_Address',
390 'localizable' => 0,
391 'html' => [
392 'type' => 'Text',
393 ],
394 ],
395 'street_number_predirectional' => [
396 'name' => 'street_number_predirectional',
397 'type' => CRM_Utils_Type::T_STRING,
398 'title' => ts('Street Direction Prefix'),
399 'description' => 'Directional prefix, e.g. SE Main St, SE is the prefix.',
400 'maxlength' => 8,
401 'size' => CRM_Utils_Type::EIGHT,
402 'table_name' => 'civicrm_address',
403 'entity' => 'Address',
404 'bao' => 'CRM_Core_BAO_Address',
405 'localizable' => 0,
406 'html' => [
407 'type' => 'Text',
408 ],
409 ],
410 'street_name' => [
411 'name' => 'street_name',
412 'type' => CRM_Utils_Type::T_STRING,
413 'title' => ts('Street Name'),
414 'description' => 'Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.',
415 'maxlength' => 64,
416 'size' => CRM_Utils_Type::BIG,
417 'export' => TRUE,
418 'where' => 'civicrm_address.street_name',
419 'headerPattern' => '',
420 'dataPattern' => '',
421 'table_name' => 'civicrm_address',
422 'entity' => 'Address',
423 'bao' => 'CRM_Core_BAO_Address',
424 'localizable' => 0,
425 'html' => [
426 'type' => 'Text',
427 ],
428 ],
429 'street_type' => [
430 'name' => 'street_type',
431 'type' => CRM_Utils_Type::T_STRING,
432 'title' => ts('Street Type'),
433 'description' => 'St, Rd, Dr, etc.',
434 'maxlength' => 8,
435 'size' => CRM_Utils_Type::EIGHT,
436 'table_name' => 'civicrm_address',
437 'entity' => 'Address',
438 'bao' => 'CRM_Core_BAO_Address',
439 'localizable' => 0,
440 'html' => [
441 'type' => 'Text',
442 ],
443 ],
444 'street_number_postdirectional' => [
445 'name' => 'street_number_postdirectional',
446 'type' => CRM_Utils_Type::T_STRING,
447 'title' => ts('Street Direction Suffix'),
448 'description' => 'Directional prefix, e.g. Main St S, S is the suffix.',
449 'maxlength' => 8,
450 'size' => CRM_Utils_Type::EIGHT,
451 'table_name' => 'civicrm_address',
452 'entity' => 'Address',
453 'bao' => 'CRM_Core_BAO_Address',
454 'localizable' => 0,
455 'html' => [
456 'type' => 'Text',
457 ],
458 ],
459 'street_unit' => [
460 'name' => 'street_unit',
461 'type' => CRM_Utils_Type::T_STRING,
462 'title' => ts('Street Unit'),
463 'description' => 'Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200',
464 'maxlength' => 16,
465 'size' => CRM_Utils_Type::TWELVE,
466 'export' => TRUE,
467 'where' => 'civicrm_address.street_unit',
468 'headerPattern' => '',
469 'dataPattern' => '',
470 'table_name' => 'civicrm_address',
471 'entity' => 'Address',
472 'bao' => 'CRM_Core_BAO_Address',
473 'localizable' => 0,
474 'html' => [
475 'type' => 'Text',
476 ],
477 ],
478 'supplemental_address_1' => [
479 'name' => 'supplemental_address_1',
480 'type' => CRM_Utils_Type::T_STRING,
481 'title' => ts('Supplemental Address 1'),
482 'description' => 'Supplemental Address Information, Line 1',
483 'maxlength' => 96,
484 'size' => CRM_Utils_Type::HUGE,
485 'import' => TRUE,
486 'where' => 'civicrm_address.supplemental_address_1',
487 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
488 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
489 'export' => TRUE,
490 'table_name' => 'civicrm_address',
491 'entity' => 'Address',
492 'bao' => 'CRM_Core_BAO_Address',
493 'localizable' => 0,
494 'html' => [
495 'type' => 'Text',
496 ],
497 ],
498 'supplemental_address_2' => [
499 'name' => 'supplemental_address_2',
500 'type' => CRM_Utils_Type::T_STRING,
501 'title' => ts('Supplemental Address 2'),
502 'description' => 'Supplemental Address Information, Line 2',
503 'maxlength' => 96,
504 'size' => CRM_Utils_Type::HUGE,
505 'import' => TRUE,
506 'where' => 'civicrm_address.supplemental_address_2',
507 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
508 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
509 'export' => TRUE,
510 'table_name' => 'civicrm_address',
511 'entity' => 'Address',
512 'bao' => 'CRM_Core_BAO_Address',
513 'localizable' => 0,
514 'html' => [
515 'type' => 'Text',
516 ],
517 ],
518 'supplemental_address_3' => [
519 'name' => 'supplemental_address_3',
520 'type' => CRM_Utils_Type::T_STRING,
521 'title' => ts('Supplemental Address 3'),
522 'description' => 'Supplemental Address Information, Line 3',
523 'maxlength' => 96,
524 'size' => CRM_Utils_Type::HUGE,
525 'import' => TRUE,
526 'where' => 'civicrm_address.supplemental_address_3',
527 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
528 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
529 'export' => TRUE,
530 'table_name' => 'civicrm_address',
531 'entity' => 'Address',
532 'bao' => 'CRM_Core_BAO_Address',
533 'localizable' => 0,
534 'html' => [
535 'type' => 'Text',
536 ],
537 ],
538 'city' => [
539 'name' => 'city',
540 'type' => CRM_Utils_Type::T_STRING,
541 'title' => ts('City'),
542 'description' => 'City, Town or Village Name.',
543 'maxlength' => 64,
544 'size' => CRM_Utils_Type::BIG,
545 'import' => TRUE,
546 'where' => 'civicrm_address.city',
547 'headerPattern' => '/city/i',
548 'dataPattern' => '/^[A-Za-z]+(\.?)(\s?[A-Za-z]+){0,2}$/',
549 'export' => TRUE,
550 'table_name' => 'civicrm_address',
551 'entity' => 'Address',
552 'bao' => 'CRM_Core_BAO_Address',
553 'localizable' => 0,
554 'html' => [
555 'type' => 'Text',
556 ],
557 ],
558 'county_id' => [
559 'name' => 'county_id',
560 'type' => CRM_Utils_Type::T_INT,
561 'title' => ts('County'),
562 'description' => 'Which County does this address belong to.',
563 'table_name' => 'civicrm_address',
564 'entity' => 'Address',
565 'bao' => 'CRM_Core_BAO_Address',
566 'localizable' => 0,
567 'FKClassName' => 'CRM_Core_DAO_County',
568 'html' => [
569 'type' => 'ChainSelect',
570 ],
571 'pseudoconstant' => [
572 'table' => 'civicrm_county',
573 'keyColumn' => 'id',
574 'labelColumn' => 'name',
575 ]
576 ],
577 'state_province_id' => [
578 'name' => 'state_province_id',
579 'type' => CRM_Utils_Type::T_INT,
580 'title' => ts('State/Province'),
581 'description' => 'Which State_Province does this address belong to.',
582 'table_name' => 'civicrm_address',
583 'entity' => 'Address',
584 'bao' => 'CRM_Core_BAO_Address',
585 'localizable' => 0,
586 'FKClassName' => 'CRM_Core_DAO_StateProvince',
587 'html' => [
588 'type' => 'ChainSelect',
589 ],
590 'pseudoconstant' => [
591 'table' => 'civicrm_state_province',
592 'keyColumn' => 'id',
593 'labelColumn' => 'name',
594 ]
595 ],
596 'postal_code_suffix' => [
597 'name' => 'postal_code_suffix',
598 'type' => CRM_Utils_Type::T_STRING,
599 'title' => ts('Postal Code Suffix'),
600 'description' => 'Store the suffix, like the +4 part in the USPS system.',
601 'maxlength' => 12,
602 'size' => 3,
603 'import' => TRUE,
604 'where' => 'civicrm_address.postal_code_suffix',
605 'headerPattern' => '/p(ostal)\sc(ode)\ss(uffix)/i',
606 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
607 'export' => TRUE,
608 'table_name' => 'civicrm_address',
609 'entity' => 'Address',
610 'bao' => 'CRM_Core_BAO_Address',
611 'localizable' => 0,
612 'html' => [
613 'type' => 'Text',
614 ],
615 ],
616 'postal_code' => [
617 'name' => 'postal_code',
618 'type' => CRM_Utils_Type::T_STRING,
619 'title' => ts('Postal Code'),
620 'description' => 'Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.',
621 'maxlength' => 64,
622 'size' => 6,
623 'import' => TRUE,
624 'where' => 'civicrm_address.postal_code',
625 'headerPattern' => '/postal|zip/i',
626 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
627 'export' => TRUE,
628 'table_name' => 'civicrm_address',
629 'entity' => 'Address',
630 'bao' => 'CRM_Core_BAO_Address',
631 'localizable' => 0,
632 'html' => [
633 'type' => 'Text',
634 ],
635 ],
636 'usps_adc' => [
637 'name' => 'usps_adc',
638 'type' => CRM_Utils_Type::T_STRING,
639 'title' => ts('USPS Code'),
640 'description' => 'USPS Bulk mailing code.',
641 'maxlength' => 32,
642 'size' => CRM_Utils_Type::MEDIUM,
643 'table_name' => 'civicrm_address',
644 'entity' => 'Address',
645 'bao' => 'CRM_Core_BAO_Address',
646 'localizable' => 0,
647 ],
648 'country_id' => [
649 'name' => 'country_id',
650 'type' => CRM_Utils_Type::T_INT,
651 'title' => ts('Country'),
652 'description' => 'Which Country does this address belong to.',
653 'table_name' => 'civicrm_address',
654 'entity' => 'Address',
655 'bao' => 'CRM_Core_BAO_Address',
656 'localizable' => 0,
657 'FKClassName' => 'CRM_Core_DAO_Country',
658 'html' => [
659 'type' => 'Select',
660 ],
661 'pseudoconstant' => [
662 'table' => 'civicrm_country',
663 'keyColumn' => 'id',
664 'labelColumn' => 'name',
665 'nameColumn' => 'iso_code',
666 ]
667 ],
668 'geo_code_1' => [
669 'name' => 'geo_code_1',
670 'type' => CRM_Utils_Type::T_FLOAT,
671 'title' => ts('Latitude'),
672 'description' => 'Latitude',
673 'import' => TRUE,
674 'where' => 'civicrm_address.geo_code_1',
675 'headerPattern' => '/geo/i',
676 'dataPattern' => '',
677 'export' => TRUE,
678 'table_name' => 'civicrm_address',
679 'entity' => 'Address',
680 'bao' => 'CRM_Core_BAO_Address',
681 'localizable' => 0,
682 'html' => [
683 'type' => 'Text',
684 ],
685 ],
686 'geo_code_2' => [
687 'name' => 'geo_code_2',
688 'type' => CRM_Utils_Type::T_FLOAT,
689 'title' => ts('Longitude'),
690 'description' => 'Longitude',
691 'import' => TRUE,
692 'where' => 'civicrm_address.geo_code_2',
693 'headerPattern' => '/geo/i',
694 'dataPattern' => '',
695 'export' => TRUE,
696 'table_name' => 'civicrm_address',
697 'entity' => 'Address',
698 'bao' => 'CRM_Core_BAO_Address',
699 'localizable' => 0,
700 'html' => [
701 'type' => 'Text',
702 ],
703 ],
704 'manual_geo_code' => [
705 'name' => 'manual_geo_code',
706 'type' => CRM_Utils_Type::T_BOOLEAN,
707 'title' => ts('Is manually geocoded'),
708 'description' => 'Is this a manually entered geo code',
709 'table_name' => 'civicrm_address',
710 'entity' => 'Address',
711 'bao' => 'CRM_Core_BAO_Address',
712 'localizable' => 0,
713 'html' => [
714 'type' => 'CheckBox',
715 ],
716 ],
717 'timezone' => [
718 'name' => 'timezone',
719 'type' => CRM_Utils_Type::T_STRING,
720 'title' => ts('Timezone'),
721 'description' => 'Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".',
722 'maxlength' => 8,
723 'size' => CRM_Utils_Type::EIGHT,
724 'table_name' => 'civicrm_address',
725 'entity' => 'Address',
726 'bao' => 'CRM_Core_BAO_Address',
727 'localizable' => 0,
728 'html' => [
729 'type' => 'Text',
730 ],
731 ],
732 'address_name' => [
733 'name' => 'name',
734 'type' => CRM_Utils_Type::T_STRING,
735 'title' => ts('Address Name'),
736 'maxlength' => 255,
737 'size' => CRM_Utils_Type::HUGE,
738 'import' => TRUE,
739 'where' => 'civicrm_address.name',
740 'headerPattern' => '/^location|(l(ocation\s)?name)$/i',
741 'dataPattern' => '/^\w+$/',
742 'export' => TRUE,
743 'table_name' => 'civicrm_address',
744 'entity' => 'Address',
745 'bao' => 'CRM_Core_BAO_Address',
746 'localizable' => 0,
747 'html' => [
748 'type' => 'Text',
749 ],
750 ],
751 'master_id' => [
752 'name' => 'master_id',
753 'type' => CRM_Utils_Type::T_INT,
754 'title' => ts('Master Address Belongs To'),
755 'description' => 'FK to Address ID',
756 'import' => TRUE,
757 'where' => 'civicrm_address.master_id',
758 'headerPattern' => '',
759 'dataPattern' => '',
760 'export' => TRUE,
761 'table_name' => 'civicrm_address',
762 'entity' => 'Address',
763 'bao' => 'CRM_Core_BAO_Address',
764 'localizable' => 0,
765 'FKClassName' => 'CRM_Core_DAO_Address',
766 ],
767 ];
768 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
769 }
770 return Civi::$statics[__CLASS__]['fields'];
771 }
772
773 /**
774 * Return a mapping from field-name to the corresponding key (as used in fields()).
775 *
776 * @return array
777 * Array(string $name => string $uniqueName).
778 */
779 public static function &fieldKeys() {
780 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
781 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
782 }
783 return Civi::$statics[__CLASS__]['fieldKeys'];
784 }
785
786 /**
787 * Returns the names of this table
788 *
789 * @return string
790 */
791 public static function getTableName() {
792 return self::$_tableName;
793 }
794
795 /**
796 * Returns if this table needs to be logged
797 *
798 * @return bool
799 */
800 public function getLog() {
801 return self::$_log;
802 }
803
804 /**
805 * Returns the list of fields that can be imported
806 *
807 * @param bool $prefix
808 *
809 * @return array
810 */
811 public static function &import($prefix = FALSE) {
812 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'address', $prefix, [
813 'CRM_Core_DAO_County',
814 'CRM_Core_DAO_StateProvince',
815 'CRM_Core_DAO_Country',
816 ]);
817 return $r;
818 }
819
820 /**
821 * Returns the list of fields that can be exported
822 *
823 * @param bool $prefix
824 *
825 * @return array
826 */
827 public static function &export($prefix = FALSE) {
828 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'address', $prefix, [
829 'CRM_Core_DAO_County',
830 'CRM_Core_DAO_StateProvince',
831 'CRM_Core_DAO_Country',
832 ]);
833 return $r;
834 }
835
836 /**
837 * Returns the list of indices
838 *
839 * @param bool $localize
840 *
841 * @return array
842 */
843 public static function indices($localize = TRUE) {
844 $indices = [
845 'index_location_type' => [
846 'name' => 'index_location_type',
847 'field' => [
848 0 => 'location_type_id',
849 ],
850 'localizable' => FALSE,
851 'sig' => 'civicrm_address::0::location_type_id',
852 ],
853 'index_is_primary' => [
854 'name' => 'index_is_primary',
855 'field' => [
856 0 => 'is_primary',
857 ],
858 'localizable' => FALSE,
859 'sig' => 'civicrm_address::0::is_primary',
860 ],
861 'index_is_billing' => [
862 'name' => 'index_is_billing',
863 'field' => [
864 0 => 'is_billing',
865 ],
866 'localizable' => FALSE,
867 'sig' => 'civicrm_address::0::is_billing',
868 ],
869 'index_street_name' => [
870 'name' => 'index_street_name',
871 'field' => [
872 0 => 'street_name',
873 ],
874 'localizable' => FALSE,
875 'sig' => 'civicrm_address::0::street_name',
876 ],
877 'index_city' => [
878 'name' => 'index_city',
879 'field' => [
880 0 => 'city',
881 ],
882 'localizable' => FALSE,
883 'sig' => 'civicrm_address::0::city',
884 ],
885 ];
886 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
887 }
888
889 }