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