Index: domain_geolocalization.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain_geolocalization/domain_geolocalization.admin.inc,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 domain_geolocalization.admin.inc
--- domain_geolocalization.admin.inc	8 Jul 2008 23:57:53 -0000	1.1.2.2
+++ domain_geolocalization.admin.inc	28 Sep 2009 18:02:19 -0000
@@ -11,90 +11,91 @@
  * Domain edit/create form.
  */
 function _domain_geolocalization_domain_edit_form(&$form, $form_state, $form_id) {
-  $domain = domain_lookup($form['domain_id']['#value']);
+  if (!empty($form['domain_id']['#value'])) {
+    $domain = domain_lookup($form['domain_id']['#value']);
+    $form['domain_geolocalization'] = array(
+      '#type' => 'fieldset',
+      // set lighter than the submit button
+      '#weight' => 1,
+      '#title' => t('Domain GeoLocalization'),
+      '#description' => t('Associate this domain with a geographic area.<br /><strong>Important</strong>: None of these corresponding fields are verified. Thus it is important that the latitude/longitude are correct for the city, state, country and zipcode entered. The only required fields are latitude and longitude.'),
+      '#collapsible' => TRUE,
+      '#collapsed' => FALSE,
+      '#validate' => '_domain_geolocalization_domain_validate',
+    );
+    $form['domain_geolocalization']['use_geolocalization'] = array(
+      '#type' => 'checkbox',
+      '#default_value' => !is_null($domain['latitude']),
+      '#title' => t('Use Geolocalization for this domain'),
+    );
+    $form['domain_geolocalization']['latitude'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Latitude'),
+      '#default_value' => $domain['latitude'],
+    );
+    $form['domain_geolocalization']['longitude'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Longitude'),
+      '#default_value' => $domain['longitude'],
+    );
+    $form['domain_geolocalization']['radius'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Search Radius'),
+      '#description' => t('Radius of the domain, in miles'),
+      '#default_value' => $domain['radius'],
+    );
 
-  $form['domain_geolocalization'] = array(
-    '#type' => 'fieldset',
-    // set lighter than the submit button
-    '#weight' => 1,
-    '#title' => t('Domain GeoLocalization'),
-    '#description' => t('Associate this domain with a geographic area.<br /><strong>Important</strong>: None of these corresponding fields are verified. Thus it is important that the latitude/longitude are correct for the city, state, country and zipcode entered. The only required fields are latitude and longitude.'),
-    '#collapsible' => TRUE,
-    '#collapsed' => FALSE,
-    '#validate' => '_domain_geolocalization_domain_validate',
-  );
-  $form['domain_geolocalization']['use_geolocalization'] = array(
-    '#type' => 'checkbox',
-    '#default_value' => !is_null($domain['latitude']),
-    '#title' => t('Use Geolocalization for this domain'),
-  );
-  $form['domain_geolocalization']['latitude'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Latitude'),
-    '#default_value' => $domain['latitude'],
-  );
-  $form['domain_geolocalization']['longitude'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Longitude'),
-    '#default_value' => $domain['longitude'],
-  );
-  $form['domain_geolocalization']['radius'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Search Radius'),
-    '#description' => t('Radius of the domain, in miles'),
-    '#default_value' => $domain['radius'],
-  );
-
-  // @fixme: This should integrate with GMaps once it is ported. However, this
-  // will be tricky since we are dealing with subdomains. The Keys API module
-  // would be another good choice for integration. On the other hand, keeping
-  // it here keeps domain adminstration all in one place.
-  $form['domain_geolocalization']['gmap_key'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Google Maps API key'),
-    '#description' => t('Each subdomain requires a !link', array('!link' => l('Google Maps API key', 'http://code.google.com/apis/maps/signup.html'))),
-    '#default_value' => $domain['gmap_key'],
-  );
-
-  $form['domain_geolocalization']['city'] = array(
-    '#type' => 'textfield',
-    '#title' => t('City'),
-    '#default_value' => $domain['city'],
-  );
-
-  $form['domain_geolocalization']['state'] = array(
-    '#type' => 'textfield',
-    '#title' => t('State Code'),
-    '#default_value' => $domain['state'],
-  );
+    // @fixme: This should integrate with GMaps once it is ported. However, this
+    // will be tricky since we are dealing with subdomains. The Keys API module
+    // would be another good choice for integration. On the other hand, keeping
+    // it here keeps domain adminstration all in one place.
+    $form['domain_geolocalization']['gmap_key'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Google Maps API key'),
+      '#description' => t('Each subdomain requires a !link', array('!link' => l(t('Google Maps API key'), 'http://code.google.com/apis/maps/signup.html'))),
+      '#default_value' => $domain['gmap_key'],
+    );
 
-  if (variable_get('domain_geolocalization_use_state_defaults', FALSE)) {
-    $form['domain_geolocalization']['state_default'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Set this domain as the default domain for this state'),
-      '#default_value' => $domain['state_default'],
-      '#description' => t('Only one default may be defined per state'),
+    $form['domain_geolocalization']['city'] = array(
+      '#type' => 'textfield',
+      '#title' => t('City'),
+      '#default_value' => $domain['city'],
     );
-  }
 
-  $form['domain_geolocalization']['zipcode'] = array(
-    '#type' => 'textfield',
-    '#length' => 30,
-    '#title' => t('US Postal Code'),
-    '#default_value' => $domain['zipcode'],
-  );
-
-  $form['domain_geolocalization']['country'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Country'),
-    '#default_value' => $domain['country'],
-  );
+    $form['domain_geolocalization']['state'] = array(
+      '#type' => 'textfield',
+      '#title' => t('State Code'),
+      '#default_value' => $domain['state'],
+    );
 
-  // weigh down the submit button
-  $form['submit']['#weight'] = 10;
+    if (variable_get('domain_geolocalization_use_state_defaults', FALSE)) {
+      $form['domain_geolocalization']['state_default'] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Set this domain as the default domain for this state'),
+        '#default_value' => $domain['state_default'],
+        '#description' => t('Only one default may be defined per state'),
+      );
+    }
 
-  // append custom validation and functions
-  $form['#validate'][] = '_domain_geolocalization_domain_edit_validate';
+    $form['domain_geolocalization']['zipcode'] = array(
+      '#type' => 'textfield',
+      '#length' => 30,
+      '#title' => t('US Postal Code'),
+      '#default_value' => $domain['zipcode'],
+    );
+
+    $form['domain_geolocalization']['country'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Country'),
+      '#default_value' => $domain['country'],
+    );
+
+    // weigh down the submit button
+    $form['submit']['#weight'] = 10;
+
+    // append custom validation and functions
+    $form['#validate'][] = '_domain_geolocalization_domain_edit_validate';
+  }
 }
 
 
@@ -120,10 +121,10 @@
       }
       else {
         // check if there is a state default already defined for this state
-	if ($form_state['values']['domain_id']) {
-	  // existing domain, so the query is altered to exclude itself
-	  $alter = ' AND domain_id <> %d';
-	}
+        if ($form_state['values']['domain_id']) {
+          // existing domain, so the query is altered to exclude itself
+          $alter = ' AND domain_id <> %d';
+        }
         $existing = db_result(db_query("SELECT domain_id FROM {domain_geolocalization} LEFT JOIN {domain_geolocalization_location_instance} USING (domain_id) LEFT JOIN {domain_geolocalization_location} USING (dglid) WHERE state = '%s' AND state_default" . $alter, $form_state['values']['state'], $form_state['values']['domain_id']));
         if ($existing) {
           $domain = domain_lookup($existing);
Index: domain_geolocalization.geocode.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain_geolocalization/domain_geolocalization.geocode.inc,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 domain_geolocalization.geocode.inc
--- domain_geolocalization.geocode.inc	11 Jul 2008 17:34:23 -0000	1.1.2.2
+++ domain_geolocalization.geocode.inc	28 Sep 2009 18:03:17 -0000
@@ -32,7 +32,7 @@
     $range_longitude = earth_longitude_range($longitude, $latitude, $proximity);
 
     $result = db_query('SELECT domain_id, ' . $earth_distance . ' AS distance FROM {domain_geolocalization} LEFT JOIN {domain} USING (domain_id) LEFT JOIN {domain_geolocalization_location_instance} USING (domain_id) LEFT JOIN {domain_geolocalization_location} USING (dglid) WHERE valid AND latitude > %f AND latitude < %f AND longitude > %f AND longitude < %f AND ' . $earth_distance . ' < %f ORDER BY distance', 
-      $range_latitude[0], $range_latitude[1], $range_longitude[0], $range_longitude[1], $proximity);
+    $range_latitude[0], $range_latitude[1], $range_longitude[0], $range_longitude[1], $proximity);
   }
   else {
     $radius_sql = _domain_geolocalization_convert_to_meters_sql('radius', 'miles');
Index: domain_geolocalization.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain_geolocalization/domain_geolocalization.inc,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 domain_geolocalization.inc
--- domain_geolocalization.inc	12 Jun 2009 00:31:01 -0000	1.1.2.5
+++ domain_geolocalization.inc	28 Sep 2009 18:04:03 -0000
@@ -42,14 +42,15 @@
 /**
  * Build the search block.
  */
-function _domain_geolocalization_search_block($type = 'ahah') {
-  if($type == 'static') {
+function _domain_geolocalization_search_block($type = 'ahah', $values) {
+  if ($type == 'static') {
     $formid = 'domain_geolocalization_search_static_form';
   }
   else {
     $formid = 'domain_geolocalization_search_form';
   }
-  $form = drupal_get_form($formid);
+
+  $form = drupal_get_form($formid, $values);
   return theme('domain_geolocalization_search_block', $form);
 }
 
@@ -136,7 +137,7 @@
     '#type' => 'submit',
     '#value' => t('Search'),
     '#ahah' => array(
-      'path' => 'search/domain/js/'.$values['node_id'],
+      'path' => 'search/domain/js/'. $values['node_id'],
       'wrapper' => 'domain-search-results',
       'method' => 'replace',
       'effect' => 'fade',
Index: domain_geolocalization.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain_geolocalization/domain_geolocalization.module,v
retrieving revision 1.1.2.15
diff -u -r1.1.2.15 domain_geolocalization.module
--- domain_geolocalization.module	12 Jun 2009 00:31:01 -0000	1.1.2.15
+++ domain_geolocalization.module	28 Sep 2009 17:58:58 -0000
@@ -124,7 +124,7 @@
   switch ($op) {
     case 'list':
       if (module_exists('domain_user_default')) {
-        $user_default = t(' (or current default domain when user has selected one)');
+        $user_default = ' '. t('(or current default domain when user has selected one)');
         // Can't cache per role once the block is customized per user
         // @todo determine if there is a way to clear the block cache when a
         // user switches domains.
@@ -183,7 +183,7 @@
 
           if (module_exists('domain_user_default') && (isset($account->default_domain) || variable_get('domain_geolocalization_block_use_default_domain', FALSE))) {
             // if user has a default, output a simple domain name and a change link
-            if(isset($account->default_domain) && $account->default_domain == $_domain['domain_id']) {
+            if (isset($account->default_domain) && $account->default_domain == $_domain['domain_id']) {
               $current_domain = $account->default_domain;
             }
             else {
Index: tests/domain_geolocalization.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain_geolocalization/tests/domain_geolocalization.test,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 domain_geolocalization.test
--- tests/domain_geolocalization.test	3 Jul 2008 20:07:28 -0000	1.1.2.1
+++ tests/domain_geolocalization.test	28 Sep 2009 17:57:28 -0000
@@ -35,15 +35,15 @@
     foreach ($tests as $distance) {
       $units = $distance[0];
       $length = $distance[1];
-      $actual_miles = round($distance[2],3);
+      $actual_miles = round($distance[2], 3);
       $actual_meters = round($distance[3], 3);
 
       // convert to miles
-      $miles = round(_domain_geolocalization_convert_to_miles($length, $units),3);
+      $miles = round(_domain_geolocalization_convert_to_miles($length, $units), 3);
       $this->assertTrue($miles === $actual_miles, t('Correctly converted @len @unit to @alen miles (@conv)', array('@len' => $length, '@unit' => $units, '@alen' => $actual_miles, '@conv' => $miles)));
 
       // convert to meters
-      $meters = round(_domain_geolocalization_convert_to_meters($length, $units),3);
+      $meters = round(_domain_geolocalization_convert_to_meters($length, $units), 3);
       $this->assertTrue($meters === $actual_meters, t('Correctly converted @len @unit to @alen meters (@conv)', array('@len' => $length, '@unit' => $units, '@alen' => $actual_meters, '@conv' => $meters)));
     }
 

