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