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