Ejegg has uploaded a new change for review.
https://gerrit.wikimedia.org/r/319480
Change subject: Fill in missing city and state from US zip code
......................................................................
Fill in missing city and state from US zip code
Bug: T86239
Change-Id: Iea001290d30059c94e63e5179a0e489ccfe5c8ae
---
M sites/all/modules/wmf_civicrm/wmf_civicrm.module
1 file changed, 12 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm
refs/changes/80/319480/1
diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
index 21bfae5..4bfced4 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
@@ -2720,9 +2720,11 @@
$address['country_id'] == $usId &&
!empty( $address['postal_code'] )
) {
- $sql = 'SELECT latitude, longitude, timezone
- FROM wmf_zip_geo
- WHERE zip = %1';
+ $sql = "SELECT city, s.id AS state_id,
latitude, longitude, timezone
+ FROM wmf_zip_geo g
+ JOIN civicrm_state_province s ON
s.abbreviation = g.state
+ AND s.country_id = $usId
+ WHERE zip = %1";
$result = CRM_Core_DAO::executeQuery(
$sql,
@@ -2737,6 +2739,13 @@
'geo_code_2' =>
$result->longitude,
'timezone' => $result->timezone,
);
+ // Only overwrite city and state if
empty
+ if ( empty( $address['city'] ) ) {
+ $geoData['city'] =
$result->city;
+ }
+ if ( $address['state_province_id'] ==
'null' ) {
+ $geoData['state_province_id'] =
$result->state_id;
+ }
}
}
if ( empty( $geoData ) && $op == 'edit' ) {
--
To view, visit https://gerrit.wikimedia.org/r/319480
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iea001290d30059c94e63e5179a0e489ccfe5c8ae
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits