From: stevetruckstuff Date: Mon, 2 Oct 2006 20:17:32 +0000 (+0000) Subject: Correct handling of default user themes. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=acd7fdf263929e876918bc434086626ec871afb1;p=squirrelmail.git Correct handling of default user themes. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11814 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/page_header.php b/functions/page_header.php index beafbdb6..9c4e9365 100644 --- a/functions/page_header.php +++ b/functions/page_header.php @@ -33,7 +33,8 @@ function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE global $base_uri; } global $custom_css, $pageheader_sent, $theme, $theme_default, $text_direction, - $default_fontset, $chosen_fontset, $default_fontsize, $chosen_fontsize, $chosen_theme; + $default_fontset, $chosen_fontset, $default_fontsize, $chosen_fontsize, + $chosen_theme, $chosen_theme_path, $user_themes, $user_theme_default; /* add no cache headers here */ //FIXME: should change all header() calls in SM core to use $oTemplate->header()!! @@ -49,8 +50,8 @@ function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE $used_fontset = (!empty($chosen_fontset) ? $chosen_fontset : $default_fontset); $used_fontsize = (!empty($chosen_fontsize) ? $chosen_fontsize : $default_fontsize); - $used_theme = basename((!empty($chosen_theme) ? $chosen_theme : $theme[$theme_default]['PATH']),'.php'); - + $used_theme = !isset($chosen_theme) && $user_theme_default != 'none' ? 'u_'.$user_themes[$user_theme_default]['PATH'] : $chosen_theme_path; + /** * Stylesheets are loaded in the following order: * 1) All stylesheets provided by the template. Normally, these are @@ -83,8 +84,8 @@ function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE * * TODO: Re-evaluate this naming convetion. */ - if (!empty($chosen_theme) && substr($chosen_theme, 0, 2) == 'u_') { - $aUserStyles[] = substr($chosen_theme, 2) .'default.css'; + if (!empty($used_theme) && substr($used_theme, 0, 2) == 'u_') { + $aUserStyles[] = substr($used_theme, 2) .'default.css'; } // 3. src/style.php diff --git a/include/load_prefs.php b/include/load_prefs.php index 70f88632..d35b088c 100644 --- a/include/load_prefs.php +++ b/include/load_prefs.php @@ -50,10 +50,30 @@ for ($i = 0; $i < count($aTemplateSet); ++$i){ // if (!$found_templateset) $sTemplateID = $sDefaultTemplateID; +// Load user theme $chosen_theme = getPref($data_dir, $username, 'chosen_theme'); +$found_theme = false; +$chosen_theme_path = empty($chosen_theme) ? + $chosen_theme_path = 'u_'.$user_themes[$user_theme_default]['PATH'] : + $chosen_theme; + +// need to adjust $chosen_theme path with SM_PATH +$chosen_theme_path = preg_replace("/(\.\.\/){1,}/", SM_PATH, $chosen_theme_path); +$k = 0; +while (!$found_theme && $k < count($user_themes)) { + if ('u_'.$user_themes[$k]['PATH'] == $chosen_theme_path) + $found_theme = true; + $k++; +} +if (!$found_theme || $chosen_theme == 'none') { + $chosen_theme_path = NULL; +} -/* Steve, is this commented out because it is part of the old system being removed? - Let's just remove it then... no? +/* PL: Steve, is this commented out because it is part of the old system being removed? + Let's just remove it then... no? + + SB: Holding on to incase I need to reference later. Will remove eventually. :) + $theme = ( !isset($theme) ? array() : $theme ); $color = ( !isset($color) ? array() : $color );