Index: README.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/switchtheme/README.txt,v retrieving revision 1.3.2.3 diff -u -p -r1.3.2.3 README.txt --- README.txt 8 Aug 2008 19:38:51 -0000 1.3.2.3 +++ README.txt 2 Nov 2008 13:26:07 -0000 @@ -33,6 +33,10 @@ None. Enable the user roles are allowed to see the switchtheme block. You may only want authenticated users to see it, for instance. + If the chosen theme should be stored permanently for registered users, please + note that you have to grant the "select different theme" permission in Drupal + core for (selected) user roles of authenticated users. + * Customize the settings in Administer >> Site configuration >> Switchtheme and enable all themes that you want users to choose from. @@ -47,13 +51,13 @@ None. -- NOTES -- The module has been designed to defer to themes created by the Sections module -(http://www.drupal.org/project/section). In other words, if you use the +(http://drupal.org/project/section). In other words, if you use the sections module to create a special theme for the admin section, the switchtheme module will use that theme rather than the individual theme chosen by the user. If you are setting up a lot of themes, you may find the Block Region module -(http://www.drupal.org/project/blockregion) to be a helpful way of setting up +(http://drupal.org/project/blockregion) to be a helpful way of setting up blocks to work the same way across many themes. That will save you the time of setting up every block in every theme. Index: switchtheme.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/switchtheme/switchtheme.module,v retrieving revision 1.10.2.4 diff -u -p -r1.10.2.4 switchtheme.module --- switchtheme.module 2 Nov 2008 12:44:36 -0000 1.10.2.4 +++ switchtheme.module 2 Nov 2008 13:29:17 -0000 @@ -75,20 +75,23 @@ function switchtheme_init() { switchtheme_switch_form_submit('', $form); } // Other modules may already have set $custom_theme, so we actually switch - // the theme only if $custom_theme has not been set yet. - if (isset($_SESSION['custom_theme']) && !isset($custom_theme)) { + // the theme only if $custom_theme has not been set yet, or if we are on + // administrative pages and admin_theme has been set to "System default" + // ('0'). Also note that the chosen theme is stored in the global user + // object for authenticated users; that value is automatically used across + // sessions by Drupal core if the "select different theme" permission has + // been granted. + if (isset($_SESSION['custom_theme']) && (!isset($custom_theme) || $custom_theme === '0')) { $custom_theme = $_SESSION['custom_theme']; } - if (module_exists('browscap')) { - if (variable_get('switchtheme_browser_enabled', FALSE)) { - $browser = browscap_get_browser(); - if (isset($browser['parent'])) { - $parent = trim($browser['parent']); - $browser_theme = variable_get('switchtheme_browser_'. md5($parent), 'default'); - if ($browser_theme != 'default') { - $custom_theme = $browser_theme; - } + if (module_exists('browscap') && variable_get('switchtheme_browser_enabled', FALSE)) { + $browser = browscap_get_browser(); + if (isset($browser['parent'])) { + $parent = trim($browser['parent']); + $browser_theme = variable_get('switchtheme_browser_'. md5($parent), 'default'); + if ($browser_theme != 'default') { + $custom_theme = $browser_theme; } } } @@ -163,18 +166,23 @@ function theme_switchtheme_block_form($f /** * Process a block switchtheme form submission. + * + * We do not validate the input here, because that is done in init_theme() + * already. */ function switchtheme_switch_form_submit($form, &$form_state) { global $user; if ($user->uid > 0) { - // Save the setting in the db for logged in users. - // We do not validate the input here, because that is done in init_theme() - // already. - if (user_save($user, array('theme' => $form_state['values']['theme']))) { - $user->theme = $form_state['values']['theme']; + // Save the setting for authenticated users, if the "select different theme" + // permission has been granted. + if (user_access('select different theme')) { + $user = user_save($user, array('theme' => $form_state['values']['theme'])); + } + // Otherwise save the setting in the session, just like for anonymous users. + else { + $_SESSION['custom_theme'] = $form_state['values']['theme']; } - $_SESSION['custom_theme'] = $form_state['values']['theme']; } elseif (user_access('switch theme')) { // Save the setting in the session for anonymous users.