| 1 |
<?php |
<?php |
| 2 |
// $Id: role_theme_switcher.module,v 1.6 2009/02/18 16:56:40 tiutiun Exp $ |
// $Id: role_theme_switcher.module,v 1.6.2.1 2009/02/19 13:39:35 tiutiun Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Implementation of hook_init() |
* Implementation of hook_init() |
| 11 |
foreach ($user->roles as $key => $value) |
foreach ($user->roles as $key => $value) |
| 12 |
{ |
{ |
| 13 |
$role_name = str_replace(' ', '_', $value); |
$role_name = str_replace(' ', '_', $value); |
| 14 |
$role_theme = variable_get(strtolower($role_name) .'_theme', ''); |
$role_theme = variable_get(strtolower($role_name).'_theme', ''); |
| 15 |
|
|
| 16 |
// Change active theme in user object |
// Change active theme in user object |
| 17 |
$user->theme = $role_theme; |
$user->theme = $role_theme; |
| 23 |
} |
} |
| 24 |
|
|
| 25 |
/** |
/** |
| 26 |
* Implementation of hook_menu(). |
* Implementation of hook_menu() |
| 27 |
*/ |
*/ |
| 28 |
function role_theme_switcher_menu() |
function role_theme_switcher_menu() |
| 29 |
{ |
{ |
| 30 |
$items['admin/user/themes'] = array( |
$items['admin/user/themes'] = array( |
| 31 |
'type' => MENU_NORMAL_ITEM, |
'type' => MENU_NORMAL_ITEM, |
| 32 |
'title' => t('Role theme switcher'), |
'title' => 'Role theme switcher', |
| 33 |
'description' => t('Settings for role theme switcher.'), |
'description' => 'Settings for role theme switcher.', |
| 34 |
'page callback' => 'drupal_get_form', |
'page callback' => 'drupal_get_form', |
| 35 |
'page arguments' => array('role_theme_switcher_admin_settings'), |
'page arguments' => array('role_theme_switcher_admin_settings'), |
| 36 |
'access arguments'=> array('administer site configuration'), |
'access arguments'=> array('administer site configuration'), |
| 40 |
} |
} |
| 41 |
|
|
| 42 |
/** |
/** |
| 43 |
* Implemntation of hook_settings(). |
* Implementation of hook_settings() |
| 44 |
*/ |
*/ |
| 45 |
function role_theme_switcher_admin_settings() |
function role_theme_switcher_admin_settings() |
| 46 |
{ |
{ |
| 47 |
$roles = user_roles(); |
$roles = user_roles(); |
| 48 |
// Get all enabled themes |
|
| 49 |
|
// Get all themes |
| 50 |
$themes = list_themes(); |
$themes = list_themes(); |
| 51 |
$list = array_merge(array(t('Default')), array_keys($themes)); |
$list = array_merge(array(t('Default')), array_keys($themes)); |
| 52 |
|
|
| 54 |
{ |
{ |
| 55 |
$role_name = str_replace(' ', '_', $role); |
$role_name = str_replace(' ', '_', $role); |
| 56 |
$form[strtolower($role_name) .'_theme'] = array( |
$form[strtolower($role_name) .'_theme'] = array( |
| 57 |
'#type' => 'select', |
'#type' => 'select', |
| 58 |
'#title' => ucfirst(strtolower($role)), |
'#title' => ucfirst(strtolower($role)), |
| 59 |
'#options' => drupal_map_assoc($list), |
'#options' => drupal_map_assoc($list), |
| 60 |
'#default_value' => variable_get(strtolower($role_name) .'_theme', '') |
'#default_value' => variable_get(strtolower($role_name).'_theme', '') |
| 61 |
); |
); |
| 62 |
} |
} |
| 63 |
|
|