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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ccourtne’s picture

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.

Robin Monks’s picture

Any progress on that patch?

ccourtne’s picture

Status: Active » Needs review
FileSize
2.59 KB

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

Robin Monks’s picture

Style looks good, +1

Robin

ccourtne’s picture

Version: » 4.7.0-beta3
FileSize
2.56 KB

Updating to beta3 and re-rolled patch.

killes@www.drop.org’s picture

Version: 4.7.0-beta3 » x.y.z
Priority: Critical » Normal
FileSize
2.65 KB

re-rolled from base dir without tabs...

Robrecht Jacques’s picture

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.

Anonymous’s picture

Status: Fixed » Closed (fixed)