Index: modules/overlay/overlay.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay.module,v
retrieving revision 1.31
diff -u -p -r1.31 overlay.module
--- modules/overlay/overlay.module	31 Aug 2010 15:04:09 -0000	1.31
+++ modules/overlay/overlay.module	15 Sep 2010 20:15:32 -0000
@@ -258,6 +258,42 @@ function overlay_page_alter(&$page) {
     // Add the overlay wrapper before the html wrapper.
     array_unshift($page['#theme_wrappers'], 'overlay');
   }
+  elseif ($link = _overlay_disable_link()) {
+    $page['page_top']['disable_overlay'] = $link;
+  }
+}
+
+/**
+ * Returns a renderable array representing a link to disable the Overlay.
+ *
+ * If the current user can access the overlay, but has not set a preference
+ * regarding the overlay in the user account settings, then this function
+ * returns a link to disable the overlay.
+ */
+function _overlay_disable_link() {
+  global $user;
+
+  $build = array();
+  if ((!isset($user->data['overlay']) || $user->data['overlay']) && user_access('access overlay')) {
+    $build = array(
+      '#type' => 'link',
+      '#title' => t('Administrative pages are configured to open in an overlay window. If you cannot access them, disable the administrative overlay in your account settings.'),
+      '#href' => 'user/' . $user->uid . '/edit',
+      '#options' => array(
+        'query' => drupal_get_destination(),
+        'fragment' => 'edit-overlay-control',
+        'attributes' => array(
+          // Prevent the target page from being opened in the overlay, and make
+          // this link visible for screen-readers only.
+          'class' => array('overlay-exclude', 'element-invisible', 'focusable'),
+        ),
+      ),
+      '#prefix' => '<div id="overlay-disable-link">',
+      '#suffix' => '</div>',
+      '#weight' => -99,
+    );
+  }
+  return $build;
 }
 
 /**
@@ -324,9 +360,9 @@ function overlay_preprocess_maintenance_
  * @see overlay.tpl.php
  */
 function template_preprocess_overlay(&$variables) {
-  $variables['tabs']              = menu_primary_local_tasks();
-  $variables['title']             = drupal_get_title();
-
+  $variables['tabs'] = menu_primary_local_tasks();
+  $variables['title'] = drupal_get_title();
+  $variables['disable_overlay'] = _overlay_disable_link();
   $variables['content_attributes_array']['class'][] = 'clearfix';
 }
 
Index: modules/overlay/overlay.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/overlay/overlay.tpl.php,v
retrieving revision 1.3
diff -u -p -r1.3 overlay.tpl.php
--- modules/overlay/overlay.tpl.php	11 Jul 2010 22:03:45 -0000	1.3
+++ modules/overlay/overlay.tpl.php	15 Sep 2010 20:15:32 -0000
@@ -21,6 +21,7 @@
  */
 ?>
 
+<?php print render($disable_overlay); ?>
 <div id="overlay" <?php print $attributes; ?>>
   <div id="overlay-titlebar" class="clearfix">
     <div id="overlay-title-wrapper" class="clearfix">
