role_theme_switcher.module in Role Theme Switcher 6
File
role_theme_switcher.module
View source
<?php
function role_theme_switcher_init() {
global $user, $custom_theme;
foreach ($user->roles as $id => $role) {
$role_theme = variable_get('role_theme_switcher_' . $id . '_theme', '');
if ($role_theme != 'Default') {
$user->theme = $role_theme;
$custom_theme = $role_theme;
}
}
}
function role_theme_switcher_menu() {
$items['admin/user/themes'] = array(
'type' => MENU_NORMAL_ITEM,
'title' => 'Role theme switcher',
'description' => 'Settings for role theme switcher.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'role_theme_switcher_admin_settings',
),
'access arguments' => array(
'administer site configuration',
),
);
return $items;
}
function role_theme_switcher_admin_settings() {
$roles = user_roles();
$themes = list_themes();
$themes_list = array_merge(array(
'Default',
), array_keys($themes));
foreach ($roles as $id => $role) {
$form['role_theme_switcher_' . $id . '_theme'] = array(
'#type' => 'select',
'#title' => ucfirst(strtolower($role)),
'#options' => drupal_map_assoc($themes_list),
'#default_value' => variable_get('role_theme_switcher_' . $id . '_theme', ''),
);
}
return system_settings_form($form);
}