--- domain_content.admin.inc.orig	Sat Oct 24 18:18:52 2009
+++ domain_content.admin.inc	Sat Feb 06 19:22:40 2010
@@ -105,20 +105,20 @@ function domain_content_list() {
  */
 function domain_content_view($domain_id = NULL, $all_affiliates = FALSE) {
   global $_domain;
-
+  $fake_domain=$_domain;
   // Load the active domain, which is not necessarily the current domain.
   if (!is_null($domain_id) && $domain_id != $_domain['domain_id']) {
-    domain_set_domain($domain_id);
+    $fake_domain=domain_load($domain_id);
   }
 
   $output = '';
   // Override the $_domain global so we can see the appropriate content
   if (!is_null($domain_id)) {
-    $_domain['site_grant'] = FALSE;
-    drupal_set_title(t('Content for !domain', array('!domain' => $_domain['sitename'])));
+    $fake_domain['site_grant'] = FALSE;
+    drupal_set_title(t('Content for !domain', array('!domain' => $fake_domain['sitename'])));
   }
   else if ($all_affiliates) {
-    $_domain['site_grant'] = TRUE;
+    $fake_domain['site_grant'] = TRUE;
     drupal_set_title(t('Content for all affiliate sites'));
   }
 
@@ -128,7 +128,7 @@ function domain_content_view($domain_id 
     $output .= t('<p>The specified domain does not exist.</p>');
     return $output;
   }
-  $output .= domain_content_admin();
+  $output .= domain_content_admin($fake_domain);
   return $output;
 }
 
@@ -138,7 +138,7 @@ function domain_content_view($domain_id 
  * @return
  *  A themed HTML batch content editing form.
  */
-function domain_content_admin() {
+function domain_content_admin($fake_domain=NULL) {
   // Load the form basics for administering nodes.
   include_once drupal_get_path('module', 'node') .'/node.admin.inc';
 
@@ -148,7 +148,7 @@ function domain_content_admin() {
     return drupal_get_form('node_multiple_delete_confirm', $_POST['nodes']);
   }
   // Call the form first, to allow for the form_values array to be populated.
-  $output .= drupal_get_form('domain_content_form');
+  $output .= drupal_get_form('domain_content_form',$fake_domain);
 
   return $output;
 }
@@ -159,10 +159,12 @@ function domain_content_admin() {
  * @return
  *  A form array according to the FormsAPI.
  */
-function domain_content_form($form_state) {
+function domain_content_form($form_state,$fake_domain=NULL) { 
   global $user, $_domain;
-  $filter = node_build_filter_query();
 
+  if (!$fake_domain) $fake_domain=$_domain;
+
+  $filter = node_build_filter_query();
   // Bypass the superuser permissions by forcing an AND on {domain_access}.
   $filter['join'] .= " INNER JOIN {domain_access} dac ON dac.nid = n.nid ";
   $arg = arg(3);
@@ -171,10 +173,10 @@ function domain_content_form($form_state
     // In this case, we must check the domain_id grant.
     // We use intval() here for security, since we are not filtering the query parameter otherwise.
     if (empty($filter['where'])) {
-      $filter['where'] = " WHERE dac.realm = 'domain_id' AND dac.gid = ". intval($_domain['domain_id']) ." ";
+      $filter['where'] = " WHERE dac.realm = 'domain_id' AND dac.gid = ". intval($fake_domain['domain_id']) ." ";
     }
     else {
-      $filter['where'] .= " AND dac.realm = 'domain_id' AND dac.gid = ". intval($_domain['domain_id']) ." ";
+      $filter['where'] .= " AND dac.realm = 'domain_id' AND dac.gid = ". intval($fake_domain['domain_id']) ." ";
     }
   }
   else {
@@ -289,7 +291,7 @@ function domain_content_form($form_state
         '#options' => $options,
         '#required' => FALSE,
         '#description' => t('Select which affiliates can access this content.'),
-        '#default_value' => array(($_domain['domain_id'] == 0) ? -1 : $_domain['domain_id']), // Can't use 0 as a checkbox value.
+        '#default_value' => array(($fake_domain['domain_id'] == 0) ? -1 : $fake_domain['domain_id']), // Can't use 0 as a checkbox value.
       );
       if ($format) {
         $form['domain']['domains']['#multiple'] = TRUE;
