Removed a lot of the warnings generated when PHP has all warnings enabled.
[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 checkForPrefs($data_dir, $username);
23
24 $chosen_theme = getPref($data_dir, $username, "chosen_theme");
25 $in_ary = false;
26 for ($i=0; $i < count($theme); $i++){
27 if ($theme[$i]["PATH"] == $chosen_theme) {
28 $in_ary = true;
29 break;
30 }
31 }
32 if (!$in_ary) {
33 $chosen_theme = "";
34 }
35
36 if ((isset($chosen_theme)) && (file_exists($chosen_theme))) {
37 require("$chosen_theme");
38 } else {
39 if (file_exists($theme[0]["PATH"])) {
40 require($theme[0]["PATH"]);
41 } else {
42 #
43 # I hard coded the theme as a last resort if no themes were
44 # found. It makes no sense to cause the whole thing to exit
45 # just because themes were not found. This is the absolute
46 # last resort.
47 #
48 $color[0] = "#DCDCDC"; // (light gray) TitleBar
49 $color[1] = "#800000"; // (red)
50 $color[2] = "#CC0000"; // (light red) Warning/Error Messages
51 $color[3] = "#A0B8C8"; // (green-blue) Left Bar Background
52 $color[4] = "#FFFFFF"; // (white) Normal Background
53 $color[5] = "#FFFFCC"; // (light yellow) Table Headers
54 $color[6] = "#000000"; // (black) Text on left bar
55 $color[7] = "#0000CC"; // (blue) Links
56 $color[8] = "#000000"; // (black) Normal text
57 $color[9] = "#ABABAB"; // (mid-gray) Darker version of #0
58 $color[10] = "#666666"; // (dark gray) Darker version of #9
59 $color[11] = "#770000"; // (dark red) Special Folders color
60 }
61 }
62
63 if (!isset($download_php)) session_register("theme_css");
64
65 $use_javascript_addr_book = getPref($data_dir, $username, "use_javascript_addr_book");
66 if ($use_javascript_addr_book == "")
67 $use_javascript_addr_book = $default_use_javascript_addr_book;
68
69
70 /** Load the user's sent folder preferences **/
71 $move_to_sent = getPref($data_dir, $username, "move_to_sent");
72 if ($move_to_sent == "")
73 $move_to_sent = $default_move_to_sent;
74
75 /** Load the user's trash folder preferences **/
76 $move_to_trash = getPref($data_dir, $username, "move_to_trash");
77 if ($move_to_trash == "")
78 $move_to_trash = $default_move_to_trash;
79
80
81 $unseen_type = getPref($data_dir, $username, "unseen_type");
82 if ($default_unseen_type == "")
83 $default_unseen_type = 1;
84 if ($unseen_type == "")
85 $unseen_type = $default_unseen_type;
86
87 $unseen_notify = getPref($data_dir, $username, "unseen_notify");
88 if ($default_unseen_notify == "")
89 $default_unseen_notify = 2;
90 if ($unseen_notify == "")
91 $unseen_notify = $default_unseen_notify;
92
93
94 $folder_prefix = getPref($data_dir, $username, "folder_prefix");
95 if ($folder_prefix == "")
96 $folder_prefix = $default_folder_prefix;
97
98 /** Load special folders **/
99 $new_trash_folder = getPref($data_dir, $username, "trash_folder");
100 if (($new_trash_folder == "") && ($move_to_trash == true))
101 $trash_folder = $folder_prefix . $trash_folder;
102 else
103 $trash_folder = $new_trash_folder;
104
105 /** Load special folders **/
106 $new_sent_folder = getPref($data_dir, $username, "sent_folder");
107 if (($new_sent_folder == "") && ($move_to_sent == true))
108 $sent_folder = $folder_prefix . $sent_folder;
109 else
110 $sent_folder = $new_sent_folder;
111
112 $show_num = getPref($data_dir, $username, "show_num");
113 if ($show_num == "")
114 $show_num = 25;
115
116 $wrap_at = getPref($data_dir, $username, "wrap_at");
117 if ($wrap_at == "")
118 $wrap_at = 86;
119 if ($wrap_at < 15)
120 $wrap_at = 15;
121
122 $left_size = getPref($data_dir, $username, "left_size");
123 if ($left_size == "") {
124 if (isset($default_left_size))
125 $left_size = $default_left_size;
126 else
127 $left_size = 200;
128 }
129
130 $editor_size = getPref($data_dir, $username, "editor_size");
131 if ($editor_size == "")
132 $editor_size = 76;
133
134 $use_signature = getPref($data_dir, $username, "use_signature");
135 if ($use_signature == "")
136 $use_signature = false;
137
138 $left_refresh = getPref($data_dir, $username, "left_refresh");
139 if ($left_refresh == "")
140 $left_refresh = false;
141
142 $sort = getPref($data_dir, $username, "sort");
143 if ($sort == "")
144 $sort = 6;
145
146 /** Load up the Signature file **/
147 if ($use_signature == true) {
148 $signature_abs = $signature = getSig($data_dir, $username);
149 } else {
150 $signature_abs = getSig($data_dir, $username);
151 }
152
153 // highlightX comes in with the form: name,color,header,value
154 for ($i=0; $hlt = getPref($data_dir, $username, "highlight$i"); $i++) {
155 $ary = explode(",", $hlt);
156 $message_highlight_list[$i]["name"] = $ary[0];
157 $message_highlight_list[$i]["color"] = $ary[1];
158 $message_highlight_list[$i]["value"] = $ary[2];
159 $message_highlight_list[$i]["match_type"] = $ary[3];
160 }
161
162 #index order lets you change the order of the message index
163 $order = getPref($data_dir, $username, "order1");
164 for ($i=1; $order; $i++) {
165 $index_order[$i] = $order;
166 $order = getPref($data_dir, $username, "order".($i+1));
167 }
168 if (!$index_order) {
169 $index_order[1] = 1;
170 $index_order[2] = 2;
171 $index_order[3] = 3;
172 $index_order[4] = 5;
173 $index_order[5] = 4;
174 }
175
176 $location_of_bar = getPref($data_dir, $username, 'location_of_bar');
177 if ($location_of_bar == '')
178 $location_of_bar = 'left';
179
180 $location_of_buttons = getPref($data_dir, $username, 'location_of_buttons');
181 if ($location_of_buttons == '')
182 $location_of_buttons = 'between';
183
184 do_hook("loading_prefs");
185
186 ?>