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