3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
29 * @copyright CiviCRM LLC (c) 2004-2017
31 * Generated from xml/schema/CRM/Core/Address.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:472057d193d1e875a14e7719a2d6a2ee)
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
38 * CRM_Core_DAO_Address constructor.
40 class CRM_Core_DAO_Address
extends CRM_Core_DAO
{
42 * Static instance to hold the table name.
46 static $_tableName = 'civicrm_address';
48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
66 * Which Location does this address belong to.
70 public $location_type_id;
72 * Is this the primary address.
78 * Is this the billing address.
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
90 public $street_address;
92 * Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.
96 public $street_number;
98 * Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A
102 public $street_number_suffix;
104 * Directional prefix, e.g. SE Main St, SE is the prefix.
108 public $street_number_predirectional;
110 * Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.
122 * Directional prefix, e.g. Main St S, S is the suffix.
126 public $street_number_postdirectional;
128 * Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200
134 * Supplemental Address Information, Line 1
138 public $supplemental_address_1;
140 * Supplemental Address Information, Line 2
144 public $supplemental_address_2;
146 * Supplemental Address Information, Line 3
150 public $supplemental_address_3;
152 * City, Town or Village Name.
158 * Which County does this address belong to.
164 * Which State_Province does this address belong to.
168 public $state_province_id;
170 * Store the suffix, like the +4 part in the USPS system.
174 public $postal_code_suffix;
176 * Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.
182 * USPS Bulk mailing code.
188 * Which Country does this address belong to.
206 * Is this a manually entered geo code
210 public $manual_geo_code;
212 * Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".
231 function __construct() {
232 $this->__table
= 'civicrm_address';
233 parent
::__construct();
236 * Returns foreign keys and entity references.
239 * [CRM_Core_Reference_Interface]
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']);
251 return Civi
::$statics[__CLASS__
]['links'];
254 * Returns all the column names of this table
258 static function &fields() {
259 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
260 Civi
::$statics[__CLASS__
]['fields'] = array(
263 'type' => CRM_Utils_Type
::T_INT
,
264 'title' => ts('Address ID') ,
265 'description' => 'Unique Address ID',
267 'table_name' => 'civicrm_address',
268 'entity' => 'Address',
269 'bao' => 'CRM_Core_BAO_Address',
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',
281 'FKClassName' => 'CRM_Contact_DAO_Contact',
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',
295 'pseudoconstant' => array(
296 'table' => 'civicrm_location_type',
298 'labelColumn' => 'display_name',
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',
311 'type' => 'CheckBox',
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',
324 'type' => 'CheckBox',
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
336 'size' => CRM_Utils_Type
::HUGE
,
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',
342 'table_name' => 'civicrm_address',
343 'entity' => 'Address',
344 'bao' => 'CRM_Core_BAO_Address',
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.',
356 'where' => 'civicrm_address.street_number',
357 'headerPattern' => '',
359 'table_name' => 'civicrm_address',
360 'entity' => 'Address',
361 'bao' => 'CRM_Core_BAO_Address',
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
374 'size' => CRM_Utils_Type
::EIGHT
,
376 'where' => 'civicrm_address.street_number_suffix',
377 'headerPattern' => '',
379 'table_name' => 'civicrm_address',
380 'entity' => 'Address',
381 'bao' => 'CRM_Core_BAO_Address',
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.',
393 'size' => CRM_Utils_Type
::EIGHT
,
394 'table_name' => 'civicrm_address',
395 'entity' => 'Address',
396 'bao' => 'CRM_Core_BAO_Address',
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.',
408 'size' => CRM_Utils_Type
::BIG
,
410 'where' => 'civicrm_address.street_name',
411 'headerPattern' => '',
413 'table_name' => 'civicrm_address',
414 'entity' => 'Address',
415 'bao' => 'CRM_Core_BAO_Address',
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.',
427 'size' => CRM_Utils_Type
::EIGHT
,
428 'table_name' => 'civicrm_address',
429 'entity' => 'Address',
430 'bao' => 'CRM_Core_BAO_Address',
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.',
442 'size' => CRM_Utils_Type
::EIGHT
,
443 'table_name' => 'civicrm_address',
444 'entity' => 'Address',
445 'bao' => 'CRM_Core_BAO_Address',
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',
457 'size' => CRM_Utils_Type
::TWELVE
,
459 'where' => 'civicrm_address.street_unit',
460 'headerPattern' => '',
462 'table_name' => 'civicrm_address',
463 'entity' => 'Address',
464 'bao' => 'CRM_Core_BAO_Address',
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',
476 'size' => CRM_Utils_Type
::HUGE
,
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',
482 'table_name' => 'civicrm_address',
483 'entity' => 'Address',
484 'bao' => 'CRM_Core_BAO_Address',
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',
496 'size' => CRM_Utils_Type
::HUGE
,
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',
502 'table_name' => 'civicrm_address',
503 'entity' => 'Address',
504 'bao' => 'CRM_Core_BAO_Address',
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',
516 'size' => CRM_Utils_Type
::HUGE
,
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',
522 'table_name' => 'civicrm_address',
523 'entity' => 'Address',
524 'bao' => 'CRM_Core_BAO_Address',
532 'type' => CRM_Utils_Type
::T_STRING
,
533 'title' => ts('City') ,
534 'description' => 'City, Town or Village Name.',
536 'size' => CRM_Utils_Type
::BIG
,
538 'where' => 'civicrm_address.city',
539 'headerPattern' => '/city/i',
540 'dataPattern' => '/^[A-Za-z]+(\.?)(\s?[A-Za-z]+){0,2}$/',
542 'table_name' => 'civicrm_address',
543 'entity' => 'Address',
544 'bao' => 'CRM_Core_BAO_Address',
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',
559 'FKClassName' => 'CRM_Core_DAO_County',
561 'type' => 'ChainSelect',
563 'pseudoconstant' => array(
564 'table' => 'civicrm_county',
566 'labelColumn' => 'name',
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',
578 'FKClassName' => 'CRM_Core_DAO_StateProvince',
580 'type' => 'ChainSelect',
582 'pseudoconstant' => array(
583 'table' => 'civicrm_state_province',
585 'labelColumn' => 'name',
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.',
596 'where' => 'civicrm_address.postal_code_suffix',
597 'headerPattern' => '/p(ostal)\sc(ode)\ss(uffix)/i',
598 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
600 'table_name' => 'civicrm_address',
601 'entity' => 'Address',
602 'bao' => 'CRM_Core_BAO_Address',
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.',
616 'where' => 'civicrm_address.postal_code',
617 'headerPattern' => '/postal|zip/i',
618 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
620 'table_name' => 'civicrm_address',
621 'entity' => 'Address',
622 'bao' => 'CRM_Core_BAO_Address',
629 'name' => 'usps_adc',
630 'type' => CRM_Utils_Type
::T_STRING
,
631 'title' => ts('USPS Code') ,
632 'description' => 'USPS Bulk mailing code.',
634 'size' => CRM_Utils_Type
::MEDIUM
,
635 'table_name' => 'civicrm_address',
636 'entity' => 'Address',
637 'bao' => 'CRM_Core_BAO_Address',
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',
649 'FKClassName' => 'CRM_Core_DAO_Country',
653 'pseudoconstant' => array(
654 'table' => 'civicrm_country',
656 'labelColumn' => 'name',
657 'nameColumn' => 'iso_code',
660 'geo_code_1' => array(
661 'name' => 'geo_code_1',
662 'type' => CRM_Utils_Type
::T_FLOAT
,
663 'title' => ts('Latitude') ,
664 'description' => 'Latitude',
666 'where' => 'civicrm_address.geo_code_1',
667 'headerPattern' => '/geo/i',
670 'table_name' => 'civicrm_address',
671 'entity' => 'Address',
672 'bao' => 'CRM_Core_BAO_Address',
678 'geo_code_2' => array(
679 'name' => 'geo_code_2',
680 'type' => CRM_Utils_Type
::T_FLOAT
,
681 'title' => ts('Longitude') ,
682 'description' => 'Longitude',
684 'where' => 'civicrm_address.geo_code_2',
685 'headerPattern' => '/geo/i',
688 'table_name' => 'civicrm_address',
689 'entity' => 'Address',
690 'bao' => 'CRM_Core_BAO_Address',
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',
706 'type' => 'CheckBox',
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".',
715 'size' => CRM_Utils_Type
::EIGHT
,
716 'table_name' => 'civicrm_address',
717 'entity' => 'Address',
718 'bao' => 'CRM_Core_BAO_Address',
724 'address_name' => array(
726 'type' => CRM_Utils_Type
::T_STRING
,
727 'title' => ts('Address Name') ,
729 'size' => CRM_Utils_Type
::HUGE
,
731 'where' => 'civicrm_address.name',
732 'headerPattern' => '/^location|(l(ocation\s)?name)$/i',
733 'dataPattern' => '/^\w+$/',
735 'table_name' => 'civicrm_address',
736 'entity' => 'Address',
737 'bao' => 'CRM_Core_BAO_Address',
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',
749 'where' => 'civicrm_address.master_id',
750 'headerPattern' => '',
753 'table_name' => 'civicrm_address',
754 'entity' => 'Address',
755 'bao' => 'CRM_Core_BAO_Address',
757 'FKClassName' => 'CRM_Core_DAO_Address',
760 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
762 return Civi
::$statics[__CLASS__
]['fields'];
765 * Return a mapping from field-name to the corresponding key (as used in fields()).
768 * Array(string $name => string $uniqueName).
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()));
774 return Civi
::$statics[__CLASS__
]['fieldKeys'];
777 * Returns the names of this table
781 static function getTableName() {
782 return self
::$_tableName;
785 * Returns if this table needs to be logged
793 * Returns the list of fields that can be imported
795 * @param bool $prefix
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',
808 * Returns the list of fields that can be exported
810 * @param bool $prefix
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',
823 * Returns the list of indices
825 public static function indices($localize = TRUE) {
827 'index_location_type' => array(
828 'name' => 'index_location_type',
830 0 => 'location_type_id',
832 'localizable' => false,
833 'sig' => 'civicrm_address::0::location_type_id',
835 'index_is_primary' => array(
836 'name' => 'index_is_primary',
840 'localizable' => false,
841 'sig' => 'civicrm_address::0::is_primary',
843 'index_is_billing' => array(
844 'name' => 'index_is_billing',
848 'localizable' => false,
849 'sig' => 'civicrm_address::0::is_billing',
851 'index_street_name' => array(
852 'name' => 'index_street_name',
856 'localizable' => false,
857 'sig' => 'civicrm_address::0::street_name',
859 'index_city' => array(
860 'name' => 'index_city',
864 'localizable' => false,
865 'sig' => 'civicrm_address::0::city',
868 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;