integrated printer_friendly into the core
[squirrelmail.git] / src / load_prefs.php
CommitLineData
59177427 1<?php
f7b1b3b1 2 /**
3 * load_prefs.php
4 *
5 * Copyright (c) 1999-2001 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 require_once('../src/validate.php');
15
16 /**************************************************************/
23d6bd09 17 /* Following code should be removed in the next foo_once step */
f7b1b3b1 18 if (defined('load_prefs_php')) { return; }
19 define('load_prefs_php', true);
20 /**************************************************************/
21
22 global $theme, $chosen_theme, $color;
23 if (! isset($theme)) { $theme = array(); }
24 if (! isset($color)) { $color = array(); }
25 require_once('../functions/prefs.php');
26 require_once('../functions/plugin.php');
23d6bd09 27 require_once('../functions/constants.php');
37df47f5 28
f7b1b3b1 29 if (!isset($username)) { $username = ''; }
30 checkForPrefs($data_dir, $username);
31
32 $chosen_theme = getPref($data_dir, $username, "chosen_theme");
33 $in_ary = false;
34 for ($i=0; $i < count($theme); $i++){
35 if ($theme[$i]["PATH"] == $chosen_theme) {
36 $in_ary = true;
37 break;
38 }
39 }
40 if (! $in_ary) { $chosen_theme = ""; }
41
42 if (isset($chosen_theme) && $in_ary && (file_exists($chosen_theme))) {
43 @include_once($chosen_theme);
44 } else {
45 if (isset($theme) && isset($theme[0])
46 && file_exists($theme[0]["PATH"])) {
47 @include_once($theme[0]["PATH"]);
48 } else {
49 /**
50 * This theme as a failsafe if no themes were found. It makes
51 * no sense to cause the whole thing to exit just because themes
52 * were not found. This is the absolute last resort.
53 */
54 $color[0] = "#DCDCDC"; // light gray TitleBar
55 $color[1] = "#800000"; // red
56 $color[2] = "#CC0000"; // light red Warning/Error Messages
57 $color[3] = "#A0B8C8"; // green-blue Left Bar Background
58 $color[4] = "#FFFFFF"; // white Normal Background
59 $color[5] = "#FFFFCC"; // light yellow Table Headers
60 $color[6] = "#000000"; // black Text on left bar
61 $color[7] = "#0000CC"; // blue Links
62 $color[8] = "#000000"; // black Normal text
63 $color[9] = "#ABABAB"; // mid-gray Darker version of #0
64 $color[10] = "#666666"; // dark gray Darker version of #9
65 $color[11] = "#770000"; // dark red Special Folders color
66 }
67 }
68
69 if (!defined('download_php')) { session_register("theme_css"); }
70
71 global $use_javascript_addr_book;
72 $use_javascript_addr_book = getPref($data_dir, $username, 'use_javascript_addr_book', $default_use_javascript_addr_book);
73
74 /** Declare the global variables for the special folders. */
75 global $move_to_sent, $move_to_trash, $save_as_draft;
76
f7b1b3b1 77 /** Load the user's special folder preferences **/
78 $move_to_sent = getPref($data_dir, $username, 'move_to_sent', $default_move_to_sent);
79 $move_to_trash = getPref($data_dir, $username, 'move_to_trash', $default_move_to_trash);
80 $save_as_draft = getPref($data_dir, $username, 'save_as_draft', $default_save_as_draft);
81
82 global $unseen_type, $unseen_notify;
83 if ($default_unseen_type == '') { $default_unseen_type = 1; }
84 $unseen_type = getPref($data_dir, $username, 'unseen_type', $default_unseen_type);
85 if ($default_unseen_notify == '') { $default_unseen_notify = 2; }
86 $unseen_notify = getPref($data_dir, $username, 'unseen_notify', $default_unseen_notify);
87
88 global $folder_prefix;
89 $folder_prefix = getPref($data_dir, $username, 'folder_prefix', $default_folder_prefix);
90
91 /* Declare global variables for special folders. */
92 global $trash_folder, $sent_folder, $draft_folder;
93
94 /** Load special folder - trash **/
b5efadfa 95 $load_trash_folder = getPref($data_dir, $username, 'trash_folder');
96 if (($load_trash_folder == '') && ($move_to_trash)) {
f7b1b3b1 97 $trash_folder = $folder_prefix . $trash_folder;
98 } else {
b5efadfa 99 $trash_folder = $load_trash_folder;
f7b1b3b1 100 }
101
102 /** Load special folder - sent **/
b5efadfa 103 $load_sent_folder = getPref($data_dir, $username, 'sent_folder');
104 if (($load_sent_folder == '') && ($move_to_sent)) {
f7b1b3b1 105 $sent_folder = $folder_prefix . $sent_folder;
106 } else {
b5efadfa 107 $sent_folder = $load_sent_folder;
f7b1b3b1 108 }
109
110 /** Load special folder - draft **/
b5efadfa 111 $load_draft_folder = getPref($data_dir, $username, 'draft_folder');
112 if (($load_draft_folder == '') && ($save_as_draft)) {
f7b1b3b1 113 $draft_folder = $folder_prefix . $draft_folder;
114 } else {
b5efadfa 115 $draft_folder = $load_draft_folder;
f7b1b3b1 116 }
117
118 global $show_num, $wrap_at, $left_size;
119 $show_num = getPref($data_dir, $username, 'show_num', 15 );
120
121 $wrap_at = getPref( $data_dir, $username, 'wrap_at', 86 );
122 if ($wrap_at < 15) { $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
133 global $editor_size, $use_signature, $prefix_sig;
134 $editor_size = getPref($data_dir, $username, "editor_size", 76 );
135
fd87494d 136 $use_signature = getPref($data_dir, $username, 'use_signature', SMPREF_OFF );
f7b1b3b1 137
138 $prefix_sig = getPref($data_dir, $username, "prefix_sig");
139
140 /* Load preferences for reply citation style. */
141 global $reply_citation_style, $reply_citation_start, $reply_citation_end;
142
fd87494d 143 $reply_citation_style = getPref($data_dir, $username, 'reply_citation_style', SMPREF_NONE );
f7b1b3b1 144 $reply_citation_start = getPref($data_dir, $username, 'reply_citation_start');
145 $reply_citation_end = getPref($data_dir, $username, 'reply_citation_end');
146
147 global $left_refresh, $sort;
fd87494d 148 $left_refresh = getPref($data_dir, $username, 'left_refresh', SMPREF_NONE );
f7b1b3b1 149 $sort = getPref($data_dir, $username, 'sort', 6 );
150
151 /** Load up the Signature file **/
152 global $signature_abs;
153 if ($use_signature) {
154 $signature_abs = $signature = getSig($data_dir, $username);
155 } else {
156 $signature_abs = getSig($data_dir, $username);
157 }
158
159 /* HighlightX comes in with the form: name, color, header, value. */
160 global $message_highlight_list;
161 for ($i=0; $hlt = getPref($data_dir, $username, "highlight$i"); $i++) {
162 $ary = explode(",", $hlt);
163 $message_highlight_list[$i]['name'] = $ary[0];
164 $message_highlight_list[$i]['color'] = $ary[1];
165 $message_highlight_list[$i]['value'] = $ary[2];
166 $message_highlight_list[$i]['match_type'] = $ary[3];
167 }
168
169 /* Index order lets you change the order of the message index */
170 global $index_order;
171 $order = getPref($data_dir, $username, 'order1');
172 for ($i=1; $order; $i++) {
173 $index_order[$i] = $order;
174 $order = getPref($data_dir, $username, 'order'.($i+1));
175 }
176 if (!isset($index_order)) {
177 $index_order[1] = 1;
178 $index_order[2] = 2;
179 $index_order[3] = 3;
180 $index_order[4] = 5;
181 $index_order[5] = 4;
182 }
183
184 global $alt_index_colors;
fd87494d 185 $alt_index_colors = getPref($data_dir, $username, 'alt_index_colors', SMPREF_ON );
f7b1b3b1 186
187 global $location_of_bar, $location_of_buttons;
fd87494d 188 $location_of_bar = getPref($data_dir, $username, 'location_of_bar', SMPREF_LOC_LEFT);
189 $location_of_buttons = getPref($data_dir, $username, 'location_of_buttons', SMPREF_LOC_BETWEEN);
f7b1b3b1 190
f226cba7 191 global $collapse_folders, $show_html_default, $show_xmailer_default,
192 $attachment_common_show_images, $pf_subtle_link, $pf_cleandisplay;
fd87494d 193 $collapse_folders = getPref($data_dir, $username, 'collapse_folders', SMPREF_ON);
f7b1b3b1 194
195 /* show_html_default is a int value. */
fd87494d 196 $show_html_default = intval(getPref($data_dir, $username, 'show_html_default', SMPREF_ON));
f226cba7 197
198 $show_xmailer_default = getPref($data_dir, $username, 'show_xmailer_default', SMPREF_OFF );
199 $attachment_common_show_images = getPref($data_dir, $username, 'attachment_common_show_images', SMPREF_OFF );
200 $pf_subtle_link = getPref($data_dir, $username, 'pf_subtle_link', SMPREF_OFF);
201 $pf_cleandisplay = getPref($data_dir, $username, 'pf_cleandisplay', SMPREF_OFF);
fd87494d 202
203 global $include_self_reply_all;
204 $include_self_reply_all = getPref($data_dir, $username, 'include_self_reply_all', SMPREF_ON);
205
206 global $page_selector, $page_selector_max;
207 $page_selector = getPref($data_dir, $username, 'page_selector', SMPREF_ON);
208 $page_selector_max = getPref($data_dir, $username, 'page_selector_max', 10);
2016e645 209
23d6bd09 210 /* SqClock now in the core */
2016e645 211 global $date_format, $hour_format, $username, $data_dir;
2016e645 212 $date_format = getPref($data_dir, $username, 'date_format', 3);
213 $hour_format = getPref($data_dir, $username, 'hour_format', 2);
f7b1b3b1 214
23d6bd09 215 /* Load the javascript settings. */
216 global $javascript_setting, $javascript_on;
217 $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT);
fd87494d 218 $javascript_on = getPref($data_dir, $username, 'javascript_on', SMPREF_ON);
23d6bd09 219
f7b1b3b1 220 do_hook("loading_prefs");
209663b7 221?>