Sig Prefix fix (forgot getPref)
[squirrelmail.git] / src / load_prefs.php
index 94b05e35350afd723a4e0e2f2fecaf84971680c3..ed9c63422b81c78322452eeec292730ea3569a40 100644 (file)
@@ -8,20 +8,31 @@
     **  Loads preferences from the $username.pref file used by almost
     **  every other script in the source directory and alswhere.
     **
+    **  $Id$
     **/
 
    if (!isset($config_php))
       include("../config/config.php");
    if (!isset($prefs_php))
       include("../functions/prefs.php");
+   if (!isset($plugin_php))
+      include("../functions/plugin.php");
       
    $load_prefs_php = true;
+   if (!isset($username))
+       $username = '';
    checkForPrefs($data_dir, $username);
 
    $chosen_theme = getPref($data_dir, $username, "chosen_theme");
-   if ((substr($chosen_theme, 0, 10) == "../config/")) {
-      $chosen_theme = substr($chosen_theme, 10);
-      $chosen_theme = "../themes/$chosen_theme";
+   $in_ary = false;
+   for ($i=0; $i < count($theme); $i++){
+         if ($theme[$i]["PATH"] == $chosen_theme) {
+                $in_ary = true;
+                break;
+         }
+   }
+   if (!$in_ary) {
+               $chosen_theme = "";
    }
 
    if ((isset($chosen_theme)) && (file_exists($chosen_theme))) {
@@ -33,7 +44,7 @@
           #
           #  I hard coded the theme as a last resort if no themes were
           #  found.  It makes no sense to cause the whole thing to exit
-          #  just because themes weren't found.  This is the absolute
+          #  just because themes were not found.  This is the absolute
           #  last resort.
           #
           $color[0]   = "#DCDCDC"; // (light gray)     TitleBar
@@ -51,7 +62,7 @@
       }
    }
 
-       session_register("theme_css");
+    if (!isset($download_php)) session_register("theme_css");
 
    $use_javascript_addr_book = getPref($data_dir, $username, "use_javascript_addr_book");
    if ($use_javascript_addr_book == "")
    $wrap_at = getPref($data_dir, $username, "wrap_at");
    if ($wrap_at == "")
       $wrap_at = 86;
+   if ($wrap_at < 15)
+      $wrap_at = 15;
 
    $left_size = getPref($data_dir, $username, "left_size");
    if ($left_size == "") {
    if ($use_signature == "")
       $use_signature = false;
 
+   $prefix_sig = getPref($data_dir, $username, "prefix_sig");
+   if ($prefix_sig == "")
+      $prefix_sig = false;
+
    $left_refresh = getPref($data_dir, $username, "left_refresh");
    if ($left_refresh == "")
       $left_refresh = false;
+
+   $sort = getPref($data_dir, $username, "sort");
+   if ($sort == "")
+      $sort = 6;
    
    /** Load up the Signature file **/
    if ($use_signature == true) {
       $signature_abs = getSig($data_dir, $username);
    }
 
-   /** Load up the Language preference **/
-   $user_language = getPref($data_dir, $username, "language");
-   if ($user_language == "") {
-      if (isset($default_charset))
-         $user_language = $default_charset;
-     else  
-         $user_language = en;
-   }      
-
    //  highlightX comes in with the form: name,color,header,value
    for ($i=0; $hlt = getPref($data_dir, $username, "highlight$i"); $i++) {
       $ary = explode(",", $hlt);
       $message_highlight_list[$i]["match_type"] = $ary[3];
    }
 
+   #index order lets you change the order of the message index
+   $order = getPref($data_dir, $username, "order1");
+   for ($i=1; $order; $i++) {
+      $index_order[$i] = $order;
+      $order = getPref($data_dir, $username, "order".($i+1));
+   }
+   if (!isset($index_order)) {
+      $index_order[1] = 1;
+      $index_order[2] = 2;
+      $index_order[3] = 3;
+      $index_order[4] = 5;
+      $index_order[5] = 4;
+   }
+   
+   $location_of_bar = getPref($data_dir, $username, 'location_of_bar');
+   if ($location_of_bar == '')
+       $location_of_bar = 'left';
+       
+   $location_of_buttons = getPref($data_dir, $username, 'location_of_buttons');
+   if ($location_of_buttons == '')
+       $location_of_buttons = 'between';
+
+   do_hook("loading_prefs");
+
 ?>