[#28] Add parameter for preferred language and pass to XCM

This commit is contained in:
Jens Schuppe 2020-06-04 14:21:06 +02:00
parent ceb1f5a753
commit 36a756e4dd
2 changed files with 16 additions and 0 deletions

View file

@ -177,6 +177,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.
$contact_data['contact_type'] = $contact_type;
$contact = civicrm_api3('Contact', 'getorcreate', $contact_data);

View file

@ -224,6 +224,13 @@ function _civicrm_api3_twingle_donation_Submit_spec(&$params) {
'api.required' => 0,
'description' => E::ts('The company of the contact.'),
);
$params['user_extrafield'] = 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(
'name' => 'user_extrafield',
'title' => E::ts('User extra field'),
@ -376,6 +383,7 @@ function civicrm_api3_twingle_donation_Submit($params) {
'user_birthdate' => 'birth_date',
'user_email' => 'email',
'user_telephone' => 'phone',
'user_language' => 'preferred_language',
'user_title' => 'formal_title',
'debit_iban' => 'iban',
) as $contact_param => $contact_component) {