? domain-867934.patch
Index: domain.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain.module,v
retrieving revision 1.134.2.28
diff -u -p -r1.134.2.28 domain.module
--- domain.module	19 Jun 2010 18:57:45 -0000	1.134.2.28
+++ domain.module	29 Jul 2010 02:36:17 -0000
@@ -1223,8 +1223,35 @@ function domain_get_uri($domain) {
  */
 function domain_goto($domain) {
   global $_domain;
+  global $user;
   // We must be on the proper domain, see http://drupal.org/node/186153.
   if ($domain != -1 && $_domain['domain_id'] != $domain['domain_id']) {
+    if ($domain['domain_id'] == 0) {
+      if (   !empty($user->domain_user)
+          && user_access('administer nodes') == FALSE
+          && !in_array($_domain['domain_id'], $user->domain_user)
+              ) {
+        // Do not use domain id = 0 or -1
+        $domain_user = $user->domain_user;
+        unset($domain_user[0]);
+        unset($domain_user[-1]);
+
+        // Generate a list of domains user can access
+        $list = array();
+        foreach ($domain_user as $gid) {
+          $temp_domain = domain_lookup($gid);
+          $list[] = l($temp_domain['sitename'], $temp_domain['path'] . 'user/login');
+        }
+        $list = implode('<br />', $list);
+
+        // tell user how they can access this page
+        drupal_set_message(t('You currently do not have the correct permissions to access this page on this domain. Please login to one of these domains and try again: <br /> !list', array('!list' => $list)));
+        drupal_access_denied();
+        exit;
+      }
+      // Ignore domain_goto request
+      return;
+    }
     $path = domain_get_uri($domain);
     drupal_goto($path);
   }
