Merge branch 'issue/28'

[#28] Add parameter for preferred language
This commit is contained in:
Jens Schuppe 2022-05-02 15:25:10 +02:00
commit 1c649ba812
3 changed files with 18 additions and 1 deletions

View file

@ -200,6 +200,14 @@ class CRM_Twingle_Submission {
} }
} }
// Prepare values: language.
if (!empty($contact_data['preferred_language'])) {
$mapping = CRM_Core_I18n_PseudoConstant::longForShortMapping();
// Override the default mapping for German.
$mapping['de'] = 'de_DE';
$contact_data['preferred_language'] = $mapping[$contact_data['preferred_language']];
}
// Pass to XCM. // Pass to XCM.
$contact_data['contact_type'] = $contact_type; $contact_data['contact_type'] = $contact_type;
$contact = civicrm_api3('Contact', 'getorcreate', $contact_data); $contact = civicrm_api3('Contact', 'getorcreate', $contact_data);

View file

@ -113,10 +113,11 @@ The action accepts the following parameters:
| <nobr>`user_street`</nobr> | String | The street address of the contact | | | | <nobr>`user_street`</nobr> | String | The street address of the contact | | |
| <nobr>`user_postal_code`</nobr> | String | The postal code of the contact | | | | <nobr>`user_postal_code`</nobr> | String | The postal code of the contact | | |
| <nobr>`user_city`</nobr> | String | The city of the contact | | | | <nobr>`user_city`</nobr> | String | The city of the contact | | |
| <nobr>`user_country`</nobr> | String | The country of the contact | [ISO 3166-1 Alpha-2 country codes](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) | | | <nobr>`user_country`</nobr> | String | The country of the contact | A [ISO 3166-1 Alpha-2 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) | |
| <nobr>`user_telephone`</nobr> | String | The telephone number of the contact | | | | <nobr>`user_telephone`</nobr> | String | The telephone number of the contact | | |
| <nobr>`user_company`</nobr> | String | The company of the contact | | | | <nobr>`user_company`</nobr> | String | The company of the contact | | |
| <nobr>`user_extrafield`</nobr> | String | Additional information of the contact | | | | <nobr>`user_extrafield`</nobr> | String | Additional information of the contact | | |
| <nobr>`user_language`</nobr> | String | The preferred language of the contact. | A [ISO-639-1 2-digit language code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) | |
| <nobr>`campaign_id`</nobr> | Integer | The CiviCRM ID of a campaign to assign the contribution | A valid CiviCRM Campaign ID. This overrides the campaign ID configured within the profile. | | | <nobr>`campaign_id`</nobr> | Integer | The CiviCRM ID of a campaign to assign the contribution | A valid CiviCRM Campaign ID. This overrides the campaign ID configured within the profile. | |
You may also refer to You may also refer to

View file

@ -224,6 +224,13 @@ function _civicrm_api3_twingle_donation_Submit_spec(&$params) {
'api.required' => 0, 'api.required' => 0,
'description' => E::ts('The company of the contact.'), 'description' => E::ts('The company of the contact.'),
); );
$params['user_language'] = array(
'name' => 'user_language',
'title' => E::ts('Language'),
'type' => CRM_Utils_Type::T_STRING,
'api.required' => 0,
'description' => E::ts('The preferred language of the contact. A 2-digit ISO-639-1 language code.'),
);
$params['user_extrafield'] = array( $params['user_extrafield'] = array(
'name' => 'user_extrafield', 'name' => 'user_extrafield',
'title' => E::ts('User extra field'), 'title' => E::ts('User extra field'),
@ -393,6 +400,7 @@ function civicrm_api3_twingle_donation_Submit($params) {
'user_birthdate' => 'birth_date', 'user_birthdate' => 'birth_date',
'user_email' => 'email', 'user_email' => 'email',
'user_telephone' => 'phone', 'user_telephone' => 'phone',
'user_language' => 'preferred_language',
'user_title' => 'formal_title', 'user_title' => 'formal_title',
'debit_iban' => 'iban', 'debit_iban' => 'iban',
) as $contact_param => $contact_component) { ) as $contact_param => $contact_component) {