should be false by default (sorry, again) ;-P
[squirrelmail.git] / src / load_prefs.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * load_prefs.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
35586184 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 15require_once('../src/validate.php');
0f2447d8 16require_once('../functions/prefs.php');
17require_once('../functions/plugin.php');
18require_once('../functions/constants.php');
19
20$username = ( !isset($username) ? '' : $username );
21
8f1ba72b 22$custom_css = getPref($data_dir, $username, 'custom_css', 'none' );
23
0f2447d8 24$theme = ( !isset($theme) ? array() : $theme );
25$color = ( !isset($color) ? array() : $color );
26
b3a5c9f7 27$chosen_theme = getPref($data_dir, $username, 'chosen_theme');
0f2447d8 28$found_theme = false;
0842b54b 29for ($i = 0; $i < count($theme); ++$i){
0f2447d8 30 if ($theme[$i]['PATH'] == $chosen_theme) {
31 $found_theme = true;
32 break;
f7b1b3b1 33 }
0f2447d8 34}
35$chosen_theme = (!$found_theme ? '' : $chosen_theme);
36
37if (isset($chosen_theme) && $found_theme && (file_exists($chosen_theme))) {
38 @include_once($chosen_theme);
39} else {
40 if (isset($theme) && isset($theme[0]) && file_exists($theme[0]['PATH'])) {
41 @include_once($theme[0]['PATH']);
f7b1b3b1 42 } else {
0f2447d8 43 /**
44 * This theme as a failsafe if no themes were found. It makes
45 * no sense to cause the whole thing to exit just because themes
46 * were not found. This is the absolute 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 */
b3a5c9f7 60 $color[12] = '#EDEDED';
61 $color[15] = '#002266'; /* (dark blue) Unselectable folders */
f7b1b3b1 62 }
0f2447d8 63}
64
99e3bfd0 65if (!defined('download_php')) {
66 session_register('theme_css');
67}
0f2447d8 68
0f2447d8 69$use_javascript_addr_book = getPref($data_dir, $username, 'use_javascript_addr_book', $default_use_javascript_addr_book);
70
0842b54b 71/* Load the user's special folder preferences */
72$move_to_sent =
73 getPref($data_dir, $username, 'move_to_sent', $default_move_to_sent);
74$move_to_trash =
75 getPref($data_dir, $username, 'move_to_trash', $default_move_to_trash);
76$save_as_draft =
77 getPref($data_dir, $username, 'save_as_draft', $default_save_as_draft);
0f2447d8 78
99e3bfd0 79if ($default_unseen_type == '') {
80 $default_unseen_type = 1;
81}
82if ($default_unseen_notify == '') {
83 $default_unseen_notify = 2;
84}
0842b54b 85$unseen_type =
86 getPref($data_dir, $username, 'unseen_type', $default_unseen_type);
87$unseen_notify =
88 getPref($data_dir, $username, 'unseen_notify', $default_unseen_notify);
0f2447d8 89
0842b54b 90$folder_prefix =
91 getPref($data_dir, $username, 'folder_prefix', $default_folder_prefix);
0f2447d8 92
0842b54b 93/* Load special folder - trash */
0f2447d8 94$load_trash_folder = getPref($data_dir, $username, 'trash_folder');
95if (($load_trash_folder == '') && ($move_to_trash)) {
96 $trash_folder = $folder_prefix . $trash_folder;
97} else {
98 $trash_folder = $load_trash_folder;
99}
100
0842b54b 101/* Load special folder - sent */
0f2447d8 102$load_sent_folder = getPref($data_dir, $username, 'sent_folder');
103if (($load_sent_folder == '') && ($move_to_sent)) {
104 $sent_folder = $folder_prefix . $sent_folder;
105} else {
106 $sent_folder = $load_sent_folder;
107}
108
0842b54b 109/* Load special folder - draft */
0f2447d8 110$load_draft_folder = getPref($data_dir, $username, 'draft_folder');
111if (($load_draft_folder == '') && ($save_as_draft)) {
112 $draft_folder = $folder_prefix . $draft_folder;
113} else {
114 $draft_folder = $load_draft_folder;
115}
116
0f2447d8 117$show_num = getPref($data_dir, $username, 'show_num', 15 );
118
119$wrap_at = getPref( $data_dir, $username, 'wrap_at', 86 );
120if ($wrap_at < 15) { $wrap_at = 15; }
121
122$left_size = getPref($data_dir, $username, 'left_size');
0842b54b 123if ($left_size == '') {
0f2447d8 124 if (isset($default_left_size)) {
125 $left_size = $default_left_size;
f7b1b3b1 126 } else {
0f2447d8 127 $left_size = 200;
f7b1b3b1 128 }
0f2447d8 129}
130
0842b54b 131$editor_size = getPref($data_dir, $username, 'editor_size', 76 );
0f2447d8 132$use_signature = getPref($data_dir, $username, 'use_signature', SMPREF_OFF );
0842b54b 133$prefix_sig = getPref($data_dir, $username, 'prefix_sig');
0f2447d8 134
135/* Load preferences for reply citation style. */
0f2447d8 136
0842b54b 137$reply_citation_style =
138 getPref($data_dir, $username, 'reply_citation_style', SMPREF_NONE );
0f2447d8 139$reply_citation_start = getPref($data_dir, $username, 'reply_citation_start');
140$reply_citation_end = getPref($data_dir, $username, 'reply_citation_end');
141
0f2447d8 142$left_refresh = getPref($data_dir, $username, 'left_refresh', SMPREF_NONE );
143$sort = getPref($data_dir, $username, 'sort', 6 );
144
145/** Load up the Signature file **/
0f2447d8 146if ($use_signature) {
147 $signature_abs = $signature = getSig($data_dir, $username);
148} else {
149 $signature_abs = getSig($data_dir, $username);
150}
151
0842b54b 152/* Highlight comes in with the form: name, color, header, value. */
0842b54b 153for ($i = 0; $hlt = getPref($data_dir, $username, "highlight$i"); ++$i) {
154 $highlight_array = explode(',', $hlt);
155 $message_highlight_list[$i]['name'] = $highlight_array[0];
156 $message_highlight_list[$i]['color'] = $highlight_array[1];
157 $message_highlight_list[$i]['value'] = $highlight_array[2];
010ce1b3 158 $message_highlight_list[$i]['match_type'] = $highlight_array[3];
0f2447d8 159}
160
161/* Index order lets you change the order of the message index */
0f2447d8 162$order = getPref($data_dir, $username, 'order1');
0842b54b 163for ($i = 1; $order; ++$i) {
0f2447d8 164 $index_order[$i] = $order;
165 $order = getPref($data_dir, $username, 'order'.($i+1));
166}
167if (!isset($index_order)) {
168 $index_order[1] = 1;
169 $index_order[2] = 2;
170 $index_order[3] = 3;
171 $index_order[4] = 5;
172 $index_order[5] = 4;
173}
174
0842b54b 175$alt_index_colors =
176 getPref($data_dir, $username, 'alt_index_colors', SMPREF_ON );
0f2447d8 177
0842b54b 178$location_of_bar =
179 getPref($data_dir, $username, 'location_of_bar', SMPREF_LOC_LEFT);
180$location_of_buttons =
181 getPref($data_dir, $username, 'location_of_buttons', SMPREF_LOC_BETWEEN);
0f2447d8 182
0842b54b 183$collapse_folders =
184 getPref($data_dir, $username, 'collapse_folders', SMPREF_ON);
0f2447d8 185
186/* show_html_default is a int value. */
0842b54b 187$show_html_default =
188 intval(getPref($data_dir, $username, 'show_html_default', SMPREF_OFF));
0f2447d8 189
0842b54b 190$show_xmailer_default =
191 getPref($data_dir, $username, 'show_xmailer_default', SMPREF_OFF );
0f2447d8 192$attachment_common_show_images = getPref($data_dir, $username, 'attachment_common_show_images', SMPREF_OFF );
193$pf_subtle_link = getPref($data_dir, $username, 'pf_subtle_link', SMPREF_ON);
194$pf_cleandisplay = getPref($data_dir, $username, 'pf_cleandisplay', SMPREF_OFF);
195
57257333 196$mdn_user_support = getPref($data_dir, $username, 'mdn_user_support', SMPREF_ON);
197
0842b54b 198$include_self_reply_all =
199 getPref($data_dir, $username, 'include_self_reply_all', SMPREF_ON);
0f2447d8 200
0f2447d8 201$page_selector = getPref($data_dir, $username, 'page_selector', SMPREF_ON);
202$page_selector_max = getPref($data_dir, $username, 'page_selector_max', 10);
203
204/* SqClock now in the core */
0f2447d8 205$date_format = getPref($data_dir, $username, 'date_format', 3);
206$hour_format = getPref($data_dir, $username, 'hour_format', 2);
207
9c3e6cd4 208/* compose in new window setting */
209$compose_new_win = getPref($data_dir, $username, 'compose_new_win', 0);
210
0f2447d8 211/* Load the javascript settings. */
0842b54b 212$javascript_setting =
213 getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT);
0f2447d8 214$javascript_on = getPref($data_dir, $username, 'javascript_on', SMPREF_ON);
215
99e3bfd0 216
beafd24e 217$search_memory = getPref($data_dir, $username, 'search_memory', 0);
0d672ac0 218
0842b54b 219do_hook('loading_prefs');
f7b1b3b1 220
9c3e6cd4 221?>