Awight has uploaded a new change for review.
https://gerrit.wikimedia.org/r/220629
Change subject: WIP Import name prefix and suffix
......................................................................
WIP Import name prefix and suffix
Bug: T88836
Change-Id: I4bffaafb924e56ffc2b346ae90d4c6b18d050a06
---
M sites/all/modules/wmf_civicrm/tests/phpunit/ImportMessageTest.php
M sites/all/modules/wmf_civicrm/wmf_civicrm.module
2 files changed, 38 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm
refs/changes/29/220629/1
diff --git a/sites/all/modules/wmf_civicrm/tests/phpunit/ImportMessageTest.php
b/sites/all/modules/wmf_civicrm/tests/phpunit/ImportMessageTest.php
index e6a56aa..4f24a86 100644
--- a/sites/all/modules/wmf_civicrm/tests/phpunit/ImportMessageTest.php
+++ b/sites/all/modules/wmf_civicrm/tests/phpunit/ImportMessageTest.php
@@ -78,6 +78,8 @@
$gateway_txn_id = mt_rand();
$check_number = (string) mt_rand();
+ $new_prefix = 'M' . mt_rand();
+
return array(
// Minimal contribution
array(
@@ -146,6 +148,8 @@
'last_name' => 'Last',
'middle_name' => 'Middle',
'no_thank_you' => 'no forwarding address',
+ 'name_prefix' => $new_prefix,
+ 'name_suffix' => 'Sr.',
'payment_method' => 'check',
'stock_description' => 'Long-winded prolegemenon',
'thankyou_date' => '2012-04-01',
@@ -160,6 +164,8 @@
'is_opt_out' => '1',
'last_name' => 'Last',
'middle_name' => 'Middle',
+ 'prefix' => $new_prefix,
+ 'suffix' => 'Sr.',
),
'contribution' => array(
'address_id' => '',
diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
index f8d65cf..2a3b02a 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
@@ -886,6 +886,38 @@
$contact['display_name'] = $msg['organization_name'];
$contact['organization_name'] = $msg['organization_name'];
}
+ if ( !empty( $msg['name_prefix'] ) ) {
+ $existing_prefixes = array_flip(
CRM_Core_PseudoConstant::individualPrefix() );
+ if ( array_key_exists( $msg['name_prefix'], $existing_prefixes ) ) {
+ $prefix_id = $existing_prefixes[$msg['name_prefix']];
+ } else {
+ $option_group_result = civicrm_api3( 'OptionGroup', 'Get', array(
+ 'name' => 'individual_prefix',
+ ) );
+ $result = civicrm_api3( 'OptionValue', 'Create', array(
+ 'option_group_id' => $option_group_result['id'],
+ 'name' => $msg['name_prefix'],
+ ) );
+ $prefix_id = $result['id'];
+ }
+ $contact['prefix_id'] = $prefix_id;
+ }
+ if ( !empty( $msg['name_suffix'] ) ) {
+ $existing_suffixes = array_flip(
CRM_Core_PseudoConstant::individualSuffix() );
+ if ( array_key_exists( $msg['name_suffix'], $existing_suffixes ) ) {
+ $suffix_id = $existing_suffixes[$msg['name_suffix']];
+ } else {
+ $option_group_result = civicrm_api3( 'OptionGroup', 'Get', array(
+ 'name' => 'individual_suffix',
+ ) );
+ $result = civicrm_api3( 'OptionValue', 'Create', array(
+ 'option_group_id' => $option_group_result['id'],
+ 'name' => $msg['name_suffix'],
+ ) );
+ $suffix_id = $result['id'];
+ }
+ $contact['suffix_id'] = $suffix_id;
+ }
if ( empty($msg['language']) ) {
// TODO: use LanguageTag to prevent truncation of >2 char lang codes
// guess from contribution_tracking data
--
To view, visit https://gerrit.wikimedia.org/r/220629
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4bffaafb924e56ffc2b346ae90d4c6b18d050a06
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits