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