Use default theme if loaded one is not found

When loading a user's theme, make sure it's installed. Also, when
determining the default theme, account for the situation in which
zero themes are installed (and use 'default' then).

Refs #1061
This commit is contained in:
Sam Wilson 2019-08-14 17:22:53 +08:00 committed by Pierrick Le Gall
parent 63bbba8e36
commit 7b6912ba98

View file

@ -299,9 +299,10 @@ function build_user($user_id, $use_cache=true)
} }
// Check user theme // Check user theme
if (!isset($user['theme_name'])) if (!isset($user['theme_name']) || !check_theme_installed($user['theme_name']))
{ {
$user['theme'] = get_default_theme(); $user['theme'] = get_default_theme();
$user['theme_name'] = $user['theme'];
} }
return $user; return $user;
@ -777,7 +778,7 @@ function get_default_theme()
// let's find the first available theme // let's find the first available theme
$active_themes = array_keys(get_pwg_themes()); $active_themes = array_keys(get_pwg_themes());
return $active_themes[0]; return isset($active_themes[0]) ? $active_themes[0] : 'default';
} }
/** /**