Index: domain_geolocalization.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain_geolocalization/domain_geolocalization.inc,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 domain_geolocalization.inc
--- domain_geolocalization.inc	3 Nov 2008 17:05:46 -0000	1.1.2.4
+++ domain_geolocalization.inc	11 Feb 2009 23:49:51 -0000
@@ -42,14 +42,14 @@
 /**
  * Build the search block.
  */
-function _domain_geolocalization_search_block($type = 'ahah') {
+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);
 }
 
@@ -93,7 +93,7 @@
 /**
  * Search form.
  */
-function domain_geolocalization_search_form($form_state) {
+function domain_geolocalization_search_form($form_state, $values = array()) {
 
   $form['postalcode'] = array(
     '#type' => 'textfield',
@@ -103,6 +103,11 @@
     '#size' => 15,
   );
 
+  $form['node_id'] = array(
+    '#type' => 'hidden',
+    '#value' => $values['nid'],
+  );
+
   if (!variable_get('domain_geolocalization_use_domain_radius', 0)) {
     // attach search radius parameter
     $form['proximity'] = array(
@@ -131,7 +136,7 @@
     '#type' => 'submit',
     '#value' => t('Search'),
     '#ahah' => array(
-      'path' => 'search/domain/js',
+      'path' => 'search/domain/js/'.$values['nid'],
       'wrapper' => 'domain-search-results',
       'method' => 'replace',
       'effect' => 'fade',
@@ -156,7 +161,7 @@
 /**
  * Static search form.
  */
-function domain_geolocalization_search_static_form($form_state) {
+function domain_geolocalization_search_static_form($form_state, $values = array()) {
   $form['postalcode'] = array(
     '#type' => 'textfield',
     '#title' => t('U.S. Postal Code'),
@@ -206,7 +211,8 @@
   if (!variable_get('domain_geolocalization_use_domain_radius', 0)) {
     $proximity =  '/' . trim($form_state['values']['proximity']);
   }
-  $form_state['redirect'] = 'search/domain/' . trim($form_state['values']['postalcode']) . $proximity;
+  $node_id =  '/' . trim($form_state['values']['node_id']);
+  $form_state['redirect'] = 'search/domain/' . trim($form_state['values']['postalcode']) . $node_id .  $proximity;
 }
 
 /**
Index: domain_geolocalization.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain_geolocalization/domain_geolocalization.module,v
retrieving revision 1.1.2.14
diff -u -r1.1.2.14 domain_geolocalization.module
--- domain_geolocalization.module	20 Nov 2008 18:45:00 -0000	1.1.2.14
+++ domain_geolocalization.module	11 Feb 2009 23:35:23 -0000
@@ -27,10 +27,10 @@
       'arguments' => array('domain' => NULL),
     ),
     'domain_geolocalization_search_results' => array(
-      'arguments' => array('domain' => NULL, 'address' => NULL, 'proximity' => NULL),
+      'arguments' => array('domain' => NULL, 'address' => NULL, 'proximity' => NULL, 'node_id' => NULL),
     ),
     'domain_geolocalization_search_results_js' => array(
-      'arguments' => array('domain' => NULL, 'address' => NULL, 'proximity' => NULL),
+      'arguments' => array('domain' => NULL, 'address' => NULL, 'proximity' => NULL, 'node_id' => NULL),
     ),
     'domain_geolocalization_search_block' => array(
       'arguments' => array('form' => NULL),
@@ -74,11 +74,12 @@
     'file' => 'domain_geolocalization.page.inc',
   );
 
-  $menu['domain-geolocalization/search/form/js'] = array(
+  $menu['domain-geolocalization/search/form/js/%'] = array(
     'title' => 'Javascript Callback Form',
     'type' => MENU_CALLBACK,
     'access arguments' => array('search domains by location'),
     'page callback' => 'domain_geolocalization_search_form_js',
+    'page arguments' => array(4),
     'file' => 'domain_geolocalization.inc',
   );
 
@@ -166,6 +167,13 @@
       }
     case 'view':
       module_load_include('inc', 'domain_geolocalization');
+        $current_node_id = 0;
+        if (arg(0) == 'node' && is_numeric(arg(1))) {
+          $current_node_id = arg(1);
+        }
+        $values = array(
+          'nid' => $current_node_id,
+        );
       switch ($delta) {
         case 0:
           // Different behavior if user default module is enabled.
@@ -193,7 +201,7 @@
 
           $block = array(
             'subject' => t('Search for nearby domains'),
-            'content' => _domain_geolocalization_search_block(),
+            'content' => _domain_geolocalization_search_block('ahah', $values),
           );
           break;
         case 1:
@@ -208,7 +216,7 @@
         case 2:
           $block = array(
           'subject' => t('Search for nearby domains'),
-          'content' => _domain_geolocalization_search_block('static'),
+          'content' => _domain_geolocalization_search_block('static', $values),
         );
         break;
       }
@@ -364,8 +372,9 @@
  *
  * @param Postal Code to search near
  * @param Proximity to search (in miles)
+ * @param Node ID the search originated from
  */
-function domain_geolocalization_search_results($postal_code = FALSE, $proximity = 50, $address) {
+function domain_geolocalization_search_results($postal_code = FALSE, $proximity = 50, $node_id, $address) {
   if (!$postal_code || (!$proximity && !variable_get('domain_geolocalization_use_domain_radius', 0))) {
     // proximity is required if not using the domain radius
     return;
@@ -541,4 +550,4 @@
       $user->domain_geolocalization[$key] = $domain[$key];
     }
   }
-}
+}
\ No newline at end of file
Index: domain_geolocalization.page.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain_geolocalization/domain_geolocalization.page.inc,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 domain_geolocalization.page.inc
--- domain_geolocalization.page.inc	22 Oct 2008 17:38:57 -0000	1.1.2.3
+++ domain_geolocalization.page.inc	11 Feb 2009 23:41:26 -0000
@@ -13,7 +13,8 @@
 function domain_geolocalization_search_page() {
   $values = array(
     'postalcode' => arg(2),
-    'proximity' => arg(3),
+    'nid' => arg(3),
+    'proximity' => arg(4),
   );
 
   module_load_include('inc', 'domain_geolocalization');
@@ -26,7 +27,7 @@
       $results = t('Invalid postal code: @postal', array('@postal' => arg(2)));
     }
     else {
-      $domains = domain_geolocalization_search_results(arg(2), arg(3), $address);
+      $domains = domain_geolocalization_search_results(arg(2), arg(3), arg(4), $address);
 
       if (module_exists('domain_user_default') && count($domains)) {
         // see if the domain should be automatically set
@@ -39,11 +40,12 @@
           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);
+            $node_id = $values['nid'] > 0 ? '/'. $values['nid'] : '';
+            drupal_goto('domain-user-default/set/' . $domain_id . $node_id);
             default:
         }
       }
-      $results =  theme('domain_geolocalization_search_results', $domains, $address, $values['proximity'], 'miles');
+      $results =  theme('domain_geolocalization_search_results', $domains, $address, $values['proximity'], $values['nid'], 'miles');
     }
   }
   // @todo Integrate the Domain User Default search behavior options here, for
@@ -58,6 +60,7 @@
 function domain_geolocalization_search_js() {
   $zip = $_POST['postalcode'];
   $proximity = $_POST['proximity'];
+  $node_id = $_POST['node_id'];
 
   // determine lat/long of zipcode
   module_load_include('inc', 'domain_geolocalization', 'domain_geolocalization.geocode');
@@ -67,7 +70,7 @@
     $results = t('Invalid postal code: @postal', array('@postal' => $zip));
   }
   else {
-    $domains = domain_geolocalization_search_results($zip, $proximity, $address);
+    $domains = domain_geolocalization_search_results($zip, $proximity, $node_id, $address);
 
     if (module_exists('domain_user_default') && count($domains)) {
       // see if the domain should be automatically set
@@ -82,13 +85,13 @@
 	$domain_id = $domains[0]['domain_id'];
 	// @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>';
+	$script = '<script type="text/javascript">location.href="' . url('domain-user-default/set/' . $domain_id . '/'. $node_id, array('absolute' => TRUE)) . '"</script>';
 	return drupal_json(array('status' => TRUE, 'data' => $script, 'set_domain' => $domain_id));
       default:
       }
     }
 
-    $results = theme('domain_geolocalization_search_results_js', $domains, $address, $proximity, 'miles');
+    $results = theme('domain_geolocalization_search_results_js', $domains, $address, $proximity, $node_id, 'miles');
   }
   return drupal_json(array('status' => TRUE, 'data' => $results));
 }
Index: domain_geolocalization.theme.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain_geolocalization/domain_geolocalization.theme.inc,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 domain_geolocalization.theme.inc
--- domain_geolocalization.theme.inc	30 Jul 2008 21:54:09 -0000	1.1.2.5
+++ domain_geolocalization.theme.inc	11 Feb 2009 23:45:27 -0000
@@ -22,9 +22,10 @@
  * @param $domains array of domain arrays
  * @param $address array of address parameters
  * @param $proximity float radius of domains
+ * @param $node_id id of the node localization originated from
  * @return string formatted search results
  */
-function theme_domain_geolocalization_search_results($domains, $address, $proximity, $units) {
+function theme_domain_geolocalization_search_results($domains, $address, $proximity, $node_id, $units) {
   $domain_radius = variable_get('domain_geolocalization_use_domain_radius', 0);
 
   if (empty($domains)) {
@@ -39,16 +40,16 @@
     case DOMAIN_GEOLOCALIZATION_SEARCH_DISPLAY_SWITCH:
       if (module_exists('domain_user_default')) {
 	// Display only a link to switch default domain.
-	$list[] = round($domain['distance'], 2) . ' ' . $units . ': ' . l($domain['sitename'], 'domain-user-default/set/' . $domain['domain_id']);
+	$list[] = round($domain['distance'], 2) . ' ' . $units . ': ' . l($domain['sitename'], 'domain-user-default/set/' . $domain['domain_id'] . '/'. $node_id);
 	break;
       }
       // fall through if module doesn't exist
     case DOMAIN_GEOLOCALIZATION_SEARCH_DISPLAY_BOTH:
       // add user default link if module exists
       if (module_exists('domain_user_default')) {
-	$default_link = ' | ' . l(t('Set as default'), 'domain-user-default/set/' . $domain['domain_id']);
+      $default_link = ' | ' . l(t('Set as default'), 'domain-user-default/set/' . $domain['domain_id'] . '/'. $node_id);
       }
-      
+
       $list[] = round($domain['distance'], 2) . ' ' . $units . ': ' . l($domain['sitename'], domain_get_path($domain)) . $default_link;
       break;
     case DOMAIN_GEOLOCALIZATION_SEARCH_DISPLAY_LINK:
@@ -68,8 +69,8 @@
  * Theme js search results. Default is simply to use normal search
  * results page theme.
  */
-function theme_domain_geolocalization_search_results_js($domains, $address, $proximity, $units) {
-  return theme('domain_geolocalization_search_results', $domains, $address, $proximity, $units);
+function theme_domain_geolocalization_search_results_js($domains, $address, $proximity, $node_id, $units) {
+  return theme('domain_geolocalization_search_results', $domains, $address, $proximity, $node_id, $units);
 }
 
 /**

