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