minor textual updates (#506707)
[squirrelmail.git] / src / load_prefs.php
1 <?php
2
3 /**
4 * load_prefs.php
5 *
6 * Copyright (c) 1999-2002 The SquirrelMail Project 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$
13 */
14
15 require_once('../src/validate.php');
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, $custom_css;
23
24 $custom_css = getPref($data_dir, $username, 'custom_css', 'none' );
25
26 $theme = ( !isset($theme) ? array() : $theme );
27 $color = ( !isset($color) ? array() : $color );
28
29 $chosen_theme = getPref($data_dir, $username, 'chosen_theme');
30 $found_theme = false;
31 for ($i = 0; $i < count($theme); ++$i){
32 if ($theme[$i]['PATH'] == $chosen_theme) {
33 $found_theme = true;
34 break;
35 }
36 }
37 $chosen_theme = (!$found_theme ? '' : $chosen_theme);
38
39 if (isset($chosen_theme) && $found_theme && (file_exists($chosen_theme))) {
40 @include_once($chosen_theme);
41 } else {
42 if (isset($theme) && isset($theme[0]) && file_exists($theme[0]['PATH'])) {
43 @include_once($theme[0]['PATH']);
44 } else {
45 /**
46 * This theme as a failsafe if no themes were found. It makes
47 * no sense to cause the whole thing to exit just because themes
48 * were not found. This is the absolute last resort.
49 */
50 $color[0] = '#DCDCDC'; /* light gray TitleBar */
51 $color[1] = '#800000'; /* red */
52 $color[2] = '#CC0000'; /* light red Warning/Error Messages */
53 $color[3] = '#A0B8C8'; /* green-blue Left Bar Background */
54 $color[4] = '#FFFFFF'; /* white Normal Background */
55 $color[5] = '#FFFFCC'; /* light yellow Table Headers */
56 $color[6] = '#000000'; /* black Text on left bar */
57 $color[7] = '#0000CC'; /* blue Links */
58 $color[8] = '#000000'; /* black Normal text */
59 $color[9] = '#ABABAB'; /* mid-gray Darker version of #0 */
60 $color[10] = '#666666'; /* dark gray Darker version of #9 */
61 $color[11] = '#770000'; /* dark red Special Folders color */
62 $color[12] = '#EDEDED';
63 $color[15] = '#002266'; /* (dark blue) Unselectable folders */
64 }
65 }
66
67 if (!defined('download_php')) { session_register('theme_css'); }
68
69 global $use_javascript_addr_book;
70 $use_javascript_addr_book = getPref($data_dir, $username, 'use_javascript_addr_book', $default_use_javascript_addr_book);
71
72 /* Declare the global variables for the special folders. */
73 global $move_to_sent, $move_to_trash, $save_as_draft;
74
75 /* Load the user's special folder preferences */
76 $move_to_sent =
77 getPref($data_dir, $username, 'move_to_sent', $default_move_to_sent);
78 $move_to_trash =
79 getPref($data_dir, $username, 'move_to_trash', $default_move_to_trash);
80 $save_as_draft =
81 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 if ($default_unseen_notify == '') { $default_unseen_notify = 2; }
86 $unseen_type =
87 getPref($data_dir, $username, 'unseen_type', $default_unseen_type);
88 $unseen_notify =
89 getPref($data_dir, $username, 'unseen_notify', $default_unseen_notify);
90
91 global $folder_prefix;
92 $folder_prefix =
93 getPref($data_dir, $username, 'folder_prefix', $default_folder_prefix);
94
95 /* Declare global variables for special folders. */
96 global $trash_folder, $sent_folder, $draft_folder;
97
98 /* Load special folder - trash */
99 $load_trash_folder = getPref($data_dir, $username, 'trash_folder');
100 if (($load_trash_folder == '') && ($move_to_trash)) {
101 $trash_folder = $folder_prefix . $trash_folder;
102 } else {
103 $trash_folder = $load_trash_folder;
104 }
105
106 /* Load special folder - sent */
107 $load_sent_folder = getPref($data_dir, $username, 'sent_folder');
108 if (($load_sent_folder == '') && ($move_to_sent)) {
109 $sent_folder = $folder_prefix . $sent_folder;
110 } else {
111 $sent_folder = $load_sent_folder;
112 }
113
114 /* Load special folder - draft */
115 $load_draft_folder = getPref($data_dir, $username, 'draft_folder');
116 if (($load_draft_folder == '') && ($save_as_draft)) {
117 $draft_folder = $folder_prefix . $draft_folder;
118 } else {
119 $draft_folder = $load_draft_folder;
120 }
121
122 global $show_num, $wrap_at, $left_size;
123 $show_num = getPref($data_dir, $username, 'show_num', 15 );
124
125 $wrap_at = getPref( $data_dir, $username, 'wrap_at', 86 );
126 if ($wrap_at < 15) { $wrap_at = 15; }
127
128 $left_size = getPref($data_dir, $username, 'left_size');
129 if ($left_size == '') {
130 if (isset($default_left_size)) {
131 $left_size = $default_left_size;
132 } else {
133 $left_size = 200;
134 }
135 }
136
137 global $editor_size, $use_signature, $prefix_sig;
138 $editor_size = getPref($data_dir, $username, 'editor_size', 76 );
139 $use_signature = getPref($data_dir, $username, 'use_signature', SMPREF_OFF );
140 $prefix_sig = getPref($data_dir, $username, 'prefix_sig');
141
142 /* Load preferences for reply citation style. */
143 global $reply_citation_style, $reply_citation_start, $reply_citation_end;
144
145 $reply_citation_style =
146 getPref($data_dir, $username, 'reply_citation_style', SMPREF_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', SMPREF_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 /* Highlight 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 $highlight_array = explode(',', $hlt);
166 $message_highlight_list[$i]['name'] = $highlight_array[0];
167 $message_highlight_list[$i]['color'] = $highlight_array[1];
168 $message_highlight_list[$i]['value'] = $highlight_array[2];
169 $message_highlight_list[$i]['match_type'] = $highlight_array[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 =
189 getPref($data_dir, $username, 'alt_index_colors', SMPREF_ON );
190
191 global $location_of_bar, $location_of_buttons;
192 $location_of_bar =
193 getPref($data_dir, $username, 'location_of_bar', SMPREF_LOC_LEFT);
194 $location_of_buttons =
195 getPref($data_dir, $username, 'location_of_buttons', SMPREF_LOC_BETWEEN);
196
197 global $collapse_folders, $show_html_default, $show_xmailer_default;
198 global $attachment_common_show_images, $pf_subtle_link, $pf_cleandisplay;
199 $collapse_folders =
200 getPref($data_dir, $username, 'collapse_folders', SMPREF_ON);
201
202 /* show_html_default is a int value. */
203 $show_html_default =
204 intval(getPref($data_dir, $username, 'show_html_default', SMPREF_OFF));
205
206 $show_xmailer_default =
207 getPref($data_dir, $username, 'show_xmailer_default', SMPREF_OFF );
208 $attachment_common_show_images = getPref($data_dir, $username, 'attachment_common_show_images', SMPREF_OFF );
209 $pf_subtle_link = getPref($data_dir, $username, 'pf_subtle_link', SMPREF_ON);
210 $pf_cleandisplay = getPref($data_dir, $username, 'pf_cleandisplay', SMPREF_OFF);
211
212 global $include_self_reply_all;
213 $include_self_reply_all =
214 getPref($data_dir, $username, 'include_self_reply_all', SMPREF_ON);
215
216 global $page_selector, $page_selector_max;
217 $page_selector = getPref($data_dir, $username, 'page_selector', SMPREF_ON);
218 $page_selector_max = getPref($data_dir, $username, 'page_selector_max', 10);
219
220 /* SqClock now in the core */
221 global $date_format, $hour_format, $username, $data_dir;
222 $date_format = getPref($data_dir, $username, 'date_format', 3);
223 $hour_format = getPref($data_dir, $username, 'hour_format', 2);
224
225 /* Load the javascript settings. */
226 global $javascript_setting, $javascript_on;
227 $javascript_setting =
228 getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT);
229 $javascript_on = getPref($data_dir, $username, 'javascript_on', SMPREF_ON);
230
231 global $search_memory;
232 $search_memory = getPref($data_dir, $username, 'search_memory', 0);
233
234 do_hook('loading_prefs');
235
236 ?>