updated a few things in preparation for the 0.5pre1 release
[squirrelmail.git] / src / load_prefs.php
1 <?php
2 /**
3 ** load_prefs.php
4 **
5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
7 **
8 ** Loads preferences from the $username.pref file used by almost
9 ** every other script in the source directory and alswhere.
10 **
11 **/
12
13 if (!isset($config_php))
14 include("../config/config.php");
15 if (!isset($prefs_php))
16 include("../functions/prefs.php");
17 if (!isset($plugin_php))
18 include("../functions/plugin.php");
19
20 $load_prefs_php = true;
21 checkForPrefs($data_dir, $username);
22
23 $chosen_theme = getPref($data_dir, $username, "chosen_theme");
24 if ((substr($chosen_theme, 0, 10) == "../config/")) {
25 $chosen_theme = substr($chosen_theme, 10);
26 $chosen_theme = "../themes/$chosen_theme";
27 }
28
29 if ((isset($chosen_theme)) && (file_exists($chosen_theme))) {
30 require("$chosen_theme");
31 } else {
32 if (file_exists($theme[0]["PATH"])) {
33 require($theme[0]["PATH"]);
34 } else {
35 #
36 # I hard coded the theme as a last resort if no themes were
37 # found. It makes no sense to cause the whole thing to exit
38 # just because themes were not found. This is the absolute
39 # last resort.
40 #
41 $color[0] = "#DCDCDC"; // (light gray) TitleBar
42 $color[1] = "#800000"; // (red)
43 $color[2] = "#CC0000"; // (light red) Warning/Error Messages
44 $color[3] = "#A0B8C8"; // (green-blue) Left Bar Background
45 $color[4] = "#FFFFFF"; // (white) Normal Background
46 $color[5] = "#FFFFCC"; // (light yellow) Table Headers
47 $color[6] = "#000000"; // (black) Text on left bar
48 $color[7] = "#0000CC"; // (blue) Links
49 $color[8] = "#000000"; // (black) Normal text
50 $color[9] = "#ABABAB"; // (mid-gray) Darker version of #0
51 $color[10] = "#666666"; // (dark gray) Darker version of #9
52 $color[11] = "#770000"; // (dark red) Special Folders color
53 }
54 }
55
56 session_register("theme_css");
57
58 $use_javascript_addr_book = getPref($data_dir, $username, "use_javascript_addr_book");
59 if ($use_javascript_addr_book == "")
60 $use_javascript_addr_book = $default_use_javascript_addr_book;
61
62
63 /** Load the user's sent folder preferences **/
64 $move_to_sent = getPref($data_dir, $username, "move_to_sent");
65 if ($move_to_sent == "")
66 $move_to_sent = $default_move_to_sent;
67
68 /** Load the user's trash folder preferences **/
69 $move_to_trash = getPref($data_dir, $username, "move_to_trash");
70 if ($move_to_trash == "")
71 $move_to_trash = $default_move_to_trash;
72
73
74 $unseen_type = getPref($data_dir, $username, "unseen_type");
75 if ($default_unseen_type == "")
76 $default_unseen_type = 1;
77 if ($unseen_type == "")
78 $unseen_type = $default_unseen_type;
79
80 $unseen_notify = getPref($data_dir, $username, "unseen_notify");
81 if ($default_unseen_notify == "")
82 $default_unseen_notify = 2;
83 if ($unseen_notify == "")
84 $unseen_notify = $default_unseen_notify;
85
86
87 $folder_prefix = getPref($data_dir, $username, "folder_prefix");
88 if ($folder_prefix == "")
89 $folder_prefix = $default_folder_prefix;
90
91 /** Load special folders **/
92 $new_trash_folder = getPref($data_dir, $username, "trash_folder");
93 if (($new_trash_folder == "") && ($move_to_trash == true))
94 $trash_folder = $folder_prefix . $trash_folder;
95 else
96 $trash_folder = $new_trash_folder;
97
98 /** Load special folders **/
99 $new_sent_folder = getPref($data_dir, $username, "sent_folder");
100 if (($new_sent_folder == "") && ($move_to_sent == true))
101 $sent_folder = $folder_prefix . $sent_folder;
102 else
103 $sent_folder = $new_sent_folder;
104
105 $show_num = getPref($data_dir, $username, "show_num");
106 if ($show_num == "")
107 $show_num = 25;
108
109 $wrap_at = getPref($data_dir, $username, "wrap_at");
110 if ($wrap_at == "")
111 $wrap_at = 86;
112
113 $left_size = getPref($data_dir, $username, "left_size");
114 if ($left_size == "") {
115 if (isset($default_left_size))
116 $left_size = $default_left_size;
117 else
118 $left_size = 200;
119 }
120
121 $editor_size = getPref($data_dir, $username, "editor_size");
122 if ($editor_size == "")
123 $editor_size = 76;
124
125 $use_signature = getPref($data_dir, $username, "use_signature");
126 if ($use_signature == "")
127 $use_signature = false;
128
129 $left_refresh = getPref($data_dir, $username, "left_refresh");
130 if ($left_refresh == "")
131 $left_refresh = false;
132
133 /** Load up the Signature file **/
134 if ($use_signature == true) {
135 $signature_abs = $signature = getSig($data_dir, $username);
136 } else {
137 $signature_abs = getSig($data_dir, $username);
138 }
139
140 // highlightX comes in with the form: name,color,header,value
141 for ($i=0; $hlt = getPref($data_dir, $username, "highlight$i"); $i++) {
142 $ary = explode(",", $hlt);
143 $message_highlight_list[$i]["name"] = $ary[0];
144 $message_highlight_list[$i]["color"] = $ary[1];
145 $message_highlight_list[$i]["value"] = $ary[2];
146 $message_highlight_list[$i]["match_type"] = $ary[3];
147 }
148
149 do_hook("loading_prefs");
150 ?>