News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

[2.0] Themes and Layouts Member Options

Started by Sorunome, October 31, 2015, 07:50:47 AM

Previous topic - Next topic

Sorunome

Using SMF 2.0.11 when changing the Member Options via "Change current options for all members using this theme" the default ones set in "Configure guest and new user options for this theme" get deleted.
This behavior results in any options set that should have effect for guests will be removed.

This originates from $sourcedir/Themes.php, there when setting things with who=1 (changing stuff for all members) the old entries get deleted with id_member != {int:no_member} instead of id_member > {int:no_member} so the entry with -1, which is used for guest defaults, is removed.
To fix this I ran this modification:

<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>Sorunome:SMFThemeBugfix</id>
<version>1.0</version>
<file name="$sourcedir/Themes.php">
<operation>
<search position="replace"><![CDATA[$smcFunc['db_query']('substring', '
DELETE FROM {db_prefix}themes
WHERE id_theme = {int:default_theme}
AND id_member != {int:no_member}
AND variable = SUBSTRING({string:option}, 1, 255)',
array(
'default_theme' => 1,
'no_member' => 0,
'option' => $opt,
)
);]]></search>
<add><![CDATA[$smcFunc['db_query']('substring', '
DELETE FROM {db_prefix}themes
WHERE id_theme = {int:default_theme}
AND id_member > {int:no_member}
AND variable = SUBSTRING({string:option}, 1, 255)',
array(
'default_theme' => 1,
'no_member' => 0,
'option' => $opt,
)
);]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[$smcFunc['db_query']('substring', '
DELETE FROM {db_prefix}themes
WHERE id_theme = {int:current_theme}
AND id_member != {int:no_member}
AND variable = SUBSTRING({string:option}, 1, 255)',
array(
'current_theme' => $_GET['th'],
'no_member' => 0,
'option' => $opt,
)
);]]></search>
<add><![CDATA[$smcFunc['db_query']('substring', '
DELETE FROM {db_prefix}themes
WHERE id_theme = {int:current_theme}
AND id_member > {int:no_member}
AND variable = SUBSTRING({string:option}, 1, 255)',
array(
'current_theme' => $_GET['th'],
'no_member' => 0,
'option' => $opt,
)
);]]></add>
</operation>
</file>
</modification>

FishingManMatt

Hi!

Recently I've been changing some settings in Member Theme Options and was wondering what was wrong. It seems the bug still exists in 2.0.17.
If a given option is enabled in guest and new user options and we disable the option in current options for all members then it also becomes turned off in guest and new user options.
Implementing the solution posted by Sorunome solves the issue.

There is also another issue related to this subject.
In the SMF Online Manual one can read:
QuoteConfigure guest and new user options for this theme - These are the default values for some member specific settings. Changing these will only affect new members and guests.
Actually, when you make some changes in guest and new user options, the changes may also affect existing/registered users. This will happen when we change options that have never been altered by the user. These options will be changed in all existing accounts.

Kindred

ummmm.....

there is no 2.0.17 version.

So, if you are reporting a bug in that version, then we have time-travel!


and it's not a bug.... IMO, this is FAD and expected behavior.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

Well... why would you disable an option for existing users but let new users have the option?

FishingManMatt

Quote from: Kindred on November 12, 2019, 04:16:48 PM
ummmm.....

there is no 2.0.17 version.

So, if you are reporting a bug in that version, then we have time-travel!


and it's not a bug.... IMO, this is FAD and expected behavior.

Time travel may be real ;)  Especially after a 24-hour hospital shift :(


Quote from: Arantor on November 12, 2019, 04:23:09 PM
Well... why would you disable an option for existing users but let new users have the option?

If this is how it is supposed to work, then after enabling an option for existing users the option should also become enabled for new users. And it is not. It only affects guest and new user options when an option is disabled in current options for all members. So, there is no consequence.

As for the second issue mentioned in my post, I referred to the SMF Online Manual that says that changing guest and new user options will only affect new members and guests. That's why I was surprised to see that some options were also changed for my existing users.

But guys, if you think that it all works as expected then there are certainly no bugs :-) Noone knows SMF better than you.
As always, many thanks for your support!

shawnb61

#5
Most of the confusion here is terminology.  Screen labels aren't helping.  There are two screens in question:

Configure Guest & New User options
- Consistent with the manual, this allows the admin to change guest and new user options.  This is where you maintain the defaults.
- Updates made here only affect the default user, "-1".

Change Current Options for All Members
- The admin has 3 options for each user setting: set, clear, or remove (removal forces usage of the default setting from the prior screen).
- This screen is NOT supposed to change the defaults...  It's a bulk update tool for changing settings for existing users.
- Updating entries here updates settings for *all existing users except 0*, and DELETES the settings for the -1 default user
- Removing entries here removes settings for *all existing users except 0 & -1*

There are multiple problems here:
1. As noted by both FishingManMatt and Sorunome, updating an entry for users shouldn't also delete the default.  The problem is that it does an update via a delete/add, and there is some internal coding confusion whether the default user ID (which it is trying to keep) is "0" or "-1".  (Some of the queries use != 0, and some use > 0.  Sorunome's fix makes them consistently use > 0.)  It deletes the default even if you are enabling the option for all users...  This is clearly not the intent.
2. One of the labels is confusing, & refers to defaults on the "Change Current Options" screen, which has nothing to do with defaults.
3. The 0/-1 confusion for default user IDs exists in at least two places, including in the installer, which loads a mix for these user settings, sometimes 0, sometimes -1. 
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

shawnb61

Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

FishingManMatt


shawnb61

Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

shawnb61

Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Advertisement: