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