Index: masquerade.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/masquerade/masquerade.module,v
retrieving revision 1.15.2.1
diff -u -r1.15.2.1 masquerade.module
--- contributions/modules/masquerade/masquerade.module	20 Nov 2006 09:38:41 -0000	1.15.2.1
+++ contributions/modules/masquerade/masquerade.module	28 Feb 2008 09:32:53 -0000
@@ -36,13 +36,7 @@
       'callback arguments' => array($default_test_user->uid),
       'access' => !$GLOBALS['masquerading'] && (user_access('masquerade as user') || user_access('masquerade as admin')),
       'type' => MENU_NORMAL_ITEM);
-
-    $items[] = array('path' => 'masquerade/unswitch', 
-      'title' => t('Switch back'),
-      'callback' => 'masquerade_switch_back',
-      'access' => $GLOBALS['masquerading'],
-      'type' => MENU_NORMAL_ITEM);
-
+    
     $items[] = array('path' => 'masquerade/autocomplete',
 	  'title' => t('Masquerade autocomplete'),
       'callback' => 'masquerade_autocomplete',
@@ -56,6 +50,13 @@
       'callback arguments' => 'masquerade_settings',
       'type' => MENU_NORMAL_ITEM,);
   }
+  else {
+    $items[] = array('path' => 'masquerade/unswitch', 
+      'title' => t('Switch back'),
+      'callback' => 'masquerade_switch_back',
+      'access' => $GLOBALS['masquerading'],
+      'type' => MENU_NORMAL_ITEM);
+  }
 
   return $items;
 }
@@ -300,7 +301,7 @@
   drupal_set_message('Browsing site as user: ' . $masqas . '.');
   $user->masquerading = $new_user->uid;
   $user = $new_user;
-  drupal_goto(referer_uri());
+  drupal_goto();
 }
 
 /**
@@ -318,7 +319,7 @@
   $user = user_load(array('uid' => $uid));
   watchdog('masquerade', "User '$user->name' no longer masquerading as '$oldname'.");
   drupal_set_message('Browsing site as user ' . $user->name . '.');
-  drupal_goto(referer_uri());
+  drupal_goto();
 }
 
 function masquerade_autocomplete($string) {
