* Better error message
[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 (!isset($config_php))
15 include("../config/config.php");
16 if (!isset($prefs_php))
17 include("../functions/prefs.php");
18 if (!isset($plugin_php))
19 include("../functions/plugin.php");
20
21 $load_prefs_php = true;
22 if (!isset($username))
23 $username = '';
24 checkForPrefs($data_dir, $username);
25
26 $chosen_theme = getPref($data_dir, $username, "chosen_theme");
27 $in_ary = false;
28 for ($i=0; $i < count($theme); $i++){
29 if ($theme[$i]["PATH"] == $chosen_theme) {
30 $in_ary = true;
31 break;
32 }
33 }
34 if (!$in_ary) {
35 $chosen_theme = "";
36 }
37
38 if ((isset($chosen_theme)) && (file_exists($chosen_theme))) {
39 $loaded=@include("$chosen_theme");
40 } else {
41 if (file_exists($theme[0]["PATH"])) {
42 require($theme[0]["PATH"]);
43 } else {
44 #
45 # I hard coded the theme as a last resort if no themes were
46 # found. It makes no sense to cause the whole thing to exit
47 # just because themes were not found. This is the absolute
48 # 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 }
63 }
64 if (!isset($loaded))
65 echo _("Unable to load chosen theme file:") . ' "' .
66 $chosen_theme . '"';
67 if (!isset($download_php)) session_register("theme_css");
68
69 $use_javascript_addr_book = getPref($data_dir, $username, "use_javascript_addr_book");
70 if ($use_javascript_addr_book == "")
71 $use_javascript_addr_book = $default_use_javascript_addr_book;
72
73
74 /** Load the user's sent folder preferences **/
75 $move_to_sent = getPref($data_dir, $username, "move_to_sent");
76 if ($move_to_sent == "")
77 $move_to_sent = $default_move_to_sent;
78
79 /** Load the user's trash folder preferences **/
80 $move_to_trash = getPref($data_dir, $username, "move_to_trash");
81 if ($move_to_trash == "")
82 $move_to_trash = $default_move_to_trash;
83
84
85 $unseen_type = getPref($data_dir, $username, "unseen_type");
86 if ($default_unseen_type == "")
87 $default_unseen_type = 1;
88 if ($unseen_type == "")
89 $unseen_type = $default_unseen_type;
90
91 $unseen_notify = getPref($data_dir, $username, "unseen_notify");
92 if ($default_unseen_notify == "")
93 $default_unseen_notify = 2;
94 if ($unseen_notify == "")
95 $unseen_notify = $default_unseen_notify;
96
97
98 $folder_prefix = getPref($data_dir, $username, "folder_prefix");
99 if ($folder_prefix == "")
100 $folder_prefix = $default_folder_prefix;
101
102 /** Load special folders **/
103 $new_trash_folder = getPref($data_dir, $username, "trash_folder");
104 if (($new_trash_folder == "") && ($move_to_trash == true))
105 $trash_folder = $folder_prefix . $trash_folder;
106 else
107 $trash_folder = $new_trash_folder;
108
109 /** Load special folders **/
110 $new_sent_folder = getPref($data_dir, $username, "sent_folder");
111 if (($new_sent_folder == "") && ($move_to_sent == true))
112 $sent_folder = $folder_prefix . $sent_folder;
113 else
114 $sent_folder = $new_sent_folder;
115
116 $show_num = getPref($data_dir, $username, "show_num");
117 if ($show_num == "")
118 $show_num = 25;
119
120 $wrap_at = getPref($data_dir, $username, "wrap_at");
121 if ($wrap_at == "")
122 $wrap_at = 86;
123 if ($wrap_at < 15)
124 $wrap_at = 15;
125
126 $left_size = getPref($data_dir, $username, "left_size");
127 if ($left_size == "") {
128 if (isset($default_left_size))
129 $left_size = $default_left_size;
130 else
131 $left_size = 200;
132 }
133
134 $editor_size = getPref($data_dir, $username, "editor_size");
135 if ($editor_size == "")
136 $editor_size = 76;
137
138 $use_signature = getPref($data_dir, $username, "use_signature");
139 if ($use_signature == "")
140 $use_signature = false;
141
142 $prefix_sig = getPref($data_dir, $username, "prefix_sig");
143 if ($prefix_sig == "")
144 $prefix_sig = false;
145
146 $left_refresh = getPref($data_dir, $username, "left_refresh");
147 if ($left_refresh == "")
148 $left_refresh = false;
149
150 $sort = getPref($data_dir, $username, "sort");
151 if ($sort == "")
152 $sort = 6;
153
154 /** Load up the Signature file **/
155 if ($use_signature == true) {
156 $signature_abs = $signature = getSig($data_dir, $username);
157 } else {
158 $signature_abs = getSig($data_dir, $username);
159 }
160
161 // highlightX comes in with the form: name,color,header,value
162 for ($i=0; $hlt = getPref($data_dir, $username, "highlight$i"); $i++) {
163 $ary = explode(",", $hlt);
164 $message_highlight_list[$i]["name"] = $ary[0];
165 $message_highlight_list[$i]["color"] = $ary[1];
166 $message_highlight_list[$i]["value"] = $ary[2];
167 $message_highlight_list[$i]["match_type"] = $ary[3];
168 }
169
170 #index order lets you change the order of the message index
171 $order = getPref($data_dir, $username, "order1");
172 for ($i=1; $order; $i++) {
173 $index_order[$i] = $order;
174 $order = getPref($data_dir, $username, "order".($i+1));
175 }
176 if (!isset($index_order)) {
177 $index_order[1] = 1;
178 $index_order[2] = 2;
179 $index_order[3] = 3;
180 $index_order[4] = 5;
181 $index_order[5] = 4;
182 }
183
184 $location_of_bar = getPref($data_dir, $username, 'location_of_bar');
185 if ($location_of_bar == '')
186 $location_of_bar = 'left';
187
188 $location_of_buttons = getPref($data_dir, $username, 'location_of_buttons');
189 if ($location_of_buttons == '')
190 $location_of_buttons = 'between';
191
192 $collapse_folders = getPref($data_dir, $username, 'collapse_folders');
193
194 $show_html_default = getPref($data_dir, $username, 'show_html_default');
195
196 do_hook("loading_prefs");
197
198 ?>