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