X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FDAO%2FAddress.php;h=924980b4654f8ea9a1b430c8611ea02f56c24d54;hb=45a83e4224c5c0ec7adcd484cace62704e81beb2;hp=6831efc7df0f818be8fabb16b95903f4297c5e4d;hpb=fbc6bb909b6f77d62a5021d30bc9bc496aef33b3;p=civicrm-core.git diff --git a/CRM/Core/DAO/Address.php b/CRM/Core/DAO/Address.php index 6831efc7df..877496a9d5 100644 --- a/CRM/Core/DAO/Address.php +++ b/CRM/Core/DAO/Address.php @@ -1,85 +1,68 @@ __table = 'civicrm_address'; parent::__construct(); } + /** * Returns foreign keys and entity references. * * @return array * [CRM_Core_Reference_Interface] */ - static function getReferenceColumns() { + public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); - Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id'); - Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'county_id', 'civicrm_county', 'id'); - Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'state_province_id', 'civicrm_state_province', 'id'); - Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'country_id', 'civicrm_country', 'id'); - Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'master_id', 'civicrm_address', 'id'); + Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); + Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'county_id', 'civicrm_county', 'id'); + Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'state_province_id', 'civicrm_state_province', 'id'); + Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'country_id', 'civicrm_country', 'id'); + Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'master_id', 'civicrm_address', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } return Civi::$statics[__CLASS__]['links']; } + /** * Returns all the column names of this table * * @return array */ - static function &fields() { + public static function &fields() { if (!isset(Civi::$statics[__CLASS__]['fields'])) { - Civi::$statics[__CLASS__]['fields'] = array( - 'id' => array( + Civi::$statics[__CLASS__]['fields'] = [ + 'id' => [ 'name' => 'id', 'type' => CRM_Utils_Type::T_INT, - 'title' => ts('Address ID') , + 'title' => ts('Address ID'), 'description' => 'Unique Address ID', - 'required' => true, - ) , - 'contact_id' => array( + 'required' => TRUE, + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + ], + 'contact_id' => [ 'name' => 'contact_id', 'type' => CRM_Utils_Type::T_INT, - 'title' => ts('Contact ID') , + 'title' => ts('Contact ID'), 'description' => 'FK to Contact ID', + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, 'FKClassName' => 'CRM_Contact_DAO_Contact', - ) , - 'location_type_id' => array( + ], + 'location_type_id' => [ 'name' => 'location_type_id', 'type' => CRM_Utils_Type::T_INT, - 'title' => ts('Address Location Type') , + 'title' => ts('Address Location Type'), 'description' => 'Which Location does this address belong to.', - 'html' => array( + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'Select', - ) , - 'pseudoconstant' => array( + ], + 'pseudoconstant' => [ 'table' => 'civicrm_location_type', 'keyColumn' => 'id', 'labelColumn' => 'display_name', - ) - ) , - 'is_primary' => array( + ] + ], + 'is_primary' => [ 'name' => 'is_primary', 'type' => CRM_Utils_Type::T_BOOLEAN, - 'title' => ts('Is Address Primary?') , + 'title' => ts('Is Address Primary?'), 'description' => 'Is this the primary address.', - 'html' => array( + 'default' => '0', + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'CheckBox', - ) , - ) , - 'is_billing' => array( + ], + ], + 'is_billing' => [ 'name' => 'is_billing', 'type' => CRM_Utils_Type::T_BOOLEAN, - 'title' => ts('Is Billing Address') , + 'title' => ts('Is Billing Address'), 'description' => 'Is this the billing address.', - 'html' => array( + 'default' => '0', + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'CheckBox', - ) , - ) , - 'street_address' => array( + ], + ], + 'street_address' => [ 'name' => 'street_address', 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Street Address') , + 'title' => ts('Street Address'), 'description' => 'Concatenation of all routable street address components (prefix, street number, street name, suffix, unit number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail delivery, etc.). ', 'maxlength' => 96, 'size' => CRM_Utils_Type::HUGE, - 'import' => true, + 'import' => TRUE, 'where' => 'civicrm_address.street_address', 'headerPattern' => '/(street|address)/i', 'dataPattern' => '/^(\d{1,5}( [0-9A-Za-z]+)+)$|^(P\.?O\.\? Box \d{1,5})$/i', - 'export' => true, - 'html' => array( + 'export' => TRUE, + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'Text', - ) , - ) , - 'street_number' => array( + ], + ], + 'street_number' => [ 'name' => 'street_number', 'type' => CRM_Utils_Type::T_INT, - 'title' => ts('Street Number') , + 'title' => ts('Street Number'), 'description' => 'Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.', - 'export' => true, + 'export' => TRUE, 'where' => 'civicrm_address.street_number', 'headerPattern' => '', 'dataPattern' => '', - 'html' => array( + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'Text', - ) , - ) , - 'street_number_suffix' => array( + ], + ], + 'street_number_suffix' => [ 'name' => 'street_number_suffix', 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Street Number Suffix') , + 'title' => ts('Street Number Suffix'), 'description' => 'Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A ', 'maxlength' => 8, 'size' => CRM_Utils_Type::EIGHT, - 'export' => true, + 'export' => TRUE, 'where' => 'civicrm_address.street_number_suffix', 'headerPattern' => '', 'dataPattern' => '', - 'html' => array( + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'Text', - ) , - ) , - 'street_number_predirectional' => array( + ], + ], + 'street_number_predirectional' => [ 'name' => 'street_number_predirectional', 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Street Direction Prefix') , + 'title' => ts('Street Direction Prefix'), 'description' => 'Directional prefix, e.g. SE Main St, SE is the prefix.', 'maxlength' => 8, 'size' => CRM_Utils_Type::EIGHT, - 'html' => array( + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'Text', - ) , - ) , - 'street_name' => array( + ], + ], + 'street_name' => [ 'name' => 'street_name', 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Street Name') , + 'title' => ts('Street Name'), 'description' => 'Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.', 'maxlength' => 64, 'size' => CRM_Utils_Type::BIG, - 'export' => true, + 'export' => TRUE, 'where' => 'civicrm_address.street_name', 'headerPattern' => '', 'dataPattern' => '', - 'html' => array( + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'Text', - ) , - ) , - 'street_type' => array( + ], + ], + 'street_type' => [ 'name' => 'street_type', 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Street Type') , + 'title' => ts('Street Type'), 'description' => 'St, Rd, Dr, etc.', 'maxlength' => 8, 'size' => CRM_Utils_Type::EIGHT, - 'html' => array( + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'Text', - ) , - ) , - 'street_number_postdirectional' => array( + ], + ], + 'street_number_postdirectional' => [ 'name' => 'street_number_postdirectional', 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Street Direction Suffix') , + 'title' => ts('Street Direction Suffix'), 'description' => 'Directional prefix, e.g. Main St S, S is the suffix.', 'maxlength' => 8, 'size' => CRM_Utils_Type::EIGHT, - 'html' => array( + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'Text', - ) , - ) , - 'street_unit' => array( + ], + ], + 'street_unit' => [ 'name' => 'street_unit', 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Street Unit') , + 'title' => ts('Street Unit'), 'description' => 'Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200', 'maxlength' => 16, 'size' => CRM_Utils_Type::TWELVE, - 'export' => true, + 'export' => TRUE, 'where' => 'civicrm_address.street_unit', 'headerPattern' => '', 'dataPattern' => '', - 'html' => array( + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'Text', - ) , - ) , - 'supplemental_address_1' => array( + ], + ], + 'supplemental_address_1' => [ 'name' => 'supplemental_address_1', 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Supplemental Address 1') , + 'title' => ts('Supplemental Address 1'), 'description' => 'Supplemental Address Information, Line 1', 'maxlength' => 96, 'size' => CRM_Utils_Type::HUGE, - 'import' => true, + 'import' => TRUE, 'where' => 'civicrm_address.supplemental_address_1', 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i', 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i', - 'export' => true, - 'html' => array( + 'export' => TRUE, + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'Text', - ) , - ) , - 'supplemental_address_2' => array( + ], + ], + 'supplemental_address_2' => [ 'name' => 'supplemental_address_2', 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Supplemental Address 2') , + 'title' => ts('Supplemental Address 2'), 'description' => 'Supplemental Address Information, Line 2', 'maxlength' => 96, 'size' => CRM_Utils_Type::HUGE, - 'import' => true, + 'import' => TRUE, 'where' => 'civicrm_address.supplemental_address_2', 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i', 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i', - 'export' => true, - 'html' => array( + 'export' => TRUE, + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'Text', - ) , - ) , - 'supplemental_address_3' => array( + ], + ], + 'supplemental_address_3' => [ 'name' => 'supplemental_address_3', 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Supplemental Address 3') , + 'title' => ts('Supplemental Address 3'), 'description' => 'Supplemental Address Information, Line 3', 'maxlength' => 96, 'size' => CRM_Utils_Type::HUGE, - 'html' => array( + 'import' => TRUE, + 'where' => 'civicrm_address.supplemental_address_3', + 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i', + 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i', + 'export' => TRUE, + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'Text', - ) , - ) , - 'city' => array( + ], + ], + 'city' => [ 'name' => 'city', 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('City') , + 'title' => ts('City'), 'description' => 'City, Town or Village Name.', 'maxlength' => 64, 'size' => CRM_Utils_Type::BIG, - 'import' => true, + 'import' => TRUE, 'where' => 'civicrm_address.city', 'headerPattern' => '/city/i', 'dataPattern' => '/^[A-Za-z]+(\.?)(\s?[A-Za-z]+){0,2}$/', - 'export' => true, - 'html' => array( + 'export' => TRUE, + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'Text', - ) , - ) , - 'county_id' => array( + ], + ], + 'county_id' => [ 'name' => 'county_id', 'type' => CRM_Utils_Type::T_INT, - 'title' => ts('County') , + 'title' => ts('County'), 'description' => 'Which County does this address belong to.', + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, 'FKClassName' => 'CRM_Core_DAO_County', - 'html' => array( + 'html' => [ 'type' => 'ChainSelect', - ) , - 'pseudoconstant' => array( + ], + 'pseudoconstant' => [ 'table' => 'civicrm_county', 'keyColumn' => 'id', 'labelColumn' => 'name', - ) - ) , - 'state_province_id' => array( + ] + ], + 'state_province_id' => [ 'name' => 'state_province_id', 'type' => CRM_Utils_Type::T_INT, - 'title' => ts('State/Province') , + 'title' => ts('State/Province'), 'description' => 'Which State_Province does this address belong to.', + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, 'FKClassName' => 'CRM_Core_DAO_StateProvince', - 'html' => array( + 'html' => [ 'type' => 'ChainSelect', - ) , - 'pseudoconstant' => array( + ], + 'pseudoconstant' => [ 'table' => 'civicrm_state_province', 'keyColumn' => 'id', 'labelColumn' => 'name', - ) - ) , - 'postal_code_suffix' => array( + ] + ], + 'postal_code_suffix' => [ 'name' => 'postal_code_suffix', 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Postal Code Suffix') , + 'title' => ts('Postal Code Suffix'), 'description' => 'Store the suffix, like the +4 part in the USPS system.', 'maxlength' => 12, 'size' => 3, - 'import' => true, + 'import' => TRUE, 'where' => 'civicrm_address.postal_code_suffix', 'headerPattern' => '/p(ostal)\sc(ode)\ss(uffix)/i', 'dataPattern' => '/\d?\d{4}(-\d{4})?/', - 'export' => true, - 'html' => array( + 'export' => TRUE, + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'Text', - ) , - ) , - 'postal_code' => array( + ], + ], + 'postal_code' => [ 'name' => 'postal_code', 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Postal Code') , + 'title' => ts('Postal Code'), 'description' => 'Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.', 'maxlength' => 64, 'size' => 6, - 'import' => true, + 'import' => TRUE, 'where' => 'civicrm_address.postal_code', 'headerPattern' => '/postal|zip/i', 'dataPattern' => '/\d?\d{4}(-\d{4})?/', - 'export' => true, - 'html' => array( + 'export' => TRUE, + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'Text', - ) , - ) , - 'usps_adc' => array( + ], + ], + 'usps_adc' => [ 'name' => 'usps_adc', 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('USPS Code') , + 'title' => ts('USPS Code'), 'description' => 'USPS Bulk mailing code.', 'maxlength' => 32, 'size' => CRM_Utils_Type::MEDIUM, - ) , - 'country_id' => array( + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + ], + 'country_id' => [ 'name' => 'country_id', 'type' => CRM_Utils_Type::T_INT, - 'title' => ts('Country') , + 'title' => ts('Country'), 'description' => 'Which Country does this address belong to.', + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, 'FKClassName' => 'CRM_Core_DAO_Country', - 'html' => array( + 'html' => [ 'type' => 'Select', - ) , - 'pseudoconstant' => array( + ], + 'pseudoconstant' => [ 'table' => 'civicrm_country', 'keyColumn' => 'id', 'labelColumn' => 'name', 'nameColumn' => 'iso_code', - ) - ) , - 'geo_code_1' => array( + ] + ], + 'geo_code_1' => [ 'name' => 'geo_code_1', 'type' => CRM_Utils_Type::T_FLOAT, - 'title' => ts('Latitude') , + 'title' => ts('Latitude'), 'description' => 'Latitude', - 'import' => true, + 'import' => TRUE, 'where' => 'civicrm_address.geo_code_1', 'headerPattern' => '/geo/i', 'dataPattern' => '', - 'export' => true, - 'html' => array( + 'export' => TRUE, + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'Text', - ) , - ) , - 'geo_code_2' => array( + ], + ], + 'geo_code_2' => [ 'name' => 'geo_code_2', 'type' => CRM_Utils_Type::T_FLOAT, - 'title' => ts('Longitude') , + 'title' => ts('Longitude'), 'description' => 'Longitude', - 'import' => true, + 'import' => TRUE, 'where' => 'civicrm_address.geo_code_2', 'headerPattern' => '/geo/i', 'dataPattern' => '', - 'export' => true, - 'html' => array( + 'export' => TRUE, + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'Text', - ) , - ) , - 'manual_geo_code' => array( + ], + ], + 'manual_geo_code' => [ 'name' => 'manual_geo_code', 'type' => CRM_Utils_Type::T_BOOLEAN, - 'title' => ts('Is manually geocoded') , + 'title' => ts('Is manually geocoded'), 'description' => 'Is this a manually entered geo code', - 'html' => array( + 'default' => '0', + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'CheckBox', - ) , - ) , - 'timezone' => array( + ], + ], + 'timezone' => [ 'name' => 'timezone', 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Timezone') , + 'title' => ts('Timezone'), 'description' => 'Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".', 'maxlength' => 8, 'size' => CRM_Utils_Type::EIGHT, - 'html' => array( + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'Text', - ) , - ) , - 'address_name' => array( + ], + ], + 'address_name' => [ 'name' => 'name', 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Address Name') , + 'title' => ts('Address Name'), 'maxlength' => 255, 'size' => CRM_Utils_Type::HUGE, - 'import' => true, + 'import' => TRUE, 'where' => 'civicrm_address.name', 'headerPattern' => '/^location|(l(ocation\s)?name)$/i', 'dataPattern' => '/^\w+$/', - 'export' => true, - 'html' => array( + 'export' => TRUE, + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, + 'html' => [ 'type' => 'Text', - ) , - ) , - 'master_id' => array( + ], + ], + 'master_id' => [ 'name' => 'master_id', 'type' => CRM_Utils_Type::T_INT, - 'title' => ts('Master Address Belongs To') , + 'title' => ts('Master Address Belongs To'), 'description' => 'FK to Address ID', - 'import' => true, + 'import' => TRUE, 'where' => 'civicrm_address.master_id', 'headerPattern' => '', 'dataPattern' => '', - 'export' => true, + 'export' => TRUE, + 'table_name' => 'civicrm_address', + 'entity' => 'Address', + 'bao' => 'CRM_Core_BAO_Address', + 'localizable' => 0, 'FKClassName' => 'CRM_Core_DAO_Address', - ) , - ); + ], + ]; CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); } return Civi::$statics[__CLASS__]['fields']; } + /** * Return a mapping from field-name to the corresponding key (as used in fields()). * * @return array * Array(string $name => string $uniqueName). */ - static function &fieldKeys() { + public static function &fieldKeys() { if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); } return Civi::$statics[__CLASS__]['fieldKeys']; } + /** * Returns the names of this table * * @return string */ - static function getTableName() { + public static function getTableName() { return self::$_tableName; } + /** * Returns if this table needs to be logged * - * @return boolean + * @return bool */ - function getLog() { + public function getLog() { return self::$_log; } + /** * Returns the list of fields that can be imported * @@ -675,14 +811,15 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO { * * @return array */ - static function &import($prefix = false) { - $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'address', $prefix, array( + public static function &import($prefix = FALSE) { + $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'address', $prefix, [ 'CRM_Core_DAO_County', 'CRM_Core_DAO_StateProvince', 'CRM_Core_DAO_Country', - )); + ]); return $r; } + /** * Returns the list of fields that can be exported * @@ -690,12 +827,66 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO { * * @return array */ - static function &export($prefix = false) { - $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'address', $prefix, array( + public static function &export($prefix = FALSE) { + $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'address', $prefix, [ 'CRM_Core_DAO_County', 'CRM_Core_DAO_StateProvince', 'CRM_Core_DAO_Country', - )); + ]); return $r; } + + /** + * Returns the list of indices + * + * @param bool $localize + * + * @return array + */ + public static function indices($localize = TRUE) { + $indices = [ + 'index_location_type' => [ + 'name' => 'index_location_type', + 'field' => [ + 0 => 'location_type_id', + ], + 'localizable' => FALSE, + 'sig' => 'civicrm_address::0::location_type_id', + ], + 'index_is_primary' => [ + 'name' => 'index_is_primary', + 'field' => [ + 0 => 'is_primary', + ], + 'localizable' => FALSE, + 'sig' => 'civicrm_address::0::is_primary', + ], + 'index_is_billing' => [ + 'name' => 'index_is_billing', + 'field' => [ + 0 => 'is_billing', + ], + 'localizable' => FALSE, + 'sig' => 'civicrm_address::0::is_billing', + ], + 'index_street_name' => [ + 'name' => 'index_street_name', + 'field' => [ + 0 => 'street_name', + ], + 'localizable' => FALSE, + 'sig' => 'civicrm_address::0::street_name', + ], + 'index_city' => [ + 'name' => 'index_city', + 'field' => [ + 0 => 'city', + ], + 'localizable' => FALSE, + 'sig' => 'civicrm_address::0::city', + ], + ]; + return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; + } + }