Merge pull request #15321 from yashodha/dev_1065
[civicrm-core.git] / CRM / Core / DAO / Address.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2019
6 *
7 * Generated from xml/schema/CRM/Core/Address.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:4e3b66ed828527539c525b2ffc71e606)
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 public 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 public static $_log = TRUE;
30
31 /**
32 * Unique Address ID
33 *
34 * @var int
35 */
36 public $id;
37
38 /**
39 * FK to Contact ID
40 *
41 * @var int
42 */
43 public $contact_id;
44
45 /**
46 * Which Location does this address belong to.
47 *
48 * @var int
49 */
50 public $location_type_id;
51
52 /**
53 * Is this the primary address.
54 *
55 * @var bool
56 */
57 public $is_primary;
58
59 /**
60 * Is this the billing address.
61 *
62 * @var bool
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
156 */
157 public $county_id;
158
159 /**
160 * Which State_Province does this address belong to.
161 *
162 * @var int
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
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 bool
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
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' => ts('Unique Address ID'),
274 'required' => TRUE,
275 'where' => 'civicrm_address.id',
276 'table_name' => 'civicrm_address',
277 'entity' => 'Address',
278 'bao' => 'CRM_Core_BAO_Address',
279 'localizable' => 0,
280 ],
281 'contact_id' => [
282 'name' => 'contact_id',
283 'type' => CRM_Utils_Type::T_INT,
284 'title' => ts('Contact ID'),
285 'description' => ts('FK to Contact ID'),
286 'where' => 'civicrm_address.contact_id',
287 'table_name' => 'civicrm_address',
288 'entity' => 'Address',
289 'bao' => 'CRM_Core_BAO_Address',
290 'localizable' => 0,
291 'FKClassName' => 'CRM_Contact_DAO_Contact',
292 ],
293 'location_type_id' => [
294 'name' => 'location_type_id',
295 'type' => CRM_Utils_Type::T_INT,
296 'title' => ts('Address Location Type'),
297 'description' => ts('Which Location does this address belong to.'),
298 'where' => 'civicrm_address.location_type_id',
299 'table_name' => 'civicrm_address',
300 'entity' => 'Address',
301 'bao' => 'CRM_Core_BAO_Address',
302 'localizable' => 0,
303 'html' => [
304 'type' => 'Select',
305 ],
306 'pseudoconstant' => [
307 'table' => 'civicrm_location_type',
308 'keyColumn' => 'id',
309 'labelColumn' => 'display_name',
310 ],
311 ],
312 'is_primary' => [
313 'name' => 'is_primary',
314 'type' => CRM_Utils_Type::T_BOOLEAN,
315 'title' => ts('Is Address Primary?'),
316 'description' => ts('Is this the primary address.'),
317 'where' => 'civicrm_address.is_primary',
318 'default' => '0',
319 'table_name' => 'civicrm_address',
320 'entity' => 'Address',
321 'bao' => 'CRM_Core_BAO_Address',
322 'localizable' => 0,
323 'html' => [
324 'type' => 'CheckBox',
325 ],
326 ],
327 'is_billing' => [
328 'name' => 'is_billing',
329 'type' => CRM_Utils_Type::T_BOOLEAN,
330 'title' => ts('Is Billing Address'),
331 'description' => ts('Is this the billing address.'),
332 'where' => 'civicrm_address.is_billing',
333 'default' => '0',
334 'table_name' => 'civicrm_address',
335 'entity' => 'Address',
336 'bao' => 'CRM_Core_BAO_Address',
337 'localizable' => 0,
338 'html' => [
339 'type' => 'CheckBox',
340 ],
341 ],
342 'street_address' => [
343 'name' => 'street_address',
344 'type' => CRM_Utils_Type::T_STRING,
345 'title' => ts('Street Address'),
346 'description' => ts('Concatenation of all routable street address components (prefix, street number, street name, suffix, unit
347 number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail
348 delivery, etc.).'),
349 'maxlength' => 96,
350 'size' => CRM_Utils_Type::HUGE,
351 'import' => TRUE,
352 'where' => 'civicrm_address.street_address',
353 'headerPattern' => '/(street|address)/i',
354 'dataPattern' => '/^(\d{1,5}( [0-9A-Za-z]+)+)$|^(P\.?O\.\? Box \d{1,5})$/i',
355 'export' => TRUE,
356 'table_name' => 'civicrm_address',
357 'entity' => 'Address',
358 'bao' => 'CRM_Core_BAO_Address',
359 'localizable' => 0,
360 'html' => [
361 'type' => 'Text',
362 ],
363 ],
364 'street_number' => [
365 'name' => 'street_number',
366 'type' => CRM_Utils_Type::T_INT,
367 'title' => ts('Street Number'),
368 'description' => ts('Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.'),
369 'where' => 'civicrm_address.street_number',
370 'export' => TRUE,
371 'table_name' => 'civicrm_address',
372 'entity' => 'Address',
373 'bao' => 'CRM_Core_BAO_Address',
374 'localizable' => 0,
375 'html' => [
376 'type' => 'Text',
377 ],
378 ],
379 'street_number_suffix' => [
380 'name' => 'street_number_suffix',
381 'type' => CRM_Utils_Type::T_STRING,
382 'title' => ts('Street Number Suffix'),
383 'description' => ts('Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A'),
384 'maxlength' => 8,
385 'size' => CRM_Utils_Type::EIGHT,
386 'where' => 'civicrm_address.street_number_suffix',
387 'export' => TRUE,
388 'table_name' => 'civicrm_address',
389 'entity' => 'Address',
390 'bao' => 'CRM_Core_BAO_Address',
391 'localizable' => 0,
392 'html' => [
393 'type' => 'Text',
394 ],
395 ],
396 'street_number_predirectional' => [
397 'name' => 'street_number_predirectional',
398 'type' => CRM_Utils_Type::T_STRING,
399 'title' => ts('Street Direction Prefix'),
400 'description' => ts('Directional prefix, e.g. SE Main St, SE is the prefix.'),
401 'maxlength' => 8,
402 'size' => CRM_Utils_Type::EIGHT,
403 'where' => 'civicrm_address.street_number_predirectional',
404 'table_name' => 'civicrm_address',
405 'entity' => 'Address',
406 'bao' => 'CRM_Core_BAO_Address',
407 'localizable' => 0,
408 'html' => [
409 'type' => 'Text',
410 ],
411 ],
412 'street_name' => [
413 'name' => 'street_name',
414 'type' => CRM_Utils_Type::T_STRING,
415 'title' => ts('Street Name'),
416 'description' => ts('Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.'),
417 'maxlength' => 64,
418 'size' => CRM_Utils_Type::BIG,
419 'where' => 'civicrm_address.street_name',
420 'export' => TRUE,
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' => ts('St, Rd, Dr, etc.'),
434 'maxlength' => 8,
435 'size' => CRM_Utils_Type::EIGHT,
436 'where' => 'civicrm_address.street_type',
437 'table_name' => 'civicrm_address',
438 'entity' => 'Address',
439 'bao' => 'CRM_Core_BAO_Address',
440 'localizable' => 0,
441 'html' => [
442 'type' => 'Text',
443 ],
444 ],
445 'street_number_postdirectional' => [
446 'name' => 'street_number_postdirectional',
447 'type' => CRM_Utils_Type::T_STRING,
448 'title' => ts('Street Direction Suffix'),
449 'description' => ts('Directional prefix, e.g. Main St S, S is the suffix.'),
450 'maxlength' => 8,
451 'size' => CRM_Utils_Type::EIGHT,
452 'where' => 'civicrm_address.street_number_postdirectional',
453 'table_name' => 'civicrm_address',
454 'entity' => 'Address',
455 'bao' => 'CRM_Core_BAO_Address',
456 'localizable' => 0,
457 'html' => [
458 'type' => 'Text',
459 ],
460 ],
461 'street_unit' => [
462 'name' => 'street_unit',
463 'type' => CRM_Utils_Type::T_STRING,
464 'title' => ts('Street Unit'),
465 'description' => ts('Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200'),
466 'maxlength' => 16,
467 'size' => CRM_Utils_Type::TWELVE,
468 'where' => 'civicrm_address.street_unit',
469 'export' => TRUE,
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' => ts('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' => ts('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' => ts('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' => ts('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' => ts('Which County does this address belong to.'),
563 'where' => 'civicrm_address.county_id',
564 'table_name' => 'civicrm_address',
565 'entity' => 'Address',
566 'bao' => 'CRM_Core_BAO_Address',
567 'localizable' => 0,
568 'FKClassName' => 'CRM_Core_DAO_County',
569 'html' => [
570 'type' => 'ChainSelect',
571 ],
572 'pseudoconstant' => [
573 'table' => 'civicrm_county',
574 'keyColumn' => 'id',
575 'labelColumn' => 'name',
576 ],
577 ],
578 'state_province_id' => [
579 'name' => 'state_province_id',
580 'type' => CRM_Utils_Type::T_INT,
581 'title' => ts('State/Province'),
582 'description' => ts('Which State_Province does this address belong to.'),
583 'where' => 'civicrm_address.state_province_id',
584 'table_name' => 'civicrm_address',
585 'entity' => 'Address',
586 'bao' => 'CRM_Core_BAO_Address',
587 'localizable' => 0,
588 'localize_context' => 'province',
589 'FKClassName' => 'CRM_Core_DAO_StateProvince',
590 'html' => [
591 'type' => 'ChainSelect',
592 ],
593 'pseudoconstant' => [
594 'table' => 'civicrm_state_province',
595 'keyColumn' => 'id',
596 'labelColumn' => 'name',
597 ],
598 ],
599 'postal_code_suffix' => [
600 'name' => 'postal_code_suffix',
601 'type' => CRM_Utils_Type::T_STRING,
602 'title' => ts('Postal Code Suffix'),
603 'description' => ts('Store the suffix, like the +4 part in the USPS system.'),
604 'maxlength' => 12,
605 'size' => 3,
606 'import' => TRUE,
607 'where' => 'civicrm_address.postal_code_suffix',
608 'headerPattern' => '/p(ostal)\sc(ode)\ss(uffix)/i',
609 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
610 'export' => TRUE,
611 'table_name' => 'civicrm_address',
612 'entity' => 'Address',
613 'bao' => 'CRM_Core_BAO_Address',
614 'localizable' => 0,
615 'html' => [
616 'type' => 'Text',
617 ],
618 ],
619 'postal_code' => [
620 'name' => 'postal_code',
621 'type' => CRM_Utils_Type::T_STRING,
622 'title' => ts('Postal Code'),
623 'description' => ts('Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.'),
624 'maxlength' => 64,
625 'size' => 6,
626 'import' => TRUE,
627 'where' => 'civicrm_address.postal_code',
628 'headerPattern' => '/postal|zip/i',
629 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
630 'export' => TRUE,
631 'table_name' => 'civicrm_address',
632 'entity' => 'Address',
633 'bao' => 'CRM_Core_BAO_Address',
634 'localizable' => 0,
635 'html' => [
636 'type' => 'Text',
637 ],
638 ],
639 'usps_adc' => [
640 'name' => 'usps_adc',
641 'type' => CRM_Utils_Type::T_STRING,
642 'title' => ts('USPS Code'),
643 'description' => ts('USPS Bulk mailing code.'),
644 'maxlength' => 32,
645 'size' => CRM_Utils_Type::MEDIUM,
646 'where' => 'civicrm_address.usps_adc',
647 'table_name' => 'civicrm_address',
648 'entity' => 'Address',
649 'bao' => 'CRM_Core_BAO_Address',
650 'localizable' => 0,
651 ],
652 'country_id' => [
653 'name' => 'country_id',
654 'type' => CRM_Utils_Type::T_INT,
655 'title' => ts('Country'),
656 'description' => ts('Which Country does this address belong to.'),
657 'where' => 'civicrm_address.country_id',
658 'table_name' => 'civicrm_address',
659 'entity' => 'Address',
660 'bao' => 'CRM_Core_BAO_Address',
661 'localizable' => 0,
662 'localize_context' => 'country',
663 'FKClassName' => 'CRM_Core_DAO_Country',
664 'html' => [
665 'type' => 'Select',
666 ],
667 'pseudoconstant' => [
668 'table' => 'civicrm_country',
669 'keyColumn' => 'id',
670 'labelColumn' => 'name',
671 'nameColumn' => 'iso_code',
672 'abbrColumn' => 'iso_code',
673 ],
674 ],
675 'geo_code_1' => [
676 'name' => 'geo_code_1',
677 'type' => CRM_Utils_Type::T_FLOAT,
678 'title' => ts('Latitude'),
679 'description' => ts('Latitude'),
680 'import' => TRUE,
681 'where' => 'civicrm_address.geo_code_1',
682 'headerPattern' => '/geo/i',
683 'export' => TRUE,
684 'table_name' => 'civicrm_address',
685 'entity' => 'Address',
686 'bao' => 'CRM_Core_BAO_Address',
687 'localizable' => 0,
688 'html' => [
689 'type' => 'Text',
690 ],
691 ],
692 'geo_code_2' => [
693 'name' => 'geo_code_2',
694 'type' => CRM_Utils_Type::T_FLOAT,
695 'title' => ts('Longitude'),
696 'description' => ts('Longitude'),
697 'import' => TRUE,
698 'where' => 'civicrm_address.geo_code_2',
699 'headerPattern' => '/geo/i',
700 'export' => TRUE,
701 'table_name' => 'civicrm_address',
702 'entity' => 'Address',
703 'bao' => 'CRM_Core_BAO_Address',
704 'localizable' => 0,
705 'html' => [
706 'type' => 'Text',
707 ],
708 ],
709 'manual_geo_code' => [
710 'name' => 'manual_geo_code',
711 'type' => CRM_Utils_Type::T_BOOLEAN,
712 'title' => ts('Is Manually Geocoded'),
713 'description' => ts('Is this a manually entered geo code'),
714 'where' => 'civicrm_address.manual_geo_code',
715 'export' => TRUE,
716 'default' => '0',
717 'table_name' => 'civicrm_address',
718 'entity' => 'Address',
719 'bao' => 'CRM_Core_BAO_Address',
720 'localizable' => 0,
721 'html' => [
722 'type' => 'CheckBox',
723 ],
724 ],
725 'timezone' => [
726 'name' => 'timezone',
727 'type' => CRM_Utils_Type::T_STRING,
728 'title' => ts('Timezone'),
729 'description' => ts('Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".'),
730 'maxlength' => 8,
731 'size' => CRM_Utils_Type::EIGHT,
732 'where' => 'civicrm_address.timezone',
733 'table_name' => 'civicrm_address',
734 'entity' => 'Address',
735 'bao' => 'CRM_Core_BAO_Address',
736 'localizable' => 0,
737 'html' => [
738 'type' => 'Text',
739 ],
740 ],
741 'address_name' => [
742 'name' => 'name',
743 'type' => CRM_Utils_Type::T_STRING,
744 'title' => ts('Address Name'),
745 'maxlength' => 255,
746 'size' => CRM_Utils_Type::HUGE,
747 'import' => TRUE,
748 'where' => 'civicrm_address.name',
749 'headerPattern' => '/^location|(l(ocation\s)?name)$/i',
750 'dataPattern' => '/^\w+$/',
751 'export' => TRUE,
752 'table_name' => 'civicrm_address',
753 'entity' => 'Address',
754 'bao' => 'CRM_Core_BAO_Address',
755 'localizable' => 0,
756 'html' => [
757 'type' => 'Text',
758 ],
759 ],
760 'master_id' => [
761 'name' => 'master_id',
762 'type' => CRM_Utils_Type::T_INT,
763 'title' => ts('Master Address Belongs To'),
764 'description' => ts('FK to Address ID'),
765 'import' => TRUE,
766 'where' => 'civicrm_address.master_id',
767 'export' => TRUE,
768 'table_name' => 'civicrm_address',
769 'entity' => 'Address',
770 'bao' => 'CRM_Core_BAO_Address',
771 'localizable' => 0,
772 'FKClassName' => 'CRM_Core_DAO_Address',
773 ],
774 ];
775 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
776 }
777 return Civi::$statics[__CLASS__]['fields'];
778 }
779
780 /**
781 * Return a mapping from field-name to the corresponding key (as used in fields()).
782 *
783 * @return array
784 * Array(string $name => string $uniqueName).
785 */
786 public static function &fieldKeys() {
787 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
788 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
789 }
790 return Civi::$statics[__CLASS__]['fieldKeys'];
791 }
792
793 /**
794 * Returns the names of this table
795 *
796 * @return string
797 */
798 public static function getTableName() {
799 return self::$_tableName;
800 }
801
802 /**
803 * Returns if this table needs to be logged
804 *
805 * @return bool
806 */
807 public function getLog() {
808 return self::$_log;
809 }
810
811 /**
812 * Returns the list of fields that can be imported
813 *
814 * @param bool $prefix
815 *
816 * @return array
817 */
818 public static function &import($prefix = FALSE) {
819 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'address', $prefix, [
820 'CRM_Core_DAO_County',
821 'CRM_Core_DAO_StateProvince',
822 'CRM_Core_DAO_Country',
823 ]);
824 return $r;
825 }
826
827 /**
828 * Returns the list of fields that can be exported
829 *
830 * @param bool $prefix
831 *
832 * @return array
833 */
834 public static function &export($prefix = FALSE) {
835 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'address', $prefix, [
836 'CRM_Core_DAO_County',
837 'CRM_Core_DAO_StateProvince',
838 'CRM_Core_DAO_Country',
839 ]);
840 return $r;
841 }
842
843 /**
844 * Returns the list of indices
845 *
846 * @param bool $localize
847 *
848 * @return array
849 */
850 public static function indices($localize = TRUE) {
851 $indices = [
852 'index_location_type' => [
853 'name' => 'index_location_type',
854 'field' => [
855 0 => 'location_type_id',
856 ],
857 'localizable' => FALSE,
858 'sig' => 'civicrm_address::0::location_type_id',
859 ],
860 'index_is_primary' => [
861 'name' => 'index_is_primary',
862 'field' => [
863 0 => 'is_primary',
864 ],
865 'localizable' => FALSE,
866 'sig' => 'civicrm_address::0::is_primary',
867 ],
868 'index_is_billing' => [
869 'name' => 'index_is_billing',
870 'field' => [
871 0 => 'is_billing',
872 ],
873 'localizable' => FALSE,
874 'sig' => 'civicrm_address::0::is_billing',
875 ],
876 'index_street_name' => [
877 'name' => 'index_street_name',
878 'field' => [
879 0 => 'street_name',
880 ],
881 'localizable' => FALSE,
882 'sig' => 'civicrm_address::0::street_name',
883 ],
884 'index_city' => [
885 'name' => 'index_city',
886 'field' => [
887 0 => 'city',
888 ],
889 'localizable' => FALSE,
890 'sig' => 'civicrm_address::0::city',
891 ],
892 'index_geo_code_1_geo_code_2' => [
893 'name' => 'index_geo_code_1_geo_code_2',
894 'field' => [
895 0 => 'geo_code_1',
896 1 => 'geo_code_2',
897 ],
898 'localizable' => FALSE,
899 'sig' => 'civicrm_address::0::geo_code_1::geo_code_2',
900 ],
901 ];
902 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
903 }
904
905 }