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