diff --git a/CRM/Contact/Import/Form/DataSource.php b/CRM/Contact/Import/Form/DataSource.php index 24baf8485d1b02625e7e46dc2bf74ebe43e30be6..bd71da375ca03c8412f449bd1dd0a3b72b78d6dd 100644 --- a/CRM/Contact/Import/Form/DataSource.php +++ b/CRM/Contact/Import/Form/DataSource.php @@ -164,6 +164,7 @@ class CRM_Contact_Import_Form_DataSource extends CRM_Import_Form_DataSource { 'onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP, 'contactType' => CRM_Import_Parser::CONTACT_INDIVIDUAL, 'fieldSeparator' => CRM_Core_Config::singleton()->fieldSeparator, + 'disableUSPS' => TRUE, ]; if ($this->get('loadedMapping')) { diff --git a/CRM/Contact/Import/Form/Preview.php b/CRM/Contact/Import/Form/Preview.php index f2ff07f56f24215965e8edbb15103a82e9ddd56f..28b219647772a85166ad54621b27c6dc5ccb324e 100644 --- a/CRM/Contact/Import/Form/Preview.php +++ b/CRM/Contact/Import/Form/Preview.php @@ -191,7 +191,6 @@ class CRM_Contact_Import_Form_Preview extends CRM_Import_Form_Preview { CRM_ACL_BAO_Cache::deleteContactCacheEntry($userID); } - CRM_Utils_Address_USPS::disable($this->getSubmittedValue('disableUSPS')); $this->runTheImport(); } diff --git a/CRM/Contact/Import/Parser/Contact.php b/CRM/Contact/Import/Parser/Contact.php index 78f0aa495a62c11e616045696140aab298eaad1c..35260a50e9d3b118521f0412905ead71ff7a7e8f 100644 --- a/CRM/Contact/Import/Parser/Contact.php +++ b/CRM/Contact/Import/Parser/Contact.php @@ -119,6 +119,10 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { public function import($values) { $rowNumber = (int) $values[array_key_last($values)]; + // Put this here for now since we're gettting run by a job and need to + // reset it for each task run. + CRM_Utils_Address_USPS::disable($this->getSubmittedValue('disableUSPS')); + $this->_unparsedStreetAddressContacts = []; if (!$this->getSubmittedValue('doGeocodeAddress')) { // CRM-5854, reset the geocode method to null to prevent geocoding diff --git a/templates/CRM/Contact/Import/Form/DataSource.tpl b/templates/CRM/Contact/Import/Form/DataSource.tpl index 102964316bee2b6519136797a241d976606df849..c09b930779ea0d3e3769312e50d25c21dc0edcbd 100644 --- a/templates/CRM/Contact/Import/Form/DataSource.tpl +++ b/templates/CRM/Contact/Import/Form/DataSource.tpl @@ -80,7 +80,9 @@ {if $form.disableUSPS} <tr class="crm-import-datasource-form-block-disableUSPS"> <td class="label"></td> - <td>{$form.disableUSPS.html} <label for="disableUSPS">{$form.disableUSPS.label}</label></td> + <td>{$form.disableUSPS.html} <label for="disableUSPS">{$form.disableUSPS.label}</label><br /> + <span class="description">{ts}Uncheck at your own risk as batch processing violates USPS API TOS.{/ts}</span> + </td> </tr> {/if} </table> diff --git a/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php b/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php index 4f30f10a37feb43c81edd2d2f89be466590d249c..01150919d32de9d3d3417a665f825c3c9abdca44 100644 --- a/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php +++ b/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php @@ -2004,6 +2004,7 @@ class CRM_Contact_Import_Parser_ContactTest extends CiviUnitTestCase { 'contactType' => CRM_Import_Parser::CONTACT_INDIVIDUAL, 'contactSubType' => '', 'doGeocodeAddress' => 0, + 'disableUSPS' => 0, 'dataSource' => 'CRM_Import_DataSource_SQL', 'sqlQuery' => 'SELECT first_name FROM civicrm_contact', 'onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP,