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