[REF] Extract determination of subscription status information
[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:44eb25ddfd0e9d87e213e2f80f80233d)
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 'add' => '1.1',
301 ],
302 'contact_id' => [
303 'name' => 'contact_id',
304 'type' => CRM_Utils_Type::T_INT,
305 'title' => ts('Contact ID'),
306 'description' => ts('FK to Contact ID'),
307 'where' => 'civicrm_address.contact_id',
308 'table_name' => 'civicrm_address',
309 'entity' => 'Address',
310 'bao' => 'CRM_Core_BAO_Address',
311 'localizable' => 0,
312 'FKClassName' => 'CRM_Contact_DAO_Contact',
313 'add' => '2.0',
314 ],
315 'location_type_id' => [
316 'name' => 'location_type_id',
317 'type' => CRM_Utils_Type::T_INT,
318 'title' => ts('Address Location Type'),
319 'description' => ts('Which Location does this address belong to.'),
320 'where' => 'civicrm_address.location_type_id',
321 'table_name' => 'civicrm_address',
322 'entity' => 'Address',
323 'bao' => 'CRM_Core_BAO_Address',
324 'localizable' => 0,
325 'html' => [
326 'type' => 'Select',
327 ],
328 'pseudoconstant' => [
329 'table' => 'civicrm_location_type',
330 'keyColumn' => 'id',
331 'labelColumn' => 'display_name',
332 ],
333 'add' => '2.0',
334 ],
335 'is_primary' => [
336 'name' => 'is_primary',
337 'type' => CRM_Utils_Type::T_BOOLEAN,
338 'title' => ts('Primary address'),
339 'description' => ts('Is this the primary address.'),
340 'where' => 'civicrm_address.is_primary',
341 'default' => '0',
342 'table_name' => 'civicrm_address',
343 'entity' => 'Address',
344 'bao' => 'CRM_Core_BAO_Address',
345 'localizable' => 0,
346 'html' => [
347 'type' => 'Radio',
348 ],
349 'add' => '2.0',
350 ],
351 'is_billing' => [
352 'name' => 'is_billing',
353 'type' => CRM_Utils_Type::T_BOOLEAN,
354 'title' => ts('Is Billing Address'),
355 'description' => ts('Is this the billing address.'),
356 'where' => 'civicrm_address.is_billing',
357 'default' => '0',
358 'table_name' => 'civicrm_address',
359 'entity' => 'Address',
360 'bao' => 'CRM_Core_BAO_Address',
361 'localizable' => 0,
362 'html' => [
363 'type' => 'CheckBox',
364 ],
365 'add' => '2.0',
366 ],
367 'street_address' => [
368 'name' => 'street_address',
369 'type' => CRM_Utils_Type::T_STRING,
370 'title' => ts('Street Address'),
371 'description' => ts('Concatenation of all routable street address components (prefix, street number, street name, suffix, unit
372 number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail
373 delivery, etc.).'),
374 'maxlength' => 96,
375 'size' => CRM_Utils_Type::HUGE,
376 'import' => TRUE,
377 'where' => 'civicrm_address.street_address',
378 'headerPattern' => '/(street|address)/i',
379 'dataPattern' => '/^(\d{1,5}( [0-9A-Za-z]+)+)$|^(P\.?O\.\? Box \d{1,5})$/i',
380 'export' => TRUE,
381 'table_name' => 'civicrm_address',
382 'entity' => 'Address',
383 'bao' => 'CRM_Core_BAO_Address',
384 'localizable' => 0,
385 'html' => [
386 'type' => 'Text',
387 ],
388 'add' => '1.1',
389 ],
390 'street_number' => [
391 'name' => 'street_number',
392 'type' => CRM_Utils_Type::T_INT,
393 'title' => ts('Street Number'),
394 'description' => ts('Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.'),
395 'where' => 'civicrm_address.street_number',
396 'export' => TRUE,
397 'table_name' => 'civicrm_address',
398 'entity' => 'Address',
399 'bao' => 'CRM_Core_BAO_Address',
400 'localizable' => 0,
401 'html' => [
402 'type' => 'Text',
403 ],
404 'add' => '1.1',
405 ],
406 'street_number_suffix' => [
407 'name' => 'street_number_suffix',
408 'type' => CRM_Utils_Type::T_STRING,
409 'title' => ts('Street Number Suffix'),
410 'description' => ts('Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A'),
411 'maxlength' => 8,
412 'size' => CRM_Utils_Type::EIGHT,
413 'where' => 'civicrm_address.street_number_suffix',
414 'export' => TRUE,
415 'table_name' => 'civicrm_address',
416 'entity' => 'Address',
417 'bao' => 'CRM_Core_BAO_Address',
418 'localizable' => 0,
419 'html' => [
420 'type' => 'Text',
421 ],
422 'add' => '1.1',
423 ],
424 'street_number_predirectional' => [
425 'name' => 'street_number_predirectional',
426 'type' => CRM_Utils_Type::T_STRING,
427 'title' => ts('Street Direction Prefix'),
428 'description' => ts('Directional prefix, e.g. SE Main St, SE is the prefix.'),
429 'maxlength' => 8,
430 'size' => CRM_Utils_Type::EIGHT,
431 'where' => 'civicrm_address.street_number_predirectional',
432 'table_name' => 'civicrm_address',
433 'entity' => 'Address',
434 'bao' => 'CRM_Core_BAO_Address',
435 'localizable' => 0,
436 'html' => [
437 'type' => 'Text',
438 ],
439 'add' => '1.1',
440 ],
441 'street_name' => [
442 'name' => 'street_name',
443 'type' => CRM_Utils_Type::T_STRING,
444 'title' => ts('Street Name'),
445 'description' => ts('Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.'),
446 'maxlength' => 64,
447 'size' => CRM_Utils_Type::BIG,
448 'where' => 'civicrm_address.street_name',
449 'export' => TRUE,
450 'table_name' => 'civicrm_address',
451 'entity' => 'Address',
452 'bao' => 'CRM_Core_BAO_Address',
453 'localizable' => 0,
454 'html' => [
455 'type' => 'Text',
456 ],
457 'add' => '1.1',
458 ],
459 'street_type' => [
460 'name' => 'street_type',
461 'type' => CRM_Utils_Type::T_STRING,
462 'title' => ts('Street Type'),
463 'description' => ts('St, Rd, Dr, etc.'),
464 'maxlength' => 8,
465 'size' => CRM_Utils_Type::EIGHT,
466 'where' => 'civicrm_address.street_type',
467 'table_name' => 'civicrm_address',
468 'entity' => 'Address',
469 'bao' => 'CRM_Core_BAO_Address',
470 'localizable' => 0,
471 'html' => [
472 'type' => 'Text',
473 ],
474 'add' => '1.1',
475 ],
476 'street_number_postdirectional' => [
477 'name' => 'street_number_postdirectional',
478 'type' => CRM_Utils_Type::T_STRING,
479 'title' => ts('Street Direction Suffix'),
480 'description' => ts('Directional prefix, e.g. Main St S, S is the suffix.'),
481 'maxlength' => 8,
482 'size' => CRM_Utils_Type::EIGHT,
483 'where' => 'civicrm_address.street_number_postdirectional',
484 'table_name' => 'civicrm_address',
485 'entity' => 'Address',
486 'bao' => 'CRM_Core_BAO_Address',
487 'localizable' => 0,
488 'html' => [
489 'type' => 'Text',
490 ],
491 'add' => '1.1',
492 ],
493 'street_unit' => [
494 'name' => 'street_unit',
495 'type' => CRM_Utils_Type::T_STRING,
496 'title' => ts('Street Unit'),
497 'description' => ts('Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200'),
498 'maxlength' => 16,
499 'size' => CRM_Utils_Type::TWELVE,
500 'where' => 'civicrm_address.street_unit',
501 'export' => TRUE,
502 'table_name' => 'civicrm_address',
503 'entity' => 'Address',
504 'bao' => 'CRM_Core_BAO_Address',
505 'localizable' => 0,
506 'html' => [
507 'type' => 'Text',
508 ],
509 'add' => '1.1',
510 ],
511 'supplemental_address_1' => [
512 'name' => 'supplemental_address_1',
513 'type' => CRM_Utils_Type::T_STRING,
514 'title' => ts('Supplemental Address 1'),
515 'description' => ts('Supplemental Address Information, Line 1'),
516 'maxlength' => 96,
517 'size' => CRM_Utils_Type::HUGE,
518 'import' => TRUE,
519 'where' => 'civicrm_address.supplemental_address_1',
520 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
521 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
522 'export' => TRUE,
523 'table_name' => 'civicrm_address',
524 'entity' => 'Address',
525 'bao' => 'CRM_Core_BAO_Address',
526 'localizable' => 0,
527 'html' => [
528 'type' => 'Text',
529 ],
530 'add' => '1.1',
531 ],
532 'supplemental_address_2' => [
533 'name' => 'supplemental_address_2',
534 'type' => CRM_Utils_Type::T_STRING,
535 'title' => ts('Supplemental Address 2'),
536 'description' => ts('Supplemental Address Information, Line 2'),
537 'maxlength' => 96,
538 'size' => CRM_Utils_Type::HUGE,
539 'import' => TRUE,
540 'where' => 'civicrm_address.supplemental_address_2',
541 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
542 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
543 'export' => TRUE,
544 'table_name' => 'civicrm_address',
545 'entity' => 'Address',
546 'bao' => 'CRM_Core_BAO_Address',
547 'localizable' => 0,
548 'html' => [
549 'type' => 'Text',
550 ],
551 'add' => '1.1',
552 ],
553 'supplemental_address_3' => [
554 'name' => 'supplemental_address_3',
555 'type' => CRM_Utils_Type::T_STRING,
556 'title' => ts('Supplemental Address 3'),
557 'description' => ts('Supplemental Address Information, Line 3'),
558 'maxlength' => 96,
559 'size' => CRM_Utils_Type::HUGE,
560 'import' => TRUE,
561 'where' => 'civicrm_address.supplemental_address_3',
562 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
563 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
564 'export' => TRUE,
565 'table_name' => 'civicrm_address',
566 'entity' => 'Address',
567 'bao' => 'CRM_Core_BAO_Address',
568 'localizable' => 0,
569 'html' => [
570 'type' => 'Text',
571 ],
572 'add' => '1.1',
573 ],
574 'city' => [
575 'name' => 'city',
576 'type' => CRM_Utils_Type::T_STRING,
577 'title' => ts('City'),
578 'description' => ts('City, Town or Village Name.'),
579 'maxlength' => 64,
580 'size' => CRM_Utils_Type::BIG,
581 'import' => TRUE,
582 'where' => 'civicrm_address.city',
583 'headerPattern' => '/city/i',
584 'dataPattern' => '/^[A-Za-z]+(\.?)(\s?[A-Za-z]+){0,2}$/',
585 'export' => TRUE,
586 'table_name' => 'civicrm_address',
587 'entity' => 'Address',
588 'bao' => 'CRM_Core_BAO_Address',
589 'localizable' => 0,
590 'html' => [
591 'type' => 'Text',
592 ],
593 'add' => '1.1',
594 ],
595 'county_id' => [
596 'name' => 'county_id',
597 'type' => CRM_Utils_Type::T_INT,
598 'title' => ts('County'),
599 'description' => ts('Which County does this address belong to.'),
600 'where' => 'civicrm_address.county_id',
601 'table_name' => 'civicrm_address',
602 'entity' => 'Address',
603 'bao' => 'CRM_Core_BAO_Address',
604 'localizable' => 0,
605 'FKClassName' => 'CRM_Core_DAO_County',
606 'html' => [
607 'type' => 'ChainSelect',
608 'controlField' => 'state_province_id',
609 ],
610 'pseudoconstant' => [
611 'table' => 'civicrm_county',
612 'keyColumn' => 'id',
613 'labelColumn' => 'name',
614 ],
615 'add' => '1.1',
616 ],
617 'state_province_id' => [
618 'name' => 'state_province_id',
619 'type' => CRM_Utils_Type::T_INT,
620 'title' => ts('State/Province'),
621 'description' => ts('Which State_Province does this address belong to.'),
622 'where' => 'civicrm_address.state_province_id',
623 'table_name' => 'civicrm_address',
624 'entity' => 'Address',
625 'bao' => 'CRM_Core_BAO_Address',
626 'localizable' => 0,
627 'localize_context' => 'province',
628 'FKClassName' => 'CRM_Core_DAO_StateProvince',
629 'html' => [
630 'type' => 'ChainSelect',
631 'controlField' => 'country_id',
632 ],
633 'pseudoconstant' => [
634 'table' => 'civicrm_state_province',
635 'keyColumn' => 'id',
636 'labelColumn' => 'name',
637 ],
638 'add' => '1.1',
639 ],
640 'postal_code_suffix' => [
641 'name' => 'postal_code_suffix',
642 'type' => CRM_Utils_Type::T_STRING,
643 'title' => ts('Postal Code Suffix'),
644 'description' => ts('Store the suffix, like the +4 part in the USPS system.'),
645 'maxlength' => 12,
646 'size' => 3,
647 'import' => TRUE,
648 'where' => 'civicrm_address.postal_code_suffix',
649 'headerPattern' => '/p(ostal)\sc(ode)\ss(uffix)/i',
650 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
651 'export' => TRUE,
652 'table_name' => 'civicrm_address',
653 'entity' => 'Address',
654 'bao' => 'CRM_Core_BAO_Address',
655 'localizable' => 0,
656 'html' => [
657 'type' => 'Text',
658 ],
659 'add' => '1.1',
660 ],
661 'postal_code' => [
662 'name' => 'postal_code',
663 'type' => CRM_Utils_Type::T_STRING,
664 'title' => ts('Postal Code'),
665 'description' => ts('Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.'),
666 'maxlength' => 64,
667 'size' => 6,
668 'import' => TRUE,
669 'where' => 'civicrm_address.postal_code',
670 'headerPattern' => '/postal|zip/i',
671 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
672 'export' => TRUE,
673 'table_name' => 'civicrm_address',
674 'entity' => 'Address',
675 'bao' => 'CRM_Core_BAO_Address',
676 'localizable' => 0,
677 'html' => [
678 'type' => 'Text',
679 ],
680 'add' => '1.1',
681 ],
682 'usps_adc' => [
683 'name' => 'usps_adc',
684 'type' => CRM_Utils_Type::T_STRING,
685 'title' => ts('USPS Code'),
686 'description' => ts('USPS Bulk mailing code.'),
687 'maxlength' => 32,
688 'size' => CRM_Utils_Type::MEDIUM,
689 'where' => 'civicrm_address.usps_adc',
690 'table_name' => 'civicrm_address',
691 'entity' => 'Address',
692 'bao' => 'CRM_Core_BAO_Address',
693 'localizable' => 0,
694 'add' => '1.1',
695 ],
696 'country_id' => [
697 'name' => 'country_id',
698 'type' => CRM_Utils_Type::T_INT,
699 'title' => ts('Country'),
700 'description' => ts('Which Country does this address belong to.'),
701 'where' => 'civicrm_address.country_id',
702 'table_name' => 'civicrm_address',
703 'entity' => 'Address',
704 'bao' => 'CRM_Core_BAO_Address',
705 'localizable' => 0,
706 'localize_context' => 'country',
707 'FKClassName' => 'CRM_Core_DAO_Country',
708 'html' => [
709 'type' => 'Select',
710 ],
711 'pseudoconstant' => [
712 'table' => 'civicrm_country',
713 'keyColumn' => 'id',
714 'labelColumn' => 'name',
715 'nameColumn' => 'iso_code',
716 'abbrColumn' => 'iso_code',
717 ],
718 'add' => '1.1',
719 ],
720 'geo_code_1' => [
721 'name' => 'geo_code_1',
722 'type' => CRM_Utils_Type::T_FLOAT,
723 'title' => ts('Latitude'),
724 'description' => ts('Latitude'),
725 'import' => TRUE,
726 'where' => 'civicrm_address.geo_code_1',
727 'headerPattern' => '/geo/i',
728 'export' => TRUE,
729 'table_name' => 'civicrm_address',
730 'entity' => 'Address',
731 'bao' => 'CRM_Core_BAO_Address',
732 'localizable' => 0,
733 'html' => [
734 'type' => 'Text',
735 ],
736 'add' => '1.1',
737 ],
738 'geo_code_2' => [
739 'name' => 'geo_code_2',
740 'type' => CRM_Utils_Type::T_FLOAT,
741 'title' => ts('Longitude'),
742 'description' => ts('Longitude'),
743 'import' => TRUE,
744 'where' => 'civicrm_address.geo_code_2',
745 'headerPattern' => '/geo/i',
746 'export' => TRUE,
747 'table_name' => 'civicrm_address',
748 'entity' => 'Address',
749 'bao' => 'CRM_Core_BAO_Address',
750 'localizable' => 0,
751 'html' => [
752 'type' => 'Text',
753 ],
754 'add' => '1.1',
755 ],
756 'manual_geo_code' => [
757 'name' => 'manual_geo_code',
758 'type' => CRM_Utils_Type::T_BOOLEAN,
759 'title' => ts('Is Manually Geocoded'),
760 'description' => ts('Is this a manually entered geo code'),
761 'where' => 'civicrm_address.manual_geo_code',
762 'export' => TRUE,
763 'default' => '0',
764 'table_name' => 'civicrm_address',
765 'entity' => 'Address',
766 'bao' => 'CRM_Core_BAO_Address',
767 'localizable' => 0,
768 'html' => [
769 'type' => 'CheckBox',
770 ],
771 'add' => '4.3',
772 ],
773 'timezone' => [
774 'name' => 'timezone',
775 'type' => CRM_Utils_Type::T_STRING,
776 'title' => ts('Timezone'),
777 'description' => ts('Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".'),
778 'maxlength' => 8,
779 'size' => CRM_Utils_Type::EIGHT,
780 'where' => 'civicrm_address.timezone',
781 'table_name' => 'civicrm_address',
782 'entity' => 'Address',
783 'bao' => 'CRM_Core_BAO_Address',
784 'localizable' => 0,
785 'html' => [
786 'type' => 'Text',
787 ],
788 'add' => '1.1',
789 ],
790 'address_name' => [
791 'name' => 'name',
792 'type' => CRM_Utils_Type::T_STRING,
793 'title' => ts('Address Name'),
794 'maxlength' => 255,
795 'size' => CRM_Utils_Type::HUGE,
796 'import' => TRUE,
797 'where' => 'civicrm_address.name',
798 'headerPattern' => '/^location|(l(ocation\s)?name)$/i',
799 'dataPattern' => '/^\w+$/',
800 'export' => TRUE,
801 'table_name' => 'civicrm_address',
802 'entity' => 'Address',
803 'bao' => 'CRM_Core_BAO_Address',
804 'localizable' => 0,
805 'html' => [
806 'type' => 'Text',
807 ],
808 'add' => '2.1',
809 ],
810 'master_id' => [
811 'name' => 'master_id',
812 'type' => CRM_Utils_Type::T_INT,
813 'title' => ts('Master Address Belongs To'),
814 'description' => ts('FK to Address ID'),
815 'import' => TRUE,
816 'where' => 'civicrm_address.master_id',
817 'export' => TRUE,
818 'table_name' => 'civicrm_address',
819 'entity' => 'Address',
820 'bao' => 'CRM_Core_BAO_Address',
821 'localizable' => 0,
822 'FKClassName' => 'CRM_Core_DAO_Address',
823 'add' => '3.3',
824 ],
825 ];
826 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
827 }
828 return Civi::$statics[__CLASS__]['fields'];
829 }
830
831 /**
832 * Return a mapping from field-name to the corresponding key (as used in fields()).
833 *
834 * @return array
835 * Array(string $name => string $uniqueName).
836 */
837 public static function &fieldKeys() {
838 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
839 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
840 }
841 return Civi::$statics[__CLASS__]['fieldKeys'];
842 }
843
844 /**
845 * Returns the names of this table
846 *
847 * @return string
848 */
849 public static function getTableName() {
850 return self::$_tableName;
851 }
852
853 /**
854 * Returns if this table needs to be logged
855 *
856 * @return bool
857 */
858 public function getLog() {
859 return self::$_log;
860 }
861
862 /**
863 * Returns the list of fields that can be imported
864 *
865 * @param bool $prefix
866 *
867 * @return array
868 */
869 public static function &import($prefix = FALSE) {
870 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'address', $prefix, [
871 'CRM_Core_DAO_County',
872 'CRM_Core_DAO_StateProvince',
873 'CRM_Core_DAO_Country',
874 ]);
875 return $r;
876 }
877
878 /**
879 * Returns the list of fields that can be exported
880 *
881 * @param bool $prefix
882 *
883 * @return array
884 */
885 public static function &export($prefix = FALSE) {
886 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'address', $prefix, [
887 'CRM_Core_DAO_County',
888 'CRM_Core_DAO_StateProvince',
889 'CRM_Core_DAO_Country',
890 ]);
891 return $r;
892 }
893
894 /**
895 * Returns the list of indices
896 *
897 * @param bool $localize
898 *
899 * @return array
900 */
901 public static function indices($localize = TRUE) {
902 $indices = [
903 'index_location_type' => [
904 'name' => 'index_location_type',
905 'field' => [
906 0 => 'location_type_id',
907 ],
908 'localizable' => FALSE,
909 'sig' => 'civicrm_address::0::location_type_id',
910 ],
911 'index_is_primary' => [
912 'name' => 'index_is_primary',
913 'field' => [
914 0 => 'is_primary',
915 ],
916 'localizable' => FALSE,
917 'sig' => 'civicrm_address::0::is_primary',
918 ],
919 'index_is_billing' => [
920 'name' => 'index_is_billing',
921 'field' => [
922 0 => 'is_billing',
923 ],
924 'localizable' => FALSE,
925 'sig' => 'civicrm_address::0::is_billing',
926 ],
927 'index_street_name' => [
928 'name' => 'index_street_name',
929 'field' => [
930 0 => 'street_name',
931 ],
932 'localizable' => FALSE,
933 'sig' => 'civicrm_address::0::street_name',
934 ],
935 'index_city' => [
936 'name' => 'index_city',
937 'field' => [
938 0 => 'city',
939 ],
940 'localizable' => FALSE,
941 'sig' => 'civicrm_address::0::city',
942 ],
943 'index_geo_code_1_geo_code_2' => [
944 'name' => 'index_geo_code_1_geo_code_2',
945 'field' => [
946 0 => 'geo_code_1',
947 1 => 'geo_code_2',
948 ],
949 'localizable' => FALSE,
950 'sig' => 'civicrm_address::0::geo_code_1::geo_code_2',
951 ],
952 ];
953 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
954 }
955
956 }