Projects ⇒ Bugs ⇒ #922: Theme changing unintentionally ⇒ CPG Dragonfly™ CMS
Bug #922 Theme changing unintentionally
Project: Dragonfly 9.0.3 -> 9.3 Category: My Account
Submitted: Friday, February 23, 2007 (01:20:38) Modified: Sunday, February 25, 2007 (11:29:53)
Status: Closed Assigned to: NanoCaiordo
PHP Version: 4.4.4 HTTPD Server: Apache 1.3

View/Vote Add Comment

by: layingback
Description:
------------
This cause analysis was in response to this Thread

<a href="http://dragonflycms.org/Forums/viewtopic/t=18157.html">Theme automatically changing to default</a>.

Let's say we have an 9.1. site upgraded from 9.0.6.1 with everything at default (this both makes it simple to discuss and reflects the situation on my test site where the error occurred).

The 3 themes such a site would have are cpg-nuke, left-over from 9.0.6.1, default, new with 9.1, and dragonfly, which would be default for the site. Additionally the site would be configured to allow users to change their themes in preferences.

When user goes to My Account > Preferences the Theme: option displays in alphabetical order, ie:
- cpgnuke
- default
- dragonfly

Problem is 'cpgnuke' is showing as the current option and thus as the users current selection even though dragonfly is the default site theme and dragonfly is the user's current theme (if they haven't been into preferences before). Most users have no idea as to the name of their currently displayed theme - Preferences says it's cpg-nuke, they are happy with the theme they are seeing (which is really dragonfly) so leave that field alone and go ahead and set their local time, etc., and click Save. Bingo, their theme is now saved as cpg-nuke!

So now we have the situation whereby a number of new users have changed their theme to cpg-nuke (or default if it's not a 9.0.6.1 upgrade?) unintentionally both on their part and that of the site's admin.

OK, site admin if they become aware of this, can 'resolve' it by changing the Forum option to disallow users from choosing their own theme. This removes the option from Preferences and forces user back to dragonfly theme immediately.

However check in cms_users and those users will still have 'cpg-nuke' sorted as their theme selection. This I think explains how several of us came to have dragonfly as our site's theme but cpg-nuke or default as our (unknowingly) selected user theme. (This bit is conjecture at this point, but what if some code somewhere tests for user's selected theme? Unless it first tests if user is allowed to select themes it will get an erroneous result. Wouldn't this produce the 'sudden' and 'unexplained' theme change?)

Suggestion to prevent this hijacking of user's theme selection against desire of user and of the site admin, is to set the initial selection of the user's theme in Preferences as follows:

If user's cms_users theme field is set, then set that as the selected theme in Preferences, else set the selected theme to be the current default theme for the site (rather than the lowest alpha-order one).
by: NanoCaiordo
Please try using one of these CVS snapshots:

Latest tar.gz
Latest tar.bz2

or apply the following patch
Index: modules/Your_Account/functions.php =================================================================== RCS file: /cvs/html/modules/Your_Account/functions.php,v retrieving revision 9.22 diff -u -r9.22 functions.php --- modules/Your_Account/functions.php 18 Jan 2007 12:06:17 -0000 9.22 +++ modules/Your_Account/functions.php 25 Feb 2007 09:08:04 -0000 @@ -170,7 +170,7 @@ } function ma_formfield($type, $field, $size, $userinfo) { - global $MAIN_CFG, $l10n_dst_regions, $l10n_gmt_regions; + global $MAIN_CFG, $CPG_SESS, $l10n_dst_regions, $l10n_gmt_regions; if ($type == 0) { return '<input type="text" name="'.(($field == 'name')?'realname':$field).'" value="'.htmlprepare($userinfo[$field]).'" class="post" style="width: 200px" size="25" maxlength="'.$size.'" />'; } else if ($type == 1) {
by: NanoCaiordo
This bug has been fixed in the CVS.

Snapshots of the sources are packaged every 6 hours; this change
will be in the next snapshot. You can grab the snapshot at the
Downloads section.

Thank you for the report, and for helping us to make Dragonfly 9.0.3 -> 9.1 better.

Index: modules/Your_Account/functions.php =================================================================== RCS file: /cvs/html/modules/Your_Account/functions.php,v retrieving revision 9.23 diff -u -r9.23 functions.php --- modules/Your_Account/functions.php 25 Feb 2007 09:35:11 -0000 9.23 +++ modules/Your_Account/functions.php 25 Feb 2007 11:25:16 -0000 @@ -202,7 +202,7 @@ } closedir($handle); natcasesort($themelist); - return select_option($field, ((is_user() && !empty($userinfo['theme'])) ? $userinfo['theme'] : $CPG_SESS['theme']), $themelist); + return select_option($field, ((is_user() && !empty($userinfo['theme']) && is_dir('themes/'.$userinfo['theme'])) ? $userinfo['theme'] : $CPG_SESS['theme']), $themelist); } else if ($type == 8) { if ($field == 'user_lang') { return lang_selectbox($userinfo['user_lang'], $field, false);
User Info

Welcome Anonymous



(Register)
Community

Support for DragonflyCMS in a other languages:

Deutsch
Español