From 58a8be92bc8fe2dd5316810ba92d3a8f8cdb1f33 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 28 Jul 2010 02:50:00 +0000 Subject: [PATCH] - Patch #659480 by mgifford, David_Rothstein, aaronbauman, Jody Lynn, casey, cwgordon7: added per-user setting for the overlay. --- modules/overlay/overlay.module | 38 +++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/modules/overlay/overlay.module b/modules/overlay/overlay.module index 13e32f1b698..5537ddf0e13 100644 --- a/modules/overlay/overlay.module +++ b/modules/overlay/overlay.module @@ -57,6 +57,39 @@ 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)) { + $form['overlay_control'] = array( + '#type' => 'fieldset', + '#title' => t('Administrative overlay'), + '#weight' => 4, + '#collapsible' => TRUE, + ); + + $form['overlay_control']['overlay'] = array( + '#type' => 'checkbox', + '#title' => t('Use the overlay for administrative pages.'), + '#description' => t('Show administrative pages on top of the page you started from.'), + '#default_value' => isset($account->data['overlay']) ? $account->data['overlay'] : 1, + ); + } + } +} + +/** + * Implements hook_user_presave(). + */ +function overlay_user_presave(&$edit, $account, $category) { + if (isset($edit['overlay'])) { + $edit['data']['overlay'] = $edit['overlay']; + } +} + /** * Implements hook_init(). * @@ -66,11 +99,14 @@ function overlay_theme() { * @see overlay_set_mode() */ function overlay_init() { + global $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 = !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.