Minor modifications to handle moving of icon themes to conf.pl
[squirrelmail.git] / include / load_prefs.php
index 5b5124fa50fcc3b3f1c5a4103cb2dbd66d488e17..8a68404d7709727a15023d9a9c4525eaea8935de 100644 (file)
@@ -50,17 +50,38 @@ 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;
+
+// Make sure the chosen theme is a legitimate one.
+// 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 );
 
 $chosen_theme = getPref($data_dir, $username, 'chosen_theme');
 $found_theme = false;
 
-// need to adjust $chosen_theme path with SM_PATH */
+// need to adjust $chosen_theme path with SM_PATH 
 $chosen_theme = preg_replace("/(\.\.\/){1,}/", SM_PATH, $chosen_theme);
 
 for ($i = 0; $i < count($theme); ++$i){
@@ -82,8 +103,24 @@ if (isset($chosen_theme) && $found_theme && (file_exists($chosen_theme))) {
 }
 
 */
+
 // user's icon theme, if using icons
-$icon_theme = getPref($data_dir, $username, 'icon_theme', 'images/themes/xp/' );
+$icon_theme = getPref($data_dir, $username, 'icon_theme');
+$default_icon_theme = $icon_themes[$icon_theme_def]['PATH'];
+$found_theme = false;
+
+// Make sure the chosen icon theme is a legitimate one.
+// need to adjust $icon_theme path with SM_PATH 
+$icon_theme = preg_replace("/(\.\.\/){1,}/", SM_PATH, $icon_theme);
+$k = 0;
+while (!$found_theme && $k < count($icon_themes)) {
+    if ($icon_themes[$k]['PATH'] == $icon_theme)
+        $found_theme = true;
+    $k++;
+}
+if (!$found_theme) {
+    $icon_theme = $default_icon_theme;
+}
 
 /*
  * NOTE: The $icon_theme_path var should contain the path to the icon