Correct handling of default user themes.
authorstevetruckstuff <stevetruckstuff@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 2 Oct 2006 20:17:32 +0000 (20:17 +0000)
committerstevetruckstuff <stevetruckstuff@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 2 Oct 2006 20:17:32 +0000 (20:17 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11814 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/page_header.php
include/load_prefs.php

index beafbdb6a707adc7702a32777795cc20dd49c998..9c4e9365248b1275017c579eb6c875b20bad959d 100644 (file)
@@ -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,
         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()!!
 
     /* 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_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
     /**
      * 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.
  */
  * 
  * 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
     }
 
     // 3. src/style.php
index 70f88632d6089c9b33442a64974562bf1ed20953..d35b088c8f92b023ab052d4038c15aec0ff638e5 100644 (file)
@@ -50,10 +50,30 @@ for ($i = 0; $i < count($aTemplateSet); ++$i){
 //
 if (!$found_templateset) $sTemplateID = $sDefaultTemplateID;
 
 //
 if (!$found_templateset) $sTemplateID = $sDefaultTemplateID;
 
+// Load user theme
 $chosen_theme = getPref($data_dir, $username, 'chosen_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 );
 
 $theme = ( !isset($theme) ? array() : $theme );
 $color = ( !isset($color) ? array() : $color );