From f6082cda98eab9732801e815a05aad1017446b12 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 2 Jan 2004 16:24:28 +0000 Subject: - Fixed bug 4916: users can have disabled themes. Modified patch by Mathias. 1. Remove the theme object. There is no need to keep it around since meta information for a theme can be retrieved via list_themes(). All we really need is the theme name. 2. Check if the user selected theme is enabled during theme initialization. This is the easiest place to put the check and doesn't mess with the user's settings. Their database profile will still contain the disabled theme selection, but they will be rendering the default admin-selected theme until their chosen theme is once again activated. --- includes/theme.inc | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'includes/theme.inc') diff --git a/includes/theme.inc b/includes/theme.inc index 78875509e..53d1dafc3 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -32,7 +32,7 @@ function theme_help($section) { } /** - * Initialized the theme system. + * Initialize the theme system by loading the theme. * * @return the name of the currently selected theme. */ @@ -40,16 +40,15 @@ function init_theme() { global $user; $themes = list_themes(); - $name = $user->theme ? $user->theme : variable_get("theme_default", 0); - $theme->path = ""; - $theme->name = ""; + /* + ** Only select the user selected theme if it is availible in the + ** list of enabled themes. + */ - if (is_object($themes[$name])) { - include_once($themes[$name]->filename); - $theme->path = dirname($themes[$name]->filename); - $theme->name = $name; - } + $theme = $themes[$user->theme] ? $user->theme : variable_get("theme_default", 0); + + include_once($themes[$theme]->filename); return $theme; } @@ -97,8 +96,8 @@ function theme() { $args = func_get_args(); $function = array_shift($args); - if (($theme->name != "") && (function_exists($theme->name ."_". $function))) { - return call_user_func_array($theme->name ."_". $function, $args); + if (($theme != "") && (function_exists($theme ."_". $function))) { + return call_user_func_array($theme ."_". $function, $args); } elseif (function_exists("theme_". $function)){ return call_user_func_array("theme_". $function, $args); @@ -112,7 +111,10 @@ function theme() { */ function path_to_theme() { global $theme; - return $theme->path; + + $themes = list_themes(); + + return dirname($themes[$theme]->filename); } /** -- cgit v1.2.3