r77045 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77044‎ | r77045 | r77046 >
Date:00:09, 20 November 2010
Author:awjrichards
Status:deferred
Tags:
Comment:
Enhanced hack to deal with Civi incorrectly determining state names from abbreviations and country
Modified paths:
  • /civicrm/trunk/sites/all/modules/queue2civicrm/queue2civicrm.module (modified) (history)

Diff [purge]

Index: civicrm/trunk/sites/all/modules/queue2civicrm/queue2civicrm.module
@@ -266,7 +266,11 @@
267267 * When passing CiviCRM a state abbreviation, odd things can happen - like getting the right abbreviation, but the wrong state
268268 * So we'll pull back the correct state/province name based off of a user's country/state abbreviation
269269 */
270 - $query = "SELECT s.name AS state_name FROM civicrm_country c, civicrm_state_province s WHERE s.country_id=c.id AND c.name='" . addslashes( $msg['country'] ) . "' AND s.abbreviation='" . addslashes( $msg['state_province'] ) . "'";
 270+ if ( strlen( $msg['country'] ) == 2 ) {
 271+ $query = "SELECT s.name AS state_name FROM civicrm_country c, civicrm_state_province s WHERE s.country_id=c.id AND c.iso_code='" . addslashes( $msg['country'] ) . "' AND s.abbreviation='" . addslashes( $msg['state_province'] ) . "'";
 272+ } else {
 273+ $query = "SELECT s.name AS state_name FROM civicrm_country c, civicrm_state_province s WHERE s.country_id=c.id AND c.name='" . addslashes( $msg['country'] ) . "' AND s.abbreviation='" . addslashes( $msg['state_province'] ) . "'";
 274+ }
271275 $dao = CRM_Core_DAO::executeQuery( $query );
272276 while ( $dao->fetch() ) {
273277 $state = $dao->state_name;

Status & tagging log