* Removed the unnecessary function replace_escaped_spaces (never used)
[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 require("$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
65 if (!isset($download_php)) session_register("theme_css");
66
67 $use_javascript_addr_book = getPref($data_dir, $username, "use_javascript_addr_book");
68 if ($use_javascript_addr_book == "")
69 $use_javascript_addr_book = $default_use_javascript_addr_book;
70
71
72 /** Load the user's sent folder preferences **/
73 $move_to_sent = getPref($data_dir, $username, "move_to_sent");
74 if ($move_to_sent == "")
75 $move_to_sent = $default_move_to_sent;
76
77 /** Load the user's trash folder preferences **/
78 $move_to_trash = getPref($data_dir, $username, "move_to_trash");
79 if ($move_to_trash == "")
80 $move_to_trash = $default_move_to_trash;
81
82
83 $unseen_type = getPref($data_dir, $username, "unseen_type");
84 if ($default_unseen_type == "")
85 $default_unseen_type = 1;
86 if ($unseen_type == "")
87 $unseen_type = $default_unseen_type;
88
89 $unseen_notify = getPref($data_dir, $username, "unseen_notify");
90 if ($default_unseen_notify == "")
91 $default_unseen_notify = 2;
92 if ($unseen_notify == "")
93 $unseen_notify = $default_unseen_notify;
94
95
96 $folder_prefix = getPref($data_dir, $username, "folder_prefix");
97 if ($folder_prefix == "")
98 $folder_prefix = $default_folder_prefix;
99
100 /** Load special folders **/
101 $new_trash_folder = getPref($data_dir, $username, "trash_folder");
102 if (($new_trash_folder == "") && ($move_to_trash == true))
103 $trash_folder = $folder_prefix . $trash_folder;
104 else
105 $trash_folder = $new_trash_folder;
106
107 /** Load special folders **/
108 $new_sent_folder = getPref($data_dir, $username, "sent_folder");
109 if (($new_sent_folder == "") && ($move_to_sent == true))
110 $sent_folder = $folder_prefix . $sent_folder;
111 else
112 $sent_folder = $new_sent_folder;
113
114 $show_num = getPref($data_dir, $username, "show_num");
115 if ($show_num == "")
116 $show_num = 25;
117
118 $wrap_at = getPref($data_dir, $username, "wrap_at");
119 if ($wrap_at == "")
120 $wrap_at = 86;
121 if ($wrap_at < 15)
122 $wrap_at = 15;
123
124 $left_size = getPref($data_dir, $username, "left_size");
125 if ($left_size == "") {
126 if (isset($default_left_size))
127 $left_size = $default_left_size;
128 else
129 $left_size = 200;
130 }
131
132 $editor_size = getPref($data_dir, $username, "editor_size");
133 if ($editor_size == "")
134 $editor_size = 76;
135
136 $use_signature = getPref($data_dir, $username, "use_signature");
137 if ($use_signature == "")
138 $use_signature = false;
139
140 $left_refresh = getPref($data_dir, $username, "left_refresh");
141 if ($left_refresh == "")
142 $left_refresh = false;
143
144 $sort = getPref($data_dir, $username, "sort");
145 if ($sort == "")
146 $sort = 6;
147
148 /** Load up the Signature file **/
149 if ($use_signature == true) {
150 $signature_abs = $signature = getSig($data_dir, $username);
151 } else {
152 $signature_abs = getSig($data_dir, $username);
153 }
154
155 // highlightX comes in with the form: name,color,header,value
156 for ($i=0; $hlt = getPref($data_dir, $username, "highlight$i"); $i++) {
157 $ary = explode(",", $hlt);
158 $message_highlight_list[$i]["name"] = $ary[0];
159 $message_highlight_list[$i]["color"] = $ary[1];
160 $message_highlight_list[$i]["value"] = $ary[2];
161 $message_highlight_list[$i]["match_type"] = $ary[3];
162 }
163
164 #index order lets you change the order of the message index
165 $order = getPref($data_dir, $username, "order1");
166 for ($i=1; $order; $i++) {
167 $index_order[$i] = $order;
168 $order = getPref($data_dir, $username, "order".($i+1));
169 }
170 if (!isset($index_order)) {
171 $index_order[1] = 1;
172 $index_order[2] = 2;
173 $index_order[3] = 3;
174 $index_order[4] = 5;
175 $index_order[5] = 4;
176 }
177
178 $location_of_bar = getPref($data_dir, $username, 'location_of_bar');
179 if ($location_of_bar == '')
180 $location_of_bar = 'left';
181
182 $location_of_buttons = getPref($data_dir, $username, 'location_of_buttons');
183 if ($location_of_buttons == '')
184 $location_of_buttons = 'between';
185
186 $collapse_folders = getPref($data_dir, $username, 'collapse_folders');
187
188 do_hook("loading_prefs");
189
190 ?>