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
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
The related bug seems to have been fixed in HEAD so here is the patch.
#4
Style looks good, +1
Robin
#5
Updating to beta3 and re-rolled patch.
#6
re-rolled from base dir without tabs...
#7
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