/[drupal]/contributions/modules/role_theme_switcher/role_theme_switcher.module
ViewVC logotype

Diff of /contributions/modules/role_theme_switcher/role_theme_switcher.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.6.2.3, Thu Apr 23 15:21:13 2009 UTC revision 1.6.2.4, Fri Jul 3 14:26:04 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: role_theme_switcher.module,v 1.6.2.2 2009/02/20 10:20:07 tiutiun Exp $  // $Id: role_theme_switcher.module,v 1.6.2.3 2009/04/23 15:21:13 tiutiun Exp $
3    
4  /**  /**
5   * Implementation of hook_init()   * Implementation of hook_init()
# Line 8  function role_theme_switcher_init() Line 8  function role_theme_switcher_init()
8  {  {
9    global $user, $custom_theme;    global $user, $custom_theme;
10    
11    foreach ($user->roles as $key => $value)    foreach ($user->roles as $id => $role)
12    {    {
13      $role_name  = str_replace(' ', '_', $value);      $role_theme = variable_get('role_theme_switcher_'.$id.'_theme', '');
     $role_theme = variable_get(strtolower($role_name).'_theme', '');  
14    
15      // Change active theme in user object      // Change active theme in user object
16      $user->theme = $role_theme;      $user->theme = $role_theme;
# Line 26  function role_theme_switcher_init() Line 25  function role_theme_switcher_init()
25   */   */
26  function role_theme_switcher_menu()  function role_theme_switcher_menu()
27  {  {
28      $items['admin/user/themes'] = array(    $items['admin/user/themes'] = array(
29        'type'            => MENU_NORMAL_ITEM,      'type'            => MENU_NORMAL_ITEM,
30        'title'           => 'Role theme switcher',      'title'           => 'Role theme switcher',
31        'description'     => 'Settings for role theme switcher.',      'description'     => 'Settings for role theme switcher.',
32        'page callback'   => 'drupal_get_form',      'page callback'   => 'drupal_get_form',
33        'page arguments'  => array('role_theme_switcher_admin_settings'),      'page arguments'  => array('role_theme_switcher_admin_settings'),
34        'access arguments'=> array('administer site configuration'),      'access arguments'=> array('administer site configuration'),
35      );    );
36    
37    return $items;    return $items;
38  }  }
# Line 47  function role_theme_switcher_admin_setti Line 46  function role_theme_switcher_admin_setti
46    
47    // Get all themes    // Get all themes
48    $themes = list_themes();    $themes = list_themes();
49    $list = array_merge(array(t('Default')), array_keys($themes));    $themes_list = array_merge(array(t('Default')), array_keys($themes));
50    
51    foreach ($roles as $id => $role)    foreach ($roles as $id => $role)
52    {    {
53      $role_name = str_replace(' ', '_', $role);      $form['role_theme_switcher_'.$id.'_theme'] = array(
     $form[strtolower($role_name) .'_theme'] = array(  
54         '#type'          => 'select',         '#type'          => 'select',
55         '#title'         => ucfirst(strtolower($role)),         '#title'         => ucfirst(strtolower($role)),
56         '#options'       => drupal_map_assoc($list),         '#options'       => drupal_map_assoc($themes_list),
57         '#default_value' => variable_get(strtolower($role_name).'_theme', '')         '#default_value' => variable_get('role_theme_switcher_'.$id.'_theme', '')
58      );      );
59    }    }
60    

Legend:
Removed from v.1.6.2.3  
changed lines
  Added in v.1.6.2.4

  ViewVC Help
Powered by ViewVC 1.1.2