3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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-2015
31 * Generated from xml/schema/CRM/Core/Address.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
34 require_once 'CRM/Core/DAO.php';
35 require_once 'CRM/Utils/Type.php';
36 require_once 'CRM/Core/DAO/County.php';
37 require_once 'CRM/Core/DAO/StateProvince.php';
38 require_once 'CRM/Core/DAO/Country.php';
39 class CRM_Core_DAO_Address
extends CRM_Core_DAO
{
41 * static instance to hold the table name
45 static $_tableName = 'civicrm_address';
47 * static instance to hold the field values
51 static $_fields = null;
53 * static instance to hold the keys used in $_fields for each field.
57 static $_fieldKeys = null;
59 * static instance to hold the FK relationships
63 static $_links = null;
65 * static instance to hold the values that can
70 static $_import = null;
72 * static instance to hold the values that can
77 static $_export = null;
79 * static value to see if we should log any modifications to
80 * this table in the civicrm_log table
98 * Which Location does this address belong to.
102 public $location_type_id;
104 * Is this the primary address.
110 * Is this the billing address.
116 * Concatenation of all routable street address components (prefix, street number, street name, suffix, unit
117 number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail
122 public $street_address;
124 * Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.
128 public $street_number;
130 * Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A
134 public $street_number_suffix;
136 * Directional prefix, e.g. SE Main St, SE is the prefix.
140 public $street_number_predirectional;
142 * Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.
154 * Directional prefix, e.g. Main St S, S is the suffix.
158 public $street_number_postdirectional;
160 * Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200
166 * Supplemental Address Information, Line 1
170 public $supplemental_address_1;
172 * Supplemental Address Information, Line 2
176 public $supplemental_address_2;
178 * Supplemental Address Information, Line 3
182 public $supplemental_address_3;
184 * City, Town or Village Name.
190 * Which County does this address belong to.
196 * Which State_Province does this address belong to.
200 public $state_province_id;
202 * Store the suffix, like the +4 part in the USPS system.
206 public $postal_code_suffix;
208 * Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate
215 * USPS Bulk mailing code.
221 * Which Country does this address belong to.
239 * Is this a manually entered geo code
243 public $manual_geo_code;
245 * Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".
264 * @return civicrm_address
266 function __construct() {
267 $this->__table
= 'civicrm_address';
268 parent
::__construct();
271 * Returns foreign keys and entity references
274 * [CRM_Core_Reference_Interface]
276 static function getReferenceColumns() {
277 if (!self
::$_links) {
278 self
::$_links = static ::createReferenceColumns(__CLASS__
);
279 self
::$_links[] = new CRM_Core_Reference_Basic(self
::getTableName() , 'contact_id', 'civicrm_contact', 'id');
280 self
::$_links[] = new CRM_Core_Reference_Basic(self
::getTableName() , 'county_id', 'civicrm_county', 'id');
281 self
::$_links[] = new CRM_Core_Reference_Basic(self
::getTableName() , 'state_province_id', 'civicrm_state_province', 'id');
282 self
::$_links[] = new CRM_Core_Reference_Basic(self
::getTableName() , 'country_id', 'civicrm_country', 'id');
283 self
::$_links[] = new CRM_Core_Reference_Basic(self
::getTableName() , 'master_id', 'civicrm_address', 'id');
285 return self
::$_links;
288 * Returns all the column names of this table
292 static function &fields() {
293 if (!(self
::$_fields)) {
294 self
::$_fields = array(
297 'type' => CRM_Utils_Type
::T_INT
,
298 'title' => ts('Address ID') ,
299 'description' => 'Unique Address ID',
302 'contact_id' => array(
303 'name' => 'contact_id',
304 'type' => CRM_Utils_Type
::T_INT
,
305 'title' => ts('Contact ID') ,
306 'description' => 'FK to Contact ID',
307 'FKClassName' => 'CRM_Contact_DAO_Contact',
309 'location_type_id' => array(
310 'name' => 'location_type_id',
311 'type' => CRM_Utils_Type
::T_INT
,
312 'title' => ts('Address Location Type') ,
313 'description' => 'Which Location does this address belong to.',
317 'pseudoconstant' => array(
318 'table' => 'civicrm_location_type',
320 'labelColumn' => 'display_name',
323 'is_primary' => array(
324 'name' => 'is_primary',
325 'type' => CRM_Utils_Type
::T_BOOLEAN
,
326 'title' => ts('Is Address Primary?') ,
327 'description' => 'Is this the primary address.',
329 'is_billing' => array(
330 'name' => 'is_billing',
331 'type' => CRM_Utils_Type
::T_BOOLEAN
,
332 'title' => ts('Is Billing Address') ,
333 'description' => 'Is this the billing address.',
335 'street_address' => array(
336 'name' => 'street_address',
337 'type' => CRM_Utils_Type
::T_STRING
,
338 'title' => ts('Street Address') ,
339 'description' => 'Concatenation of all routable street address components (prefix, street number, street name, suffix, unit
340 number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail
344 'size' => CRM_Utils_Type
::HUGE
,
346 'where' => 'civicrm_address.street_address',
347 'headerPattern' => '/(street|address)/i',
348 'dataPattern' => '/^(\d{1,5}( [0-9A-Za-z]+)+)$|^(P\.?O\.\? Box \d{1,5})$/i',
351 'street_number' => array(
352 'name' => 'street_number',
353 'type' => CRM_Utils_Type
::T_INT
,
354 'title' => ts('Street Number') ,
355 'description' => 'Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.',
357 'where' => 'civicrm_address.street_number',
358 'headerPattern' => '',
361 'street_number_suffix' => array(
362 'name' => 'street_number_suffix',
363 'type' => CRM_Utils_Type
::T_STRING
,
364 'title' => ts('Street Number Suffix') ,
365 'description' => 'Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A
368 'size' => CRM_Utils_Type
::EIGHT
,
370 'where' => 'civicrm_address.street_number_suffix',
371 'headerPattern' => '',
374 'street_number_predirectional' => array(
375 'name' => 'street_number_predirectional',
376 'type' => CRM_Utils_Type
::T_STRING
,
377 'title' => ts('Street Direction Prefix') ,
378 'description' => 'Directional prefix, e.g. SE Main St, SE is the prefix.',
380 'size' => CRM_Utils_Type
::EIGHT
,
382 'street_name' => array(
383 'name' => 'street_name',
384 'type' => CRM_Utils_Type
::T_STRING
,
385 'title' => ts('Street Name') ,
386 'description' => 'Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.',
388 'size' => CRM_Utils_Type
::BIG
,
390 'where' => 'civicrm_address.street_name',
391 'headerPattern' => '',
394 'street_type' => array(
395 'name' => 'street_type',
396 'type' => CRM_Utils_Type
::T_STRING
,
397 'title' => ts('Street Type') ,
398 'description' => 'St, Rd, Dr, etc.',
400 'size' => CRM_Utils_Type
::EIGHT
,
402 'street_number_postdirectional' => array(
403 'name' => 'street_number_postdirectional',
404 'type' => CRM_Utils_Type
::T_STRING
,
405 'title' => ts('Street Direction Suffix') ,
406 'description' => 'Directional prefix, e.g. Main St S, S is the suffix.',
408 'size' => CRM_Utils_Type
::EIGHT
,
410 'street_unit' => array(
411 'name' => 'street_unit',
412 'type' => CRM_Utils_Type
::T_STRING
,
413 'title' => ts('Street Unit') ,
414 'description' => 'Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200',
416 'size' => CRM_Utils_Type
::TWELVE
,
418 'where' => 'civicrm_address.street_unit',
419 'headerPattern' => '',
422 'supplemental_address_1' => array(
423 'name' => 'supplemental_address_1',
424 'type' => CRM_Utils_Type
::T_STRING
,
425 'title' => ts('Supplemental Address 1') ,
426 'description' => 'Supplemental Address Information, Line 1',
428 'size' => CRM_Utils_Type
::HUGE
,
430 'where' => 'civicrm_address.supplemental_address_1',
431 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
432 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
435 'supplemental_address_2' => array(
436 'name' => 'supplemental_address_2',
437 'type' => CRM_Utils_Type
::T_STRING
,
438 'title' => ts('Supplemental Address 2') ,
439 'description' => 'Supplemental Address Information, Line 2',
441 'size' => CRM_Utils_Type
::HUGE
,
443 'where' => 'civicrm_address.supplemental_address_2',
444 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
445 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
448 'supplemental_address_3' => array(
449 'name' => 'supplemental_address_3',
450 'type' => CRM_Utils_Type
::T_STRING
,
451 'title' => ts('Supplemental Address 3') ,
452 'description' => 'Supplemental Address Information, Line 3',
454 'size' => CRM_Utils_Type
::HUGE
,
458 'type' => CRM_Utils_Type
::T_STRING
,
459 'title' => ts('City') ,
460 'description' => 'City, Town or Village Name.',
462 'size' => CRM_Utils_Type
::BIG
,
464 'where' => 'civicrm_address.city',
465 'headerPattern' => '/city/i',
466 'dataPattern' => '/^[A-Za-z]+(\.?)(\s?[A-Za-z]+){0,2}$/',
469 'county_id' => array(
470 'name' => 'county_id',
471 'type' => CRM_Utils_Type
::T_INT
,
472 'title' => ts('County') ,
473 'description' => 'Which County does this address belong to.',
474 'FKClassName' => 'CRM_Core_DAO_County',
478 'pseudoconstant' => array(
479 'table' => 'civicrm_county',
481 'labelColumn' => 'name',
484 'state_province_id' => array(
485 'name' => 'state_province_id',
486 'type' => CRM_Utils_Type
::T_INT
,
487 'title' => ts('State') ,
488 'description' => 'Which State_Province does this address belong to.',
489 'FKClassName' => 'CRM_Core_DAO_StateProvince',
493 'pseudoconstant' => array(
494 'table' => 'civicrm_state_province',
496 'labelColumn' => 'name',
499 'postal_code_suffix' => array(
500 'name' => 'postal_code_suffix',
501 'type' => CRM_Utils_Type
::T_STRING
,
502 'title' => ts('Postal Code Suffix') ,
503 'description' => 'Store the suffix, like the +4 part in the USPS system.',
505 'size' => CRM_Utils_Type
::TWELVE
,
507 'where' => 'civicrm_address.postal_code_suffix',
508 'headerPattern' => '/p(ostal)\sc(ode)\ss(uffix)/i',
509 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
512 'postal_code' => array(
513 'name' => 'postal_code',
514 'type' => CRM_Utils_Type
::T_STRING
,
515 'title' => ts('Postal Code') ,
516 'description' => 'Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate
520 'size' => CRM_Utils_Type
::TWELVE
,
522 'where' => 'civicrm_address.postal_code',
523 'headerPattern' => '/postal|zip/i',
524 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
528 'name' => 'usps_adc',
529 'type' => CRM_Utils_Type
::T_STRING
,
530 'title' => ts('USPS Code') ,
531 'description' => 'USPS Bulk mailing code.',
533 'size' => CRM_Utils_Type
::MEDIUM
,
535 'country_id' => array(
536 'name' => 'country_id',
537 'type' => CRM_Utils_Type
::T_INT
,
538 'title' => ts('Country') ,
539 'description' => 'Which Country does this address belong to.',
540 'FKClassName' => 'CRM_Core_DAO_Country',
544 'pseudoconstant' => array(
545 'table' => 'civicrm_country',
547 'labelColumn' => 'name',
548 'nameColumn' => 'iso_code',
551 'geo_code_1' => array(
552 'name' => 'geo_code_1',
553 'type' => CRM_Utils_Type
::T_FLOAT
,
554 'title' => ts('Latitude') ,
555 'description' => 'Latitude',
557 'where' => 'civicrm_address.geo_code_1',
558 'headerPattern' => '/geo/i',
562 'geo_code_2' => array(
563 'name' => 'geo_code_2',
564 'type' => CRM_Utils_Type
::T_FLOAT
,
565 'title' => ts('Longitude') ,
566 'description' => 'Longitude',
568 'where' => 'civicrm_address.geo_code_2',
569 'headerPattern' => '/geo/i',
573 'manual_geo_code' => array(
574 'name' => 'manual_geo_code',
575 'type' => CRM_Utils_Type
::T_BOOLEAN
,
576 'title' => ts('Is manually geocoded') ,
577 'description' => 'Is this a manually entered geo code',
580 'name' => 'timezone',
581 'type' => CRM_Utils_Type
::T_STRING
,
582 'title' => ts('Timezone') ,
583 'description' => 'Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".',
585 'size' => CRM_Utils_Type
::EIGHT
,
587 'address_name' => array(
589 'type' => CRM_Utils_Type
::T_STRING
,
590 'title' => ts('Address Name') ,
592 'size' => CRM_Utils_Type
::HUGE
,
594 'where' => 'civicrm_address.name',
595 'headerPattern' => '/^location|(l(ocation\s)?name)$/i',
596 'dataPattern' => '/^\w+$/',
599 'master_id' => array(
600 'name' => 'master_id',
601 'type' => CRM_Utils_Type
::T_INT
,
602 'title' => ts('Master Address Belongs To') ,
603 'description' => 'FK to Address ID',
605 'where' => 'civicrm_address.master_id',
606 'headerPattern' => '',
609 'FKClassName' => 'CRM_Core_DAO_Address',
613 return self
::$_fields;
616 * Returns an array containing, for each field, the arary key used for that
617 * field in self::$_fields.
621 static function &fieldKeys() {
622 if (!(self
::$_fieldKeys)) {
623 self
::$_fieldKeys = array(
625 'contact_id' => 'contact_id',
626 'location_type_id' => 'location_type_id',
627 'is_primary' => 'is_primary',
628 'is_billing' => 'is_billing',
629 'street_address' => 'street_address',
630 'street_number' => 'street_number',
631 'street_number_suffix' => 'street_number_suffix',
632 'street_number_predirectional' => 'street_number_predirectional',
633 'street_name' => 'street_name',
634 'street_type' => 'street_type',
635 'street_number_postdirectional' => 'street_number_postdirectional',
636 'street_unit' => 'street_unit',
637 'supplemental_address_1' => 'supplemental_address_1',
638 'supplemental_address_2' => 'supplemental_address_2',
639 'supplemental_address_3' => 'supplemental_address_3',
641 'county_id' => 'county_id',
642 'state_province_id' => 'state_province_id',
643 'postal_code_suffix' => 'postal_code_suffix',
644 'postal_code' => 'postal_code',
645 'usps_adc' => 'usps_adc',
646 'country_id' => 'country_id',
647 'geo_code_1' => 'geo_code_1',
648 'geo_code_2' => 'geo_code_2',
649 'manual_geo_code' => 'manual_geo_code',
650 'timezone' => 'timezone',
651 'name' => 'address_name',
652 'master_id' => 'master_id',
655 return self
::$_fieldKeys;
658 * Returns the names of this table
662 static function getTableName() {
663 return self
::$_tableName;
666 * Returns if this table needs to be logged
674 * Returns the list of fields that can be imported
676 * @param bool $prefix
680 static function &import($prefix = false) {
681 if (!(self
::$_import)) {
682 self
::$_import = array();
683 $fields = self
::fields();
684 foreach($fields as $name => $field) {
685 if (CRM_Utils_Array
::value('import', $field)) {
687 self
::$_import['address'] = & $fields[$name];
689 self
::$_import[$name] = & $fields[$name];
693 self
::$_import = array_merge(self
::$_import, CRM_Core_DAO_County
::import(true));
694 self
::$_import = array_merge(self
::$_import, CRM_Core_DAO_StateProvince
::import(true));
695 self
::$_import = array_merge(self
::$_import, CRM_Core_DAO_Country
::import(true));
697 return self
::$_import;
700 * Returns the list of fields that can be exported
702 * @param bool $prefix
706 static function &export($prefix = false) {
707 if (!(self
::$_export)) {
708 self
::$_export = array();
709 $fields = self
::fields();
710 foreach($fields as $name => $field) {
711 if (CRM_Utils_Array
::value('export', $field)) {
713 self
::$_export['address'] = & $fields[$name];
715 self
::$_export[$name] = & $fields[$name];
719 self
::$_export = array_merge(self
::$_export, CRM_Core_DAO_County
::export(true));
720 self
::$_export = array_merge(self
::$_export, CRM_Core_DAO_StateProvince
::export(true));
721 self
::$_export = array_merge(self
::$_export, CRM_Core_DAO_Country
::export(true));
723 return self
::$_export;