Added sent_subfolders plugin, tweaked config stuff, other stuff.
[squirrelmail.git] / src / load_prefs.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * load_prefs.php
5 *
6 * Copyright (c) 1999-2001 The Squirrelmail Development Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Loads preferences from the $username.pref file used by almost
10 * every other script in the source directory and alswhere.
11 *
12 * $Id$
13 */
f7b1b3b1 14
35586184 15/*****************************************************************/
16/*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/
17/*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/
18/*** + Base level indent should begin at left margin, as ***/
19/*** the require_once below looks. ***/
20/*** + All identation should consist of four space blocks ***/
21/*** + Tab characters are evil. ***/
22/*** + all comments should use "slash-star ... star-slash" ***/
23/*** style -- no pound characters, no slash-slash style ***/
24/*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/
25/*** ALWAYS USE { AND } CHARACTERS!!! ***/
26/*** + Please use ' instead of ", when possible. Note " ***/
27/*** should always be used in _( ) function calls. ***/
28/*** Thank you for your help making the SM code more readable. ***/
29/*****************************************************************/
f7b1b3b1 30
35586184 31require_once('../src/validate.php');
f7b1b3b1 32
33 global $theme, $chosen_theme, $color;
34 if (! isset($theme)) { $theme = array(); }
35 if (! isset($color)) { $color = array(); }
36 require_once('../functions/prefs.php');
37 require_once('../functions/plugin.php');
23d6bd09 38 require_once('../functions/constants.php');
37df47f5 39
f7b1b3b1 40 if (!isset($username)) { $username = ''; }
f7b1b3b1 41
42 $chosen_theme = getPref($data_dir, $username, "chosen_theme");
43 $in_ary = false;
44 for ($i=0; $i < count($theme); $i++){
45 if ($theme[$i]["PATH"] == $chosen_theme) {
46 $in_ary = true;
47 break;
48 }
49 }
50 if (! $in_ary) { $chosen_theme = ""; }
51
52 if (isset($chosen_theme) && $in_ary && (file_exists($chosen_theme))) {
53 @include_once($chosen_theme);
54 } else {
55 if (isset($theme) && isset($theme[0])
56 && file_exists($theme[0]["PATH"])) {
57 @include_once($theme[0]["PATH"]);
58 } else {
59 /**
60 * This theme as a failsafe if no themes were found. It makes
61 * no sense to cause the whole thing to exit just because themes
62 * were not found. This is the absolute last resort.
63 */
64 $color[0] = "#DCDCDC"; // light gray TitleBar
65 $color[1] = "#800000"; // red
66 $color[2] = "#CC0000"; // light red Warning/Error Messages
67 $color[3] = "#A0B8C8"; // green-blue Left Bar Background
68 $color[4] = "#FFFFFF"; // white Normal Background
69 $color[5] = "#FFFFCC"; // light yellow Table Headers
70 $color[6] = "#000000"; // black Text on left bar
71 $color[7] = "#0000CC"; // blue Links
72 $color[8] = "#000000"; // black Normal text
73 $color[9] = "#ABABAB"; // mid-gray Darker version of #0
74 $color[10] = "#666666"; // dark gray Darker version of #9
75 $color[11] = "#770000"; // dark red Special Folders color
76 }
77 }
78
79 if (!defined('download_php')) { session_register("theme_css"); }
80
81 global $use_javascript_addr_book;
82 $use_javascript_addr_book = getPref($data_dir, $username, 'use_javascript_addr_book', $default_use_javascript_addr_book);
83
84 /** Declare the global variables for the special folders. */
85 global $move_to_sent, $move_to_trash, $save_as_draft;
86
f7b1b3b1 87 /** Load the user's special folder preferences **/
88 $move_to_sent = getPref($data_dir, $username, 'move_to_sent', $default_move_to_sent);
89 $move_to_trash = getPref($data_dir, $username, 'move_to_trash', $default_move_to_trash);
90 $save_as_draft = getPref($data_dir, $username, 'save_as_draft', $default_save_as_draft);
91
92 global $unseen_type, $unseen_notify;
93 if ($default_unseen_type == '') { $default_unseen_type = 1; }
94 $unseen_type = getPref($data_dir, $username, 'unseen_type', $default_unseen_type);
95 if ($default_unseen_notify == '') { $default_unseen_notify = 2; }
96 $unseen_notify = getPref($data_dir, $username, 'unseen_notify', $default_unseen_notify);
97
98 global $folder_prefix;
99 $folder_prefix = getPref($data_dir, $username, 'folder_prefix', $default_folder_prefix);
100
101 /* Declare global variables for special folders. */
102 global $trash_folder, $sent_folder, $draft_folder;
103
104 /** Load special folder - trash **/
b5efadfa 105 $load_trash_folder = getPref($data_dir, $username, 'trash_folder');
106 if (($load_trash_folder == '') && ($move_to_trash)) {
f7b1b3b1 107 $trash_folder = $folder_prefix . $trash_folder;
108 } else {
b5efadfa 109 $trash_folder = $load_trash_folder;
f7b1b3b1 110 }
111
112 /** Load special folder - sent **/
b5efadfa 113 $load_sent_folder = getPref($data_dir, $username, 'sent_folder');
114 if (($load_sent_folder == '') && ($move_to_sent)) {
f7b1b3b1 115 $sent_folder = $folder_prefix . $sent_folder;
116 } else {
b5efadfa 117 $sent_folder = $load_sent_folder;
f7b1b3b1 118 }
119
120 /** Load special folder - draft **/
b5efadfa 121 $load_draft_folder = getPref($data_dir, $username, 'draft_folder');
122 if (($load_draft_folder == '') && ($save_as_draft)) {
f7b1b3b1 123 $draft_folder = $folder_prefix . $draft_folder;
124 } else {
b5efadfa 125 $draft_folder = $load_draft_folder;
f7b1b3b1 126 }
127
128 global $show_num, $wrap_at, $left_size;
129 $show_num = getPref($data_dir, $username, 'show_num', 15 );
130
131 $wrap_at = getPref( $data_dir, $username, 'wrap_at', 86 );
132 if ($wrap_at < 15) { $wrap_at = 15; }
133
134 $left_size = getPref($data_dir, $username, 'left_size');
135 if ($left_size == "") {
136 if (isset($default_left_size)) {
137 $left_size = $default_left_size;
138 } else {
139 $left_size = 200;
140 }
141 }
142
143 global $editor_size, $use_signature, $prefix_sig;
144 $editor_size = getPref($data_dir, $username, "editor_size", 76 );
145
fd87494d 146 $use_signature = getPref($data_dir, $username, 'use_signature', SMPREF_OFF );
f7b1b3b1 147
148 $prefix_sig = getPref($data_dir, $username, "prefix_sig");
149
150 /* Load preferences for reply citation style. */
151 global $reply_citation_style, $reply_citation_start, $reply_citation_end;
152
fd87494d 153 $reply_citation_style = getPref($data_dir, $username, 'reply_citation_style', SMPREF_NONE );
f7b1b3b1 154 $reply_citation_start = getPref($data_dir, $username, 'reply_citation_start');
155 $reply_citation_end = getPref($data_dir, $username, 'reply_citation_end');
156
157 global $left_refresh, $sort;
fd87494d 158 $left_refresh = getPref($data_dir, $username, 'left_refresh', SMPREF_NONE );
f7b1b3b1 159 $sort = getPref($data_dir, $username, 'sort', 6 );
160
161 /** Load up the Signature file **/
162 global $signature_abs;
163 if ($use_signature) {
164 $signature_abs = $signature = getSig($data_dir, $username);
165 } else {
166 $signature_abs = getSig($data_dir, $username);
167 }
168
169 /* HighlightX comes in with the form: name, color, header, value. */
170 global $message_highlight_list;
171 for ($i=0; $hlt = getPref($data_dir, $username, "highlight$i"); $i++) {
172 $ary = explode(",", $hlt);
173 $message_highlight_list[$i]['name'] = $ary[0];
174 $message_highlight_list[$i]['color'] = $ary[1];
175 $message_highlight_list[$i]['value'] = $ary[2];
176 $message_highlight_list[$i]['match_type'] = $ary[3];
177 }
178
179 /* Index order lets you change the order of the message index */
180 global $index_order;
181 $order = getPref($data_dir, $username, 'order1');
182 for ($i=1; $order; $i++) {
183 $index_order[$i] = $order;
184 $order = getPref($data_dir, $username, 'order'.($i+1));
185 }
186 if (!isset($index_order)) {
187 $index_order[1] = 1;
188 $index_order[2] = 2;
189 $index_order[3] = 3;
190 $index_order[4] = 5;
191 $index_order[5] = 4;
192 }
193
194 global $alt_index_colors;
fd87494d 195 $alt_index_colors = getPref($data_dir, $username, 'alt_index_colors', SMPREF_ON );
f7b1b3b1 196
197 global $location_of_bar, $location_of_buttons;
fd87494d 198 $location_of_bar = getPref($data_dir, $username, 'location_of_bar', SMPREF_LOC_LEFT);
199 $location_of_buttons = getPref($data_dir, $username, 'location_of_buttons', SMPREF_LOC_BETWEEN);
f7b1b3b1 200
f226cba7 201 global $collapse_folders, $show_html_default, $show_xmailer_default,
202 $attachment_common_show_images, $pf_subtle_link, $pf_cleandisplay;
fd87494d 203 $collapse_folders = getPref($data_dir, $username, 'collapse_folders', SMPREF_ON);
f7b1b3b1 204
205 /* show_html_default is a int value. */
fd87494d 206 $show_html_default = intval(getPref($data_dir, $username, 'show_html_default', SMPREF_ON));
f226cba7 207
208 $show_xmailer_default = getPref($data_dir, $username, 'show_xmailer_default', SMPREF_OFF );
209 $attachment_common_show_images = getPref($data_dir, $username, 'attachment_common_show_images', SMPREF_OFF );
3cebb0a5 210 $pf_subtle_link = getPref($data_dir, $username, 'pf_subtle_link', SMPREF_ON);
f226cba7 211 $pf_cleandisplay = getPref($data_dir, $username, 'pf_cleandisplay', SMPREF_OFF);
fd87494d 212
213 global $include_self_reply_all;
214 $include_self_reply_all = getPref($data_dir, $username, 'include_self_reply_all', SMPREF_ON);
215
216 global $page_selector, $page_selector_max;
217 $page_selector = getPref($data_dir, $username, 'page_selector', SMPREF_ON);
218 $page_selector_max = getPref($data_dir, $username, 'page_selector_max', 10);
2016e645 219
23d6bd09 220 /* SqClock now in the core */
2016e645 221 global $date_format, $hour_format, $username, $data_dir;
2016e645 222 $date_format = getPref($data_dir, $username, 'date_format', 3);
223 $hour_format = getPref($data_dir, $username, 'hour_format', 2);
f7b1b3b1 224
23d6bd09 225 /* Load the javascript settings. */
226 global $javascript_setting, $javascript_on;
227 $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT);
fd87494d 228 $javascript_on = getPref($data_dir, $username, 'javascript_on', SMPREF_ON);
23d6bd09 229
f7b1b3b1 230 do_hook("loading_prefs");
209663b7 231?>