Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build_theme_select does not render subtemplates in select if these are aloowed #4787

Open
gacekssj4 opened this issue Jan 27, 2024 · 2 comments

Comments

@gacekssj4
Copy link

I have following structure of themes
Master Style

  • Default theme
  • Added theme from internet
    • MyStyle (this is my theme i changed colors etc)
      • MyStyle Dark

What I want to achieve:
Allow users only use MyStyle and MyStyle Dark

What I did:
I disallowed groups from using "DefaultTheme" and "Added theme from Internet"

Problem:
Theme selector disappeared from footer

How to solve (my quick fix)

Change to this function
https://github.com/mybb/mybb/blob/feature/inc/functions.php#L5626

foreach($tcache[$tid] as $theme)
{
	$sel = "";
	// Show theme if allowed, or if override is on
	if(is_member($theme['allowedgroups']) || $theme['allowedgroups'] == "all" || $usergroup_override == true)
	{
		if($theme['tid'] == $selected)
		{
			$sel = " selected=\"selected\"";
		}

		if($theme['pid'] != 0)
		{
			$theme['name'] = htmlspecialchars_uni($theme['name']);
			eval("\$themeselect_option .= \"".$templates->get("usercp_themeselector_option")."\";");
			++$num_themes;
			$depthit = $depth."--";
		}

		if(array_key_exists($theme['tid'], $tcache))
		{
			build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override, $footer, $count_override);
		}
	}
}

To

foreach($tcache[$tid] as $theme)
{
	$sel = "";
	// Show theme if allowed, or if override is on
	if(is_member($theme['allowedgroups']) || $theme['allowedgroups'] == "all" || $usergroup_override == true)
	{
		if($theme['tid'] == $selected)
		{
			$sel = " selected=\"selected\"";
		}

		if($theme['pid'] != 0)
		{
			$theme['name'] = htmlspecialchars_uni($theme['name']);
			eval("\$themeselect_option .= \"".$templates->get("usercp_themeselector_option")."\";");
			++$num_themes;
			$depthit = $depth."--";
		}
	}
        /// Move this outside of a loop.
	if(array_key_exists($theme['tid'], $tcache)) {
	      build_theme_select($name, $selected, $theme['tid'], $depthit, $usergroup_override, $footer, $count_override);
        }
}

And now only allowed themes show in footer like (I think) it should be.

@Sama34
Copy link
Contributor

Sama34 commented Jan 27, 2024

If I understand correctly, you are disabling the main (primary) theme and enabling the secondary (child) theme.

If the main theme is disabled it would be expected that any child theme is disabled as well.

@gacekssj4
Copy link
Author

I understand that. But form my point of view i have my theme (downlaoded from internet) And I don't like it. I use it as base for work, since it has better HTML structure and that's what I want to use and be able to update this base template if it gets updated.

I want to override it, so (i think) prefered way is to create child theme.

  • Internet theme
    • My child theme
      • Color 1
      • Color 2

I do not want my users to allow to use "Internet theme". I want them to be able to use "MyChild" Theme and 2 color variations and be able to update Internet theme at any time without losing changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@Sama34 @gacekssj4 and others