Download & Extend

Default on theme no longer changes existing users

Project:Drupal core
Version:x.y.z
Component:theme system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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.

Comments

#1

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

Any progress on that patch?

#3

Status:active» needs review

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

AttachmentSizeStatusTest resultOperations
defaultheme.patch2.59 KBIgnored: Check issue status.NoneNone

#4

Style looks good, +1

Robin

#5

Version:<none>» 4.7.0-beta3

Updating to beta3 and re-rolled patch.

AttachmentSizeStatusTest resultOperations
defaultheme1.patch2.56 KBIgnored: Check issue status.NoneNone

#6

Version:4.7.0-beta3» x.y.z
Priority:critical» normal

re-rolled from base dir without tabs...

AttachmentSizeStatusTest resultOperations
theme_default.patch2.65 KBIgnored: Check issue status.NoneNone

#7

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

Status:fixed» closed (fixed)