Index: modules/overlay/overlay.module =================================================================== RCS file: /cvs/drupal/drupal/modules/overlay/overlay.module,v retrieving revision 1.22 diff -u -p -r1.22 overlay.module --- modules/overlay/overlay.module 13 Jun 2010 05:47:47 -0000 1.22 +++ modules/overlay/overlay.module 24 Jun 2010 16:27:36 -0000 @@ -42,6 +42,10 @@ function overlay_permission() { 'title' => t('Access the administrative overlay'), 'description' => t('View administrative pages in the overlay.'), ), + 'disable overlay' => array( + 'title' => t('Disable the administrative overlay'), + 'description' => t('Allow users to disable the overlay for their account.'), + ), ); } @@ -58,6 +62,27 @@ function overlay_theme() { } /** + * Implements hook_form_FORM_ID_alter(). + */ +function overlay_form_user_profile_form_alter(&$form, &$form_state) { + if ($form['#user_category'] == 'account') { + $account = $form['#user']; + if (user_access('access overlay', $account) && user_access('disable overlay')) { + $form['account']['data'] = array('#tree' => TRUE); + $form['account']['data']['overlay'] = array( + '#type' => 'checkbox', + '#title' => t('Use overlay'), + '#default_value' => isset($account->data['overlay']) ? $account->data['overlay'] : 1, + '#description' => t('Open content creation and administrative pages in an overlay.'), + '#weight' => 10, + ); + return $form; + } + } +} + + +/** * Implements hook_init(). * * Determine whether the current page request is destined to appear in the @@ -67,13 +92,14 @@ function overlay_theme() { */ function overlay_init() { // @todo: custom_theme does not exist anymore. - global $custom_theme; + global $custom_theme, $user; $mode = overlay_get_mode(); // Only act if the user has access to the overlay and a mode was not already // set. Other modules can also enable the overlay directly for other uses. - if (empty($mode) && user_access('access overlay')) { + $use_overlay = user_access('disable overlay') && (!isset($user->data['overlay']) || $user->data['overlay']); + if (empty($mode) && user_access('access overlay') && $use_overlay) { $current_path = current_path(); // After overlay is enabled on the modules page, redirect to // #overlay=admin/modules to actually enable the overlay.