59177427 |
1 | <?php |
ef870322 |
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 | ** |
245a6892 |
11 | ** $Id$ |
ef870322 |
12 | **/ |
13 | |
f740c049 |
14 | if (defined('load_prefs_php')) |
15 | return; |
16 | define('load_prefs_php', true); |
17 | |
18 | global $theme, $chosen_theme, $color; |
9a6f7785 |
19 | if (! isset($theme)) |
20 | $theme = array(); |
21 | if (! isset($color)) |
22 | $color = array(); |
f740c049 |
23 | include("../functions/prefs.php"); |
24 | include("../functions/plugin.php"); |
37df47f5 |
25 | |
ceac7a2f |
26 | if (!isset($username)) |
27 | $username = ''; |
b4da6659 |
28 | checkForPrefs($data_dir, $username); |
29 | |
d0747e26 |
30 | $chosen_theme = getPref($data_dir, $username, "chosen_theme"); |
47f9c368 |
31 | $in_ary = false; |
32 | for ($i=0; $i < count($theme); $i++){ |
33 | if ($theme[$i]["PATH"] == $chosen_theme) { |
34 | $in_ary = true; |
35 | break; |
36 | } |
37 | } |
f740c049 |
38 | |
39 | if (! $in_ary) |
40 | $chosen_theme = ""; |
d3cdb279 |
41 | |
f740c049 |
42 | if (isset($chosen_theme) && $in_ary && (file_exists($chosen_theme))) { |
43 | @include($chosen_theme); |
d3cdb279 |
44 | } else { |
9a6f7785 |
45 | if (file_exists(isset($theme) && isset($theme[0]) && $theme[0]["PATH"])) { |
f740c049 |
46 | @include($theme[0]["PATH"]); |
f3d17401 |
47 | } else { |
98fe1e9f |
48 | # |
f740c049 |
49 | # I hard coded the theme as a failsafe if no themes were |
98fe1e9f |
50 | # found. It makes no sense to cause the whole thing to exit |
74a7d5b0 |
51 | # just because themes were not found. This is the absolute |
98fe1e9f |
52 | # last resort. |
53 | # |
54 | $color[0] = "#DCDCDC"; // (light gray) TitleBar |
55 | $color[1] = "#800000"; // (red) |
56 | $color[2] = "#CC0000"; // (light red) Warning/Error Messages |
57 | $color[3] = "#A0B8C8"; // (green-blue) Left Bar Background |
58 | $color[4] = "#FFFFFF"; // (white) Normal Background |
59 | $color[5] = "#FFFFCC"; // (light yellow) Table Headers |
60 | $color[6] = "#000000"; // (black) Text on left bar |
61 | $color[7] = "#0000CC"; // (blue) Links |
62 | $color[8] = "#000000"; // (black) Normal text |
63 | $color[9] = "#ABABAB"; // (mid-gray) Darker version of #0 |
64 | $color[10] = "#666666"; // (dark gray) Darker version of #9 |
65 | $color[11] = "#770000"; // (dark red) Special Folders color |
f3d17401 |
66 | } |
d3cdb279 |
67 | } |
2de8df87 |
68 | |
f740c049 |
69 | if (!defined('download_php')) |
70 | session_register("theme_css"); |
71 | |
72 | global $use_javascript_addr_book; |
3806fa52 |
73 | $use_javascript_addr_book = getPref($data_dir, $username, "use_javascript_addr_book"); |
74 | if ($use_javascript_addr_book == "") |
75 | $use_javascript_addr_book = $default_use_javascript_addr_book; |
76 | |
77 | |
1573e796 |
78 | /** Load the user's sent folder preferences **/ |
f740c049 |
79 | global $move_to_sent, $move_to_trash; |
1573e796 |
80 | $move_to_sent = getPref($data_dir, $username, "move_to_sent"); |
81 | if ($move_to_sent == "") |
82 | $move_to_sent = $default_move_to_sent; |
83 | |
84 | /** Load the user's trash folder preferences **/ |
85 | $move_to_trash = getPref($data_dir, $username, "move_to_trash"); |
86 | if ($move_to_trash == "") |
87 | $move_to_trash = $default_move_to_trash; |
88 | |
89 | |
f740c049 |
90 | global $unseen_type, $unseen_notify; |
24fc5dd2 |
91 | $unseen_type = getPref($data_dir, $username, "unseen_type"); |
92 | if ($default_unseen_type == "") |
93 | $default_unseen_type = 1; |
94 | if ($unseen_type == "") |
95 | $unseen_type = $default_unseen_type; |
96 | |
97 | $unseen_notify = getPref($data_dir, $username, "unseen_notify"); |
98 | if ($default_unseen_notify == "") |
99 | $default_unseen_notify = 2; |
100 | if ($unseen_notify == "") |
101 | $unseen_notify = $default_unseen_notify; |
102 | |
103 | |
f740c049 |
104 | global $folder_prefix; |
1e0628fb |
105 | $folder_prefix = getPref($data_dir, $username, "folder_prefix"); |
106 | if ($folder_prefix == "") |
107 | $folder_prefix = $default_folder_prefix; |
108 | |
f740c049 |
109 | |
1e0628fb |
110 | /** Load special folders **/ |
f740c049 |
111 | global $trash_folder, $sent_folder; |
1e0628fb |
112 | $new_trash_folder = getPref($data_dir, $username, "trash_folder"); |
113 | if (($new_trash_folder == "") && ($move_to_trash == true)) |
114 | $trash_folder = $folder_prefix . $trash_folder; |
115 | else |
116 | $trash_folder = $new_trash_folder; |
117 | |
118 | /** Load special folders **/ |
119 | $new_sent_folder = getPref($data_dir, $username, "sent_folder"); |
120 | if (($new_sent_folder == "") && ($move_to_sent == true)) |
121 | $sent_folder = $folder_prefix . $sent_folder; |
122 | else |
123 | $sent_folder = $new_sent_folder; |
11307a4c |
124 | |
f740c049 |
125 | |
126 | global $show_num, $wrap_at, $left_size; |
9c83f905 |
127 | $show_num = getPref($data_dir, $username, "show_num"); |
128 | if ($show_num == "") |
129 | $show_num = 25; |
130 | |
11307a4c |
131 | $wrap_at = getPref($data_dir, $username, "wrap_at"); |
132 | if ($wrap_at == "") |
133 | $wrap_at = 86; |
7aaa81fc |
134 | if ($wrap_at < 15) |
135 | $wrap_at = 15; |
11307a4c |
136 | |
2848c630 |
137 | $left_size = getPref($data_dir, $username, "left_size"); |
138 | if ($left_size == "") { |
139 | if (isset($default_left_size)) |
140 | $left_size = $default_left_size; |
141 | else |
142 | $left_size = 200; |
143 | } |
144 | |
f740c049 |
145 | |
146 | global $editor_size, $use_signature, $prefix_sig; |
11307a4c |
147 | $editor_size = getPref($data_dir, $username, "editor_size"); |
148 | if ($editor_size == "") |
149 | $editor_size = 76; |
f804972b |
150 | |
151 | $use_signature = getPref($data_dir, $username, "use_signature"); |
152 | if ($use_signature == "") |
153 | $use_signature = false; |
154 | |
025deae0 |
155 | $prefix_sig = getPref($data_dir, $username, "prefix_sig"); |
156 | if ($prefix_sig == "") |
f740c049 |
157 | $prefix_sig = true; |
158 | |
025deae0 |
159 | |
f740c049 |
160 | global $left_refresh, $sort; |
469eb37b |
161 | $left_refresh = getPref($data_dir, $username, "left_refresh"); |
162 | if ($left_refresh == "") |
163 | $left_refresh = false; |
5c54e435 |
164 | |
165 | $sort = getPref($data_dir, $username, "sort"); |
166 | if ($sort == "") |
167 | $sort = 6; |
469eb37b |
168 | |
f740c049 |
169 | |
f804972b |
170 | /** Load up the Signature file **/ |
f740c049 |
171 | global $signature_abs; |
f804972b |
172 | if ($use_signature == true) { |
c36ed9cf |
173 | $signature_abs = $signature = getSig($data_dir, $username); |
f804972b |
174 | } else { |
c36ed9cf |
175 | $signature_abs = getSig($data_dir, $username); |
f804972b |
176 | } |
636e611c |
177 | |
f740c049 |
178 | |
9d157cec |
179 | // highlightX comes in with the form: name,color,header,value |
f740c049 |
180 | global $message_highlight_list; |
9d157cec |
181 | for ($i=0; $hlt = getPref($data_dir, $username, "highlight$i"); $i++) { |
182 | $ary = explode(",", $hlt); |
183 | $message_highlight_list[$i]["name"] = $ary[0]; |
184 | $message_highlight_list[$i]["color"] = $ary[1]; |
185 | $message_highlight_list[$i]["value"] = $ary[2]; |
3e69e88b |
186 | $message_highlight_list[$i]["match_type"] = $ary[3]; |
9d157cec |
187 | } |
8e265988 |
188 | |
f740c049 |
189 | |
8e265988 |
190 | #index order lets you change the order of the message index |
f740c049 |
191 | global $index_order; |
8e265988 |
192 | $order = getPref($data_dir, $username, "order1"); |
193 | for ($i=1; $order; $i++) { |
194 | $index_order[$i] = $order; |
195 | $order = getPref($data_dir, $username, "order".($i+1)); |
196 | } |
a7ea7540 |
197 | if (!isset($index_order)) { |
8e265988 |
198 | $index_order[1] = 1; |
199 | $index_order[2] = 2; |
200 | $index_order[3] = 3; |
201 | $index_order[4] = 5; |
202 | $index_order[5] = 4; |
203 | } |
9a732bb6 |
204 | |
ac53fb56 |
205 | global $alt_index_colors; |
206 | $alt_index_colors = getPref($data_dir, $username, 'alt_index_colors'); |
207 | if ($alt_index_colors === 0) { |
208 | $alt_index_colors = false; |
209 | } else { |
210 | $alt_index_colors = true; |
211 | } |
212 | |
f740c049 |
213 | |
214 | global $location_of_bar, $location_of_buttons; |
9a732bb6 |
215 | $location_of_bar = getPref($data_dir, $username, 'location_of_bar'); |
216 | if ($location_of_bar == '') |
217 | $location_of_bar = 'left'; |
441f2d33 |
218 | |
219 | $location_of_buttons = getPref($data_dir, $username, 'location_of_buttons'); |
220 | if ($location_of_buttons == '') |
221 | $location_of_buttons = 'between'; |
235a65d5 |
222 | |
f740c049 |
223 | |
224 | global $collapse_folders, $show_html_default; |
235a65d5 |
225 | $collapse_folders = getPref($data_dir, $username, 'collapse_folders'); |
e2ab93e5 |
226 | |
227 | $show_html_default = getPref($data_dir, $username, 'show_html_default'); |
c36ed9cf |
228 | |
6b638171 |
229 | do_hook("loading_prefs"); |
b731cd83 |
230 | |
11307a4c |
231 | ?> |