Mwalker has submitted this change and it was merged.
Change subject: Country lookup now accept full (english) name
......................................................................
Country lookup now accept full (english) name
Change-Id: I774c386a3e2e2f251e3f201144b3f42e9e51f589
---
M sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module
1 file changed, 22 insertions(+), 19 deletions(-)
Approvals:
Mwalker: Verified; Looks good to me, approved
diff --git a/sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module
b/sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module
index feecf7d..7b26585 100644
--- a/sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_common/wmf_civicrm/wmf_civicrm.module
@@ -817,26 +817,29 @@
return $default_location_type->id;
}
-function wmf_civicrm_get_country_id( $code ) {
- // Outside chance this could be a lang_COUNTRY pair
- $locality = explode( '_', $code );
- if ( count( $locality ) > 1 ) {
- $code = $locality[ 1 ];
- }
+function wmf_civicrm_get_country_id( $raw ) {
+ // ISO code, or outside chance this could be a lang_COUNTRY pair
+ if ( preg_match( '/^([a-z]+_)?([A-Z]{2})$/', $raw, $matches ) ) {
+ $code = $matches[2];
- // Assume this is an iso code
- if ( strlen( $code ) == 2 ) {
- $iso_cache = CRM_Core_PseudoConstant::countryIsoCode();
- $id = array_search( strtoupper( $code ), $iso_cache );
- if ( $id !== FALSE ) {
- return $id;
- }
- }
- watchdog( 'wmf_civicrm',
- "Cannot find country: [%code]",
- array( '%code' => $code ),
- WATCHDOG_NOTICE
- );
+ $iso_cache = CRM_Core_PseudoConstant::countryIsoCode();
+ $id = array_search( strtoupper( $code ), $iso_cache );
+ if ( $id !== FALSE ) {
+ return $id;
+ }
+ } else {
+ $country_cache = CRM_Core_PseudoConstant::country( false, false
);
+ $id = array_search( $raw, $country_cache );
+ if ( $id !== false ) {
+ return $id;
+ }
+ }
+
+ watchdog( 'wmf_civicrm',
+ "Cannot find country: [%txt]",
+ array( '%txt' => $raw ),
+ WATCHDOG_NOTICE
+ );
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/52539
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I774c386a3e2e2f251e3f201144b3f42e9e51f589
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/civicrm
Gerrit-Branch: master
Gerrit-Owner: Adamw <[email protected]>
Gerrit-Reviewer: Mwalker <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits