59177427 |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4 | * load_prefs.php |
5 | * |
15e6162e |
6 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * Loads preferences from the $username.pref file used by almost |
10 | * every other script in the source directory and alswhere. |
11 | * |
12 | * $Id$ |
13 | */ |
f7b1b3b1 |
14 | |
35586184 |
15 | require_once('../src/validate.php'); |
0f2447d8 |
16 | require_once('../functions/prefs.php'); |
17 | require_once('../functions/plugin.php'); |
18 | require_once('../functions/constants.php'); |
19 | |
20 | $username = ( !isset($username) ? '' : $username ); |
21 | |
22 | global $theme, $chosen_theme, $color; |
23 | $theme = ( !isset($theme) ? array() : $theme ); |
24 | $color = ( !isset($color) ? array() : $color ); |
25 | |
26 | $chosen_theme = getPref($data_dir, $username, "chosen_theme"); |
27 | $found_theme = false; |
28 | for ($i=0; $i < count($theme); $i++){ |
29 | if ($theme[$i]['PATH'] == $chosen_theme) { |
30 | $found_theme = true; |
31 | break; |
f7b1b3b1 |
32 | } |
0f2447d8 |
33 | } |
34 | $chosen_theme = (!$found_theme ? '' : $chosen_theme); |
35 | |
36 | if (isset($chosen_theme) && $found_theme && (file_exists($chosen_theme))) { |
37 | @include_once($chosen_theme); |
38 | } else { |
39 | if (isset($theme) && isset($theme[0]) && file_exists($theme[0]['PATH'])) { |
40 | @include_once($theme[0]['PATH']); |
f7b1b3b1 |
41 | } else { |
0f2447d8 |
42 | /** |
43 | * This theme as a failsafe if no themes were found. It makes |
44 | * no sense to cause the whole thing to exit just because themes |
45 | * were not found. This is the absolute last resort. |
46 | */ |
47 | $color[0] = '#DCDCDC'; /* light gray TitleBar */ |
48 | $color[1] = '#800000'; /* red */ |
49 | $color[2] = '#CC0000'; /* light red Warning/Error Messages */ |
50 | $color[3] = '#A0B8C8'; /* green-blue Left Bar Background */ |
51 | $color[4] = '#FFFFFF'; /* white Normal Background */ |
52 | $color[5] = '#FFFFCC'; /* light yellow Table Headers */ |
53 | $color[6] = '#000000'; /* black Text on left bar */ |
54 | $color[7] = '#0000CC'; /* blue Links */ |
55 | $color[8] = '#000000'; /* black Normal text */ |
56 | $color[9] = '#ABABAB'; /* mid-gray Darker version of #0 */ |
57 | $color[10] = '#666666'; /* dark gray Darker version of #9 */ |
58 | $color[11] = '#770000'; /* dark red Special Folders color */ |
f7b1b3b1 |
59 | } |
0f2447d8 |
60 | } |
61 | |
62 | if (!defined('download_php')) { session_register('theme_css'); } |
63 | |
64 | global $use_javascript_addr_book; |
65 | $use_javascript_addr_book = getPref($data_dir, $username, 'use_javascript_addr_book', $default_use_javascript_addr_book); |
66 | |
67 | /** Declare the global variables for the special folders. */ |
68 | global $move_to_sent, $move_to_trash, $save_as_draft; |
69 | |
70 | /** Load the user's special folder preferences **/ |
71 | $move_to_sent = getPref($data_dir, $username, 'move_to_sent', $default_move_to_sent); |
72 | $move_to_trash = getPref($data_dir, $username, 'move_to_trash', $default_move_to_trash); |
73 | $save_as_draft = getPref($data_dir, $username, 'save_as_draft', $default_save_as_draft); |
74 | |
75 | global $unseen_type, $unseen_notify; |
76 | if ($default_unseen_type == '') { $default_unseen_type = 1; } |
77 | $unseen_type = getPref($data_dir, $username, 'unseen_type', $default_unseen_type); |
78 | if ($default_unseen_notify == '') { $default_unseen_notify = 2; } |
79 | $unseen_notify = getPref($data_dir, $username, 'unseen_notify', $default_unseen_notify); |
80 | |
81 | global $folder_prefix; |
82 | $folder_prefix = getPref($data_dir, $username, 'folder_prefix', $default_folder_prefix); |
83 | |
84 | /* Declare global variables for special folders. */ |
85 | global $trash_folder, $sent_folder, $draft_folder; |
86 | |
87 | /** Load special folder - trash **/ |
88 | $load_trash_folder = getPref($data_dir, $username, 'trash_folder'); |
89 | if (($load_trash_folder == '') && ($move_to_trash)) { |
90 | $trash_folder = $folder_prefix . $trash_folder; |
91 | } else { |
92 | $trash_folder = $load_trash_folder; |
93 | } |
94 | |
95 | /** Load special folder - sent **/ |
96 | $load_sent_folder = getPref($data_dir, $username, 'sent_folder'); |
97 | if (($load_sent_folder == '') && ($move_to_sent)) { |
98 | $sent_folder = $folder_prefix . $sent_folder; |
99 | } else { |
100 | $sent_folder = $load_sent_folder; |
101 | } |
102 | |
103 | /** Load special folder - draft **/ |
104 | $load_draft_folder = getPref($data_dir, $username, 'draft_folder'); |
105 | if (($load_draft_folder == '') && ($save_as_draft)) { |
106 | $draft_folder = $folder_prefix . $draft_folder; |
107 | } else { |
108 | $draft_folder = $load_draft_folder; |
109 | } |
110 | |
111 | global $show_num, $wrap_at, $left_size; |
112 | $show_num = getPref($data_dir, $username, 'show_num', 15 ); |
113 | |
114 | $wrap_at = getPref( $data_dir, $username, 'wrap_at', 86 ); |
115 | if ($wrap_at < 15) { $wrap_at = 15; } |
116 | |
117 | $left_size = getPref($data_dir, $username, 'left_size'); |
118 | if ($left_size == "") { |
119 | if (isset($default_left_size)) { |
120 | $left_size = $default_left_size; |
f7b1b3b1 |
121 | } else { |
0f2447d8 |
122 | $left_size = 200; |
f7b1b3b1 |
123 | } |
0f2447d8 |
124 | } |
125 | |
126 | global $editor_size, $use_signature, $prefix_sig; |
127 | $editor_size = getPref($data_dir, $username, "editor_size", 76 ); |
128 | |
129 | $use_signature = getPref($data_dir, $username, 'use_signature', SMPREF_OFF ); |
130 | |
131 | $prefix_sig = getPref($data_dir, $username, "prefix_sig"); |
132 | |
133 | /* Load preferences for reply citation style. */ |
134 | global $reply_citation_style, $reply_citation_start, $reply_citation_end; |
135 | |
136 | $reply_citation_style = getPref($data_dir, $username, 'reply_citation_style', SMPREF_NONE ); |
137 | $reply_citation_start = getPref($data_dir, $username, 'reply_citation_start'); |
138 | $reply_citation_end = getPref($data_dir, $username, 'reply_citation_end'); |
139 | |
140 | global $left_refresh, $sort; |
141 | $left_refresh = getPref($data_dir, $username, 'left_refresh', SMPREF_NONE ); |
142 | $sort = getPref($data_dir, $username, 'sort', 6 ); |
143 | |
144 | /** Load up the Signature file **/ |
145 | global $signature_abs; |
146 | if ($use_signature) { |
147 | $signature_abs = $signature = getSig($data_dir, $username); |
148 | } else { |
149 | $signature_abs = getSig($data_dir, $username); |
150 | } |
151 | |
152 | /* HighlightX comes in with the form: name, color, header, value. */ |
153 | global $message_highlight_list; |
154 | for ($i=0; $hlt = getPref($data_dir, $username, "highlight$i"); $i++) { |
155 | $ary = explode(",", $hlt); |
156 | $message_highlight_list[$i]['name'] = $ary[0]; |
157 | $message_highlight_list[$i]['color'] = $ary[1]; |
158 | $message_highlight_list[$i]['value'] = $ary[2]; |
159 | $message_highlight_list[$i]['match_type'] = $ary[3]; |
160 | } |
161 | |
162 | /* Index order lets you change the order of the message index */ |
163 | global $index_order; |
164 | $order = getPref($data_dir, $username, 'order1'); |
165 | for ($i=1; $order; $i++) { |
166 | $index_order[$i] = $order; |
167 | $order = getPref($data_dir, $username, 'order'.($i+1)); |
168 | } |
169 | if (!isset($index_order)) { |
170 | $index_order[1] = 1; |
171 | $index_order[2] = 2; |
172 | $index_order[3] = 3; |
173 | $index_order[4] = 5; |
174 | $index_order[5] = 4; |
175 | } |
176 | |
177 | global $alt_index_colors; |
178 | $alt_index_colors = getPref($data_dir, $username, 'alt_index_colors', SMPREF_ON ); |
179 | |
180 | global $location_of_bar, $location_of_buttons; |
181 | $location_of_bar = getPref($data_dir, $username, 'location_of_bar', SMPREF_LOC_LEFT); |
182 | $location_of_buttons = getPref($data_dir, $username, 'location_of_buttons', SMPREF_LOC_BETWEEN); |
183 | |
184 | global $collapse_folders, $show_html_default, $show_xmailer_default, |
185 | $attachment_common_show_images, $pf_subtle_link, $pf_cleandisplay; |
186 | $collapse_folders = getPref($data_dir, $username, 'collapse_folders', SMPREF_ON); |
187 | |
188 | /* show_html_default is a int value. */ |
189 | $show_html_default = intval(getPref($data_dir, $username, 'show_html_default', SMPREF_OFF)); |
190 | |
191 | $show_xmailer_default = getPref($data_dir, $username, 'show_xmailer_default', SMPREF_OFF ); |
192 | $attachment_common_show_images = getPref($data_dir, $username, 'attachment_common_show_images', SMPREF_OFF ); |
193 | $pf_subtle_link = getPref($data_dir, $username, 'pf_subtle_link', SMPREF_ON); |
194 | $pf_cleandisplay = getPref($data_dir, $username, 'pf_cleandisplay', SMPREF_OFF); |
195 | |
196 | global $include_self_reply_all; |
197 | $include_self_reply_all = getPref($data_dir, $username, 'include_self_reply_all', SMPREF_ON); |
198 | |
199 | global $page_selector, $page_selector_max; |
200 | $page_selector = getPref($data_dir, $username, 'page_selector', SMPREF_ON); |
201 | $page_selector_max = getPref($data_dir, $username, 'page_selector_max', 10); |
202 | |
203 | /* SqClock now in the core */ |
204 | global $date_format, $hour_format, $username, $data_dir; |
205 | $date_format = getPref($data_dir, $username, 'date_format', 3); |
206 | $hour_format = getPref($data_dir, $username, 'hour_format', 2); |
207 | |
208 | /* Load the javascript settings. */ |
209 | global $javascript_setting, $javascript_on; |
210 | $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT); |
211 | $javascript_on = getPref($data_dir, $username, 'javascript_on', SMPREF_ON); |
212 | |
213 | do_hook("loading_prefs"); |
f7b1b3b1 |
214 | |
209663b7 |
215 | ?> |