Advertisement:

Author Topic: [2.0] Themes and Layouts Member Options  (Read 2403 times)

Offline Sorunome

  • Semi-Newbie
  • *
  • Posts: 30
    • Sorunome on GitHub
[2.0] Themes and Layouts Member Options
« on: October 31, 2015, 07:50:47 AM »
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:

Code: [Select]
<?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>

Offline FishingManMatt

  • Semi-Newbie
  • *
  • Posts: 62
  • Gender: Male
Re: [2.0] Themes and Layouts Member Options
« Reply #1 on: November 12, 2019, 03:04:19 PM »
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:
Quote
Configure 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.

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,625
  • Gender: Male
    • Kindred-999 on GitHub
Re: [2.0] Themes and Layouts Member Options
« Reply #2 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.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,982
    • StoryBB/StoryBB on GitHub
Re: [2.0] Themes and Layouts Member Options
« Reply #3 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?
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline FishingManMatt

  • Semi-Newbie
  • *
  • Posts: 62
  • Gender: Male
Re: [2.0] Themes and Layouts Member Options
« Reply #4 on: November 12, 2019, 05:57:11 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 :(


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!

Offline shawnb61

  • Developer
  • SMF Hero
  • *
  • Posts: 1,591
    • sbulen on GitHub
Re: [2.0] Themes and Layouts Member Options
« Reply #5 on: December 02, 2019, 01:12:25 AM »
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. 
« Last Edit: December 02, 2019, 01:38:38 AM by shawnb61 »
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Offline shawnb61

  • Developer
  • SMF Hero
  • *
  • Posts: 1,591
    • sbulen on GitHub
Re: [2.0] Themes and Layouts Member Options
« Reply #6 on: December 02, 2019, 12:55:38 PM »
And... 2.1 does the same thing...
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Offline FishingManMatt

  • Semi-Newbie
  • *
  • Posts: 62
  • Gender: Male
Re: [2.0] Themes and Layouts Member Options
« Reply #7 on: December 03, 2019, 04:40:41 PM »
Many thanks for the clarification, Shawn!

Offline shawnb61

  • Developer
  • SMF Hero
  • *
  • Posts: 1,591
    • sbulen on GitHub
Re: [2.0] Themes and Layouts Member Options
« Reply #8 on: December 03, 2019, 07:54:42 PM »
2.0 issue logged internally, #89

2.1 issue logged: https://github.com/SimpleMachines/SMF2.1/issues/5882
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp