diff --git a/api/v3/TwingleDonation/Submit.php b/api/v3/TwingleDonation/Submit.php index f773054..4025f97 100644 --- a/api/v3/TwingleDonation/Submit.php +++ b/api/v3/TwingleDonation/Submit.php @@ -335,25 +335,20 @@ function civicrm_api3_twingle_donation_Submit($params) { } } - // Make required address components configurable to prevent existing - // contact addresses from being overwritten with incomplete address - // information. See issue #47 - $required_address_components = - $profile->getAttribute('required_address_components'); - $unset_address_params = False; - foreach ($required_address_components as $req) { - if (empty($params[$req])) { - $unset_address_params = True; - } - } - if ($unset_address_params) { - foreach([ - 'street_address', - 'postal_code', - 'city', - 'country', - ] as $req) { - unset($params[$req]); + // Remove address data when any address component that is configured as + // required is missing. + // See https://github.com/systopia/de.systopia.twingle/issues/47 + foreach ($profile->getAttribute('required_address_components', []) as $required_address_component) { + if (empty($params[$required_address_component])) { + foreach ([ + 'street_address', + 'postal_code', + 'city', + 'country', + ] as $address_param) { + unset($params[$address_param]); + } + break; } } diff --git a/templates/CRM/Twingle/Form/Profile.hlp b/templates/CRM/Twingle/Form/Profile.hlp index b4c6ff9..e3841d7 100644 --- a/templates/CRM/Twingle/Form/Profile.hlp +++ b/templates/CRM/Twingle/Form/Profile.hlp @@ -12,6 +12,7 @@ | written permission from the original author(s). | +-------------------------------------------------------------*} +{crmScope extensionKey='de.systopia.twingle'} {htxt id='id-location_type_id'} {ts domain="de.systopia.twingle"}Select which location type to use for addresses for individuals, either when no organisation name is specified, or an organisation address can not be shared with the individual contact.{/ts} {/htxt} @@ -55,9 +56,9 @@ {/htxt} {htxt id='id-required_address_components'} -
{ts domain="de.systopia.twingle"}Select the address components that must be present to create a new address for the contact.{/ts}
-{ts domain="de.systopia.twingle"}Depending on your XCM settings, the newly transferred address will replace the old one. This behavior may be intentional, as you always want to have the most current address.{/ts}
-{ts domain="de.systopia.twingle"}ATTENTION: In some cases Twingle sends only the country of the user. If no other address components are selected in the required address components, the current user address will be overwritten with an address containing only the country, depending on the XCM settings.{/ts}
+{ts}Select the address components that must be present to create or update an address for the contact.{/ts}
+{ts}Depending on your XCM settings, the transferred address might replace an existing one.{/ts}
+{ts}Since in some cases Twingle send the country of the user as the only address parameter, depending on your XCM configuration, not declaring other address components as required might lead to the current user address being overwritten with an address containing the country only.{/ts}
{/htxt} {htxt id='id-custom_field_mapping'} @@ -74,3 +75,4 @@