Commit f6082cda authored by Dries's avatar Dries

- 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.
parent 604064b5
......@@ -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);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment