Index: README.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/switchtheme/README.txt,v retrieving revision 1.1.4.3 diff -u -p -r1.1.4.3 README.txt --- README.txt 8 Aug 2008 19:38:58 -0000 1.1.4.3 +++ README.txt 2 Nov 2008 13:25:01 -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.2.2.6 diff -u -p -r1.2.2.6 switchtheme.module --- switchtheme.module 2 Nov 2008 12:44:50 -0000 1.2.2.6 +++ switchtheme.module 2 Nov 2008 13:25:44 -0000 @@ -52,8 +52,13 @@ function switchtheme_menu($may_cache) { switchtheme_switch_form_submit('', $form_values); } // 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']; } } @@ -135,18 +140,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_id, $form_values) { 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_values['theme']))) { - $user->theme = $form_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_values['theme'])); + } + // Otherwise save the setting in the session, just like for anonymous users. + else { + $_SESSION['custom_theme'] = $form_values['theme']; } - $_SESSION['custom_theme'] = $form_values['theme']; } elseif (user_access('switch theme')) { // Save the setting in the session for anonymous users.