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