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

Diff of /contributions/modules/switchtheme/switchtheme.module

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

revision 1.16, Sun Aug 2 23:42:11 2009 UTC revision 1.17, Mon Aug 10 23:47:00 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: switchtheme.module,v 1.15 2008/11/02 13:32:46 sun Exp $  // $Id: switchtheme.module,v 1.16 2009/08/02 23:42:11 sun Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 173  function theme_switchtheme_block_form($f Line 173  function theme_switchtheme_block_form($f
173  function switchtheme_switch_form_submit($form, &$form_state) {  function switchtheme_switch_form_submit($form, &$form_state) {
174    global $user;    global $user;
175    
176    if ($user->uid > 0) {    $themes = switchtheme_options();
177      // Save the setting for authenticated users, if the "select different theme"    // Bail out if we do not have a valid theme name.
178      // permission has been granted.    if (empty($form_state['values']['theme']) || !isset($themes[$form_state['values']['theme']])) {
179      if (user_access('select different theme')) {      return;
180        $user = user_save($user, array('theme' => $form_state['values']['theme']));    }
181      }    // Save the setting for authenticated users, if the "select different theme"
182      // Otherwise save the setting in the session, just like for anonymous users.    // permission has been granted.
183      else {    if ($user->uid > 0 && user_access('select different theme')) {
184        $_SESSION['custom_theme'] = $form_state['values']['theme'];      $user = user_save($user, array('theme' => $form_state['values']['theme']));
     }  
185    }    }
186      // Otherwise save the setting in the user's session.
187    elseif (user_access('switch theme')) {    elseif (user_access('switch theme')) {
     // Save the setting in the session for anonymous users.  
188      $_SESSION['custom_theme'] = $form_state['values']['theme'];      $_SESSION['custom_theme'] = $form_state['values']['theme'];
189    }    }
190  }  }
# Line 196  function switchtheme_switch_form_submit( Line 195  function switchtheme_switch_form_submit(
195   * @todo Probably should come back here and cache the theme list.   * @todo Probably should come back here and cache the theme list.
196   */   */
197  function switchtheme_options() {  function switchtheme_options() {
   $options = array();  
198    $themes = list_themes();    $themes = list_themes();
199    foreach ($themes as $name => $attr) {    foreach ($themes as $name => $attr) {
200      if ($attr->status) {      if ($attr->status) {
201        $options[] = $attr->name;        $options[$attr->name] = $attr->name;
202      }      }
203    }    }
204    return $options;    return $options;

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

  ViewVC Help
Powered by ViewVC 1.1.2