From b48c14670e80c874b5df3bf0875b1bc9007a60b1 Mon Sep 17 00:00:00 2001 From: Wim De Craene Date: Wed, 6 Jan 2016 12:35:35 +0100 Subject: [PATCH] Allow to skip geocoding when creating an address with the api --- CRM/Core/BAO/Address.php | 5 ++++- api/v3/Address.php | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php index d7a01331e9..14367b8a03 100644 --- a/CRM/Core/BAO/Address.php +++ b/CRM/Core/BAO/Address.php @@ -378,8 +378,11 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address { } } + // check if geocode should be skipped (can be forced with an optional parameter through the api) + $skip_geocode = (isset($params['skip_geocode']) && $params['skip_geocode']) ? TRUE : FALSE; + // add latitude and longitude and format address if needed - if (!empty($config->geocodeMethod) && ($config->geocodeMethod != 'CRM_Utils_Geocode_OpenStreetMaps') && empty($params['manual_geo_code'])) { + if (!$skip_geocode && !empty($config->geocodeMethod) && ($config->geocodeMethod != 'CRM_Utils_Geocode_OpenStreetMaps') && empty($params['manual_geo_code'])) { $class = $config->geocodeMethod; $class::format($params); } diff --git a/api/v3/Address.php b/api/v3/Address.php index 8753a1eb14..041aef461e 100644 --- a/api/v3/Address.php +++ b/api/v3/Address.php @@ -101,6 +101,12 @@ function _civicrm_api3_address_create_spec(&$params) { 'description' => 'Optional param to indicate you want the street_address field parsed into individual params', 'type' => CRM_Utils_Type::T_BOOLEAN, ); + $params['skip_geocode'] = array( + 'title' => 'Skip geocode', + 'description' => 'Optional param to indicate you want to skip geocoding (useful when importing a lot of addresses + at once, the job \'Geocode and Parse Addresses\' can execute this task after the import)', + 'type' => CRM_Utils_Type::T_BOOLEAN, + ); $params['world_region'] = array( 'title' => ts('World Region'), 'name' => 'world_region', -- 2.25.1