/[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.2.2.8, Sun Aug 2 23:42:20 2009 UTC revision 1.2.2.9, Mon Aug 10 23:47:07 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: switchtheme.module,v 1.2.2.7 2008/11/02 13:33:07 sun Exp $  // $Id: switchtheme.module,v 1.2.2.8 2009/08/02 23:42:20 sun Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 111  function switchtheme_display_random_bloc Line 111  function switchtheme_display_random_bloc
111      $theme->screenshot = dirname($theme->filename) .'/screenshot.png';      $theme->screenshot = dirname($theme->filename) .'/screenshot.png';
112      if ($theme->status && file_exists($theme->screenshot)) {      if ($theme->status && file_exists($theme->screenshot)) {
113        // Return the first theme with a screenshot.        // Return the first theme with a screenshot.
114        $output = l("<img src=\"". base_path() ."$theme->screenshot\" alt=\"preview of $theme->name\" />", $_GET['q'], NULL, 'theme='.$theme->name, NULL, FALSE, TRUE);        $output = l("<img src=\"". base_path() ."$theme->screenshot\" alt=\"preview of $theme->name\" />", $_GET['q'], NULL, 'theme='. $theme->name, NULL, FALSE, TRUE);
115        return $output;        return $output;
116      }      }
117    }    }
# Line 147  function theme_switchtheme_block_form($f Line 147  function theme_switchtheme_block_form($f
147  function switchtheme_switch_form_submit($form_id, $form_values) {  function switchtheme_switch_form_submit($form_id, $form_values) {
148    global $user;    global $user;
149    
150    if ($user->uid > 0) {    $themes = switchtheme_options();
151      // Save the setting for authenticated users, if the "select different theme"    // Bail out if we do not have a valid theme name.
152      // permission has been granted.    if (empty($form_values['theme']) || !isset($themes[$form_values['theme']])) {
153      if (user_access('select different theme')) {      return;
154        $user = user_save($user, array('theme' => $form_values['theme']));    }
155      }    // Save the setting for authenticated users, if the "select different theme"
156      // Otherwise save the setting in the session, just like for anonymous users.    // permission has been granted.
157      else {    if ($user->uid > 0 && user_access('select different theme')) {
158        $_SESSION['custom_theme'] = $form_values['theme'];      $user = user_save($user, array('theme' => $form_values['theme']));
     }  
159    }    }
160      // Otherwise save the setting in the user's session.
161    elseif (user_access('switch theme')) {    elseif (user_access('switch theme')) {
     // Save the setting in the session for anonymous users.  
162      $_SESSION['custom_theme'] = $form_values['theme'];      $_SESSION['custom_theme'] = $form_values['theme'];
163    }    }
164  }  }
# Line 170  function switchtheme_switch_form_submit( Line 169  function switchtheme_switch_form_submit(
169   * @todo Probably should come back here and cache the theme list.   * @todo Probably should come back here and cache the theme list.
170   */   */
171  function switchtheme_options() {  function switchtheme_options() {
   $options = array();  
172    $themes = list_themes();    $themes = list_themes();
173    foreach ($themes as $name => $attr) {    foreach ($themes as $name => $attr) {
174      if ($attr->status) {      if ($attr->status) {
175        $options[] = $attr->name;        $options[$attr->name] = $attr->name;
176      }      }
177    }    }
178    return $options;    return $options;

Legend:
Removed from v.1.2.2.8  
changed lines
  Added in v.1.2.2.9

  ViewVC Help
Powered by ViewVC 1.1.2