Index: domain_geolocalization.page.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain_geolocalization/domain_geolocalization.page.inc,v
retrieving revision 1.3
diff -u -r1.3 domain_geolocalization.page.inc
--- domain_geolocalization.page.inc	11 Jul 2008 17:40:56 -0000	1.3
+++ domain_geolocalization.page.inc	22 Oct 2008 00:26:38 -0000
@@ -18,35 +18,34 @@
 
   module_load_include('inc', 'domain_geolocalization');
   $form = drupal_get_form('domain_geolocalization_search_form', $values);
+  if ($values['postalcode']) {
+    // determine lat/long of zipcode
+    module_load_include('inc', 'domain_geolocalization', 'domain_geolocalization.geocode');
+    $address = _domain_geolocalization_geocode(array('zipcode' => arg(2)));
+    if (!$address['zipcode']) {
+      $results = t('Invalid postal code: @postal', array('@postal' => arg(2)));
+    }
+    else {
+      $domains = domain_geolocalization_search_results(arg(2), arg(3), $address);
 
-  // determine lat/long of zipcode
-  module_load_include('inc', 'domain_geolocalization', 'domain_geolocalization.geocode');
-  $address = _domain_geolocalization_geocode(array('zipcode' => arg(2)));
-  if (!$address['zipcode']) {
-    $results = t('Invalid postal code: @postal', array('@postal' => arg(2)));
-  }
-  else {
-    $domains = domain_geolocalization_search_results(arg(2), arg(3), $address);
-
-    if (module_exists('domain_user_default') && count($domains)) {
-      // see if the domain should be automatically set
-      $auto_set = variable_get('domain_user_default_geolocalization_search_result_behavior', DOMAIN_USER_DEFAULT_GEOLOCALIZATION_AUTO_SET_NEVER);
-      switch ($auto_set) {
-      case DOMAIN_USER_DEFAULT_GEOLOCALIZATION_AUTO_SET_SINGLE:
-	if (count($domains) > 1) {
-	  break;
-	}
-      case DOMAIN_USER_DEFAULT_GEOLOCALIZATION_AUTO_SET_TOP:
-	// At this point, these both behave the same
-	$domain_id = $domains[0]['domain_id'];
-	drupal_goto('domain-user-default/set/' . $domain_id);
-      default:
+      if (module_exists('domain_user_default') && count($domains)) {
+        // see if the domain should be automatically set
+        $auto_set = variable_get('domain_user_default_geolocalization_search_result_behavior', DOMAIN_USER_DEFAULT_GEOLOCALIZATION_AUTO_SET_NEVER);
+        switch ($auto_set) {
+          case DOMAIN_USER_DEFAULT_GEOLOCALIZATION_AUTO_SET_SINGLE:
+            if (count($domains) > 1) {
+              break;
+            }
+          case DOMAIN_USER_DEFAULT_GEOLOCALIZATION_AUTO_SET_TOP:
+            // At this point, these both behave the same
+            $domain_id = $domains[0]['domain_id'];
+            drupal_goto('domain-user-default/set/' . $domain_id);
+            default:
+        }
       }
+      $results =  theme('domain_geolocalization_search_results', $domains, $address, $values['proximity'], 'miles');
     }
-
-    $results =  theme('domain_geolocalization_search_results', $domains, $address, $values['proximity'], 'miles');
   }
-
   // @todo Integrate the Domain User Default search behavior options here, for
   // auto-setting based on results.
 
@@ -84,11 +83,11 @@
 	// @todo find out if there is a way to do this within the
 	// framework of the Drupal Form AHAH handling.
 	$script = '<script type="text/javascript">location.href="' . url('domain-user-default/set/' . $domain_id, array('absolute' => TRUE)) . '"</script>';
-	return drupal_json(array('status' => TRUE, 'data' => $script, 'set_domain' => $domain_id)); 
+	return drupal_json(array('status' => TRUE, 'data' => $script, 'set_domain' => $domain_id));
       default:
       }
     }
-    
+
     $results = theme('domain_geolocalization_search_results_js', $domains, $address, $proximity, 'miles');
   }
   return drupal_json(array('status' => TRUE, 'data' => $results));

