Default on theme no longer changes existing users

ccourtne - October 25, 2005 - 19:04
Project:Drupal
Version:x.y.z
Component:theme system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

If a user updates there profile it save an actual theme name instead of leaving it blank for the default. This means it's no longer possible for a user to "follow the default" if they select the default theme in their user profile. The following orphan code used to fix this scenario, but has been orphaned by the form api changes.

    // Reset to follow site default theme if user selects the site default
    if ($key == variable_get('theme_default', 'bluemarine')) {
      $key = '';
      if ($edit['theme'] == variable_get('theme_default', 'bluemarine')) {
        $edit['theme'] = '';
      }
    }

    foreach ($themes as $info) {
      $info->screenshot = dirname($info->filename) . '/screenshot.png';
      $screenshot = file_exists($info->screenshot) ? theme('image', $info->screenshot, t('Screenshot for %theme theme', array('%theme' => $info->name)), '', array('class' => 'screenshot'), false) : t('no screenshot');

      $form['themes'][$info->name]['screenshot'] = array('#type' => 'markup', '#value' => $screenshot);
      $form['themes'][$info->name]['description'] = array('#type' => 'item', '#title' => $info->name,  '#value' => dirname($info->filename));
      $options[$info->name] = '';
    }
    $form['themes']['theme'] = array('#type' => 'radios', '#options' => $options, '#default_value' => $edit['theme'] ? $edit['theme'] : variable_get('theme_default', 'bluemarine'));

This should be moved inside the for loop and used to set the values for the options box. Here is the code as it should look with the new forms api.

    foreach ($themes as $info) {
      // Reset to follow site default theme if user selects the site default
      if ($info->name == variable_get('theme_default', 'bluemarine')) {
        $key = '';
        if ($edit['theme'] == variable_get('theme_default', 'bluemarine')) {
          $edit['theme'] = '';
        }
      }
      else {
        $key = $info->name;
      }

      $info->screenshot = dirname($info->filename) . '/screenshot.png';
      $screenshot = file_exists($info->screenshot) ? theme('image', $info->screenshot, t('Screenshot for %theme theme', array('%theme' => $info->name)), '', array('class' => 'screenshot'), false) : t('no screenshot');

      $form['themes'][$info->name]['screenshot'] = array('#type' => 'markup', '#value' => $screenshot);
      $form['themes'][$info->name]['description'] = array('#type' => 'item', '#title' => $info->name,  '#value' => dirname($info->filename));
      $options[$key] = $info->name;
    }
    $form['themes']['theme'] = array('#type' => 'radios', '#options' => $options, '#default_value' => $edit['theme'] ? $edit['theme'] : '');

Unfortunatly this exposes a bug in the form api. I will submit a proper patch once the form api handles this correctly.

#1

ccourtne - October 25, 2005 - 19:07

Some clarification the changes above are in the system_user function inside system.module. And the related bug filed against the form api is node/35227.

#2

Robin Monks - October 30, 2005 - 19:11

Any progress on that patch?

#3

ccourtne - October 30, 2005 - 23:46
Status:active» needs review

The related bug seems to have been fixed in HEAD so here is the patch.

AttachmentSize
defaultheme.patch 2.59 KB

#4

Robin Monks - November 1, 2005 - 23:56

Style looks good, +1

Robin

#5

ccourtne - January 10, 2006 - 23:51
Version:<none>» 4.7.0-beta3

Updating to beta3 and re-rolled patch.

AttachmentSize
defaultheme1.patch 2.56 KB

#6

killes@www.drop.org - February 1, 2006 - 13:18
Version:4.7.0-beta3» x.y.z
Priority:critical» normal

re-rolled from base dir without tabs...

AttachmentSize
theme_default.patch 2.65 KB

#7

Robrecht Jacques - September 4, 2006 - 18:49
Status:needs review» fixed

This was fixed in system.module v1.313.

Tried it with current CVS/5.0 and when the user selects the default theme, and the admin then changes the default theme, the theme selection of the user will follow that new default.

#8

Anonymous - September 18, 2006 - 19:00
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.