Allow to skip geocoding when creating an address with the api
authorWim De Craene <wim.de.craene@mediaraven.be>
Wed, 6 Jan 2016 11:35:35 +0000 (12:35 +0100)
committerWim De Craene <wim.de.craene@mediaraven.be>
Wed, 6 Jan 2016 11:35:35 +0000 (12:35 +0100)
CRM/Core/BAO/Address.php
api/v3/Address.php

index d7a01331e9f93bde0f5efeb041d90669a03b89e6..14367b8a03a2eddfad15fee0b637dd958e7f7c5f 100644 (file)
@@ -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);
     }
index 8753a1eb14ed65a04bb3087b386ca4b7d50a0a9a..041aef461e1a7f4061e358689464004462cfcf37 100644 (file)
@@ -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',