If you want a new permission called "use admin theme" you can patch the module with these simple modifications:

Step 1: Create a new permission

Modify the admin_perm() function to this:

function admin_perm() {
  return array('use admin toolbar', 'use admin theme');
}

Step 2: Check permission

Add this code to admin_init():

// Use the administrative theme if the user is looking at a page in the admin/* path.
  if (!user_access('use admin theme')) {
    global $custom_theme;
    $custom_theme = variable_get('theme_default','none');;
  }

so that the function looks like this:

/**
 * Implementation of hook_init().
 */
function admin_init() {
  if (arg(0) === 'admin') {
    menu_set_active_menu_name('admin');
  }
  if (user_access('use admin toolbar')) {
    $path = drupal_get_path('module', 'admin');
    drupal_add_js("{$path}/includes/jquery.cookie.js");
    drupal_add_js("{$path}/includes/jquery.drilldown.js");
    drupal_add_js("{$path}/includes/admin.toolbar.js");
    drupal_add_js("{$path}/includes/admin.menu.js");
    drupal_add_css("{$path}/includes/admin.toolbar.base.css");
    drupal_add_css("{$path}/includes/admin.toolbar.css");
    drupal_add_css("{$path}/includes/admin.menu.css");
  }
  
  // Use the administrative theme if the user is looking at a page in the admin/* path.
  if (!user_access('use admin theme')) {
    global $custom_theme;
    $custom_theme = variable_get('theme_default','none');;
  }
}

Comments

jlmeredith’s picture

Great info! Worked like a charm! Thanks for the great code snippet. This should seriously be in the core module.

pixelsweatshop’s picture

+1 for this feature.

thedavidmeister’s picture

thanks for this, works a treat with no nasty side effects afaik :)

made my life a whole lot easier today, as I wanted to give my contributors access to the nice, clean "Rubik" theme for content editing, yet Admin started showing it to users starting new forum topics.

+1 for this feature

patrickroma’s picture

great!

thedavidmeister’s picture

could we get this committed? i'm using it in every second project i'm working on atm.

mkalkbrenner’s picture

This patch is incompatible with theme switching modules like ThemeKey. (see #1169504: Conflict with admin module)

BTW the default theme is 'garland' and not 'none'.

thedavidmeister’s picture

@mkalkbrenner: the default theme is set to 'none' by the Admin module, not this patch so you should open a new issue for that