http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72334

Revision: 72334
Author:   awjrichards
Date:     2010-09-03 23:17:51 +0000 (Fri, 03 Sep 2010)

Log Message:
-----------
Part of a fix to bug 25032 where CiviCRM would apply incorrect state to a user 
making a transaction

Modified Paths:
--------------
    civicrm/trunk/sites/all/modules/queue2civicrm/queue2civicrm.module

Modified: civicrm/trunk/sites/all/modules/queue2civicrm/queue2civicrm.module
===================================================================
--- civicrm/trunk/sites/all/modules/queue2civicrm/queue2civicrm.module  
2010-09-03 23:17:32 UTC (rev 72333)
+++ civicrm/trunk/sites/all/modules/queue2civicrm/queue2civicrm.module  
2010-09-03 23:17:51 UTC (rev 72334)
@@ -256,15 +256,26 @@
        $contact['display_name'] = trim($contact['first_name'] . ' ' . 
$contact['last_name']);
        $contact_result = &civicrm_contact_add( $contact );
        $contact['id'] = $contact_result['contact_id'];
-       
-       // Insert the location record
+
+
+  /**
+   * When passing CiviCRM a state abbreviation, odd things can happen - like 
getting the right abbreviation, but the wrong state
+   * So we'll pull back the correct state/province name based off of a user's 
country/state abbreviation
+   */
+  $query = "SELECT s.name AS state_name FROM civicrm_country c, 
civicrm_state_province s WHERE s.country_id=c.id AND c.name='" . 
$msg['country'] . "' AND s.abbreviation='" . $msg['state_province'] . "'";
+  $dao = CRM_Core_DAO::executeQuery( $query );
+  while ( $dao->fetch() ) {
+    $state = $dao->state_name;
+  }
+  
+  // Insert the location record
        $address = array(
                'contact_id' => $contact['id'],
                'location_type' => 'Home',
                'street_address' => $msg['street_address'],
                'supplemental_address_1' => $msg['supplemental_address_1'],
                'city' => $msg['city'],
-               'state_province' => $msg['state_province'],
+               'state_province' => ( !is_null( $state )) ? $state : 
$msg['state_province'],
                'postal_code' => $msg['postal_code'],
                'country' => $msg['country'],
                'is_primary' => 1,
@@ -272,7 +283,8 @@
                'email' => $msg['email']
                );
        $location_result = &civicrm_location_add( $address );
-       
+
+
        // Insert the contribution record
        $contribution = array(
                'contact_id' => $contact['id'],



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to