/[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.1, Thu Feb 19 13:39:35 2009 UTC revision 1.6.2.2, Fri Feb 20 10:20:07 2009 UTC
# Line 1  Line 1 
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()
# Line 11  function role_theme_switcher_init() Line 11  function role_theme_switcher_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;
# Line 23  function role_theme_switcher_init() Line 23  function role_theme_switcher_init()
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'),
# Line 40  function role_theme_switcher_menu() Line 40  function role_theme_switcher_menu()
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    
# Line 53  function role_theme_switcher_admin_setti Line 54  function role_theme_switcher_admin_setti
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    

Legend:
Removed from v.1.6.2.1  
changed lines
  Added in v.1.6.2.2

  ViewVC Help
Powered by ViewVC 1.1.2