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