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