0012210: configure if Nominatim should be used during contact import
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 19 Sep 2016 10:38:49 +0000 (12:38 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 28 Sep 2016 10:23:55 +0000 (12:23 +0200)
https://forge.tine20.org/view.php?id=12210

Change-Id: I5a308892633064454eb15e5f722eb39facab946f
Reviewed-on: http://gerrit.tine20.com/customers/3580
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Addressbook/Config.php
tine20/Addressbook/Import/Csv.php

index efe2534..4d9a990 100644 (file)
  */
 class Addressbook_Config extends Tinebase_Config_Abstract
 {
+
+    /**
+     * contact nominatim during contact import
+     *
+     * @var string
+     */
+    const CONTACT_IMPORT_NOMINATIM = 'contactImportNominatim';
+
     /**
      * fields for contact record duplicate check
      * 
@@ -107,6 +115,16 @@ class Addressbook_Config extends Tinebase_Config_Abstract
             'setByAdminModule'      => FALSE,
             'setBySetupModule'      => FALSE,
         ),
+        self::CONTACT_IMPORT_NOMINATIM => array(
+            //_('Use Nominatim during contact import')
+            'label'                 => 'Use Nominatim during contact import',
+            'description'           => 'Use Nominatim during contact import',
+            'type'                  => 'bool',
+            'default'               => false,
+            'clientRegistryInclude' => false,
+            'setByAdminModule'      => true,
+            'setBySetupModule'      => true,
+        ),
     );
     
     /**
index adf8a30..aef860e 100644 (file)
@@ -48,9 +48,12 @@ class Addressbook_Import_Csv extends Tinebase_Import_Csv_Abstract
     public function __construct(array $_options = array())
     {
         parent::__construct($_options);
-        
-        // don't set geodata for imported contacts as this is too much traffic for the nominatim server
-        $this->_controller->setGeoDataForContacts(FALSE);
+
+        if (! Addressbook_Config::getInstance()->get(Addressbook_Config::CONTACT_IMPORT_NOMINATIM)) {
+            // don't set geodata for imported contacts as this might be too much traffic for the nominatim server
+            // TODO make this setting overwritable via import definition/options
+            $this->_controller->setGeoDataForContacts(FALSE);
+        }
         
         // get container id from default container if not set
         if (empty($this->_options['container_id'])) {