Typo
[squirrelmail.git] / src / load_prefs.php
... / ...
CommitLineData
1<?php
2
3/**
4 * load_prefs.php
5 *
6 * Copyright (c) 1999-2002 The SquirrelMail Project 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 */
14
15require_once('../src/validate.php');
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
26$chosen_theme = getPref($data_dir, $username, "chosen_theme");
27$found_theme = false;
28for ($i = 0; $i < count($theme); ++$i){
29 if ($theme[$i]['PATH'] == $chosen_theme) {
30 $found_theme = true;
31 break;
32 }
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']);
41 } else {
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 */
59 }
60}
61
62if (!defined('download_php')) { session_register('theme_css'); }
63
64global $use_javascript_addr_book;
65$use_javascript_addr_book = getPref($data_dir, $username, 'use_javascript_addr_book', $default_use_javascript_addr_book);
66
67/* Declare the global variables for the special folders. */
68global $move_to_sent, $move_to_trash, $save_as_draft;
69
70/* Load the user's special folder preferences */
71$move_to_sent =
72 getPref($data_dir, $username, 'move_to_sent', $default_move_to_sent);
73$move_to_trash =
74 getPref($data_dir, $username, 'move_to_trash', $default_move_to_trash);
75$save_as_draft =
76 getPref($data_dir, $username, 'save_as_draft', $default_save_as_draft);
77
78global $unseen_type, $unseen_notify;
79if ($default_unseen_type == '') { $default_unseen_type = 1; }
80if ($default_unseen_notify == '') { $default_unseen_notify = 2; }
81$unseen_type =
82 getPref($data_dir, $username, 'unseen_type', $default_unseen_type);
83$unseen_notify =
84 getPref($data_dir, $username, 'unseen_notify', $default_unseen_notify);
85
86global $folder_prefix;
87$folder_prefix =
88 getPref($data_dir, $username, 'folder_prefix', $default_folder_prefix);
89
90/* Declare global variables for special folders. */
91global $trash_folder, $sent_folder, $draft_folder;
92
93/* Load special folder - trash */
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
101/* Load special folder - sent */
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
109/* Load special folder - draft */
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
117global $show_num, $wrap_at, $left_size;
118$show_num = getPref($data_dir, $username, 'show_num', 15 );
119
120$wrap_at = getPref( $data_dir, $username, 'wrap_at', 86 );
121if ($wrap_at < 15) { $wrap_at = 15; }
122
123$left_size = getPref($data_dir, $username, 'left_size');
124if ($left_size == '') {
125 if (isset($default_left_size)) {
126 $left_size = $default_left_size;
127 } else {
128 $left_size = 200;
129 }
130}
131
132global $editor_size, $use_signature, $prefix_sig;
133$editor_size = getPref($data_dir, $username, 'editor_size', 76 );
134$use_signature = getPref($data_dir, $username, 'use_signature', SMPREF_OFF );
135$prefix_sig = getPref($data_dir, $username, 'prefix_sig');
136
137/* Load preferences for reply citation style. */
138global $reply_citation_style, $reply_citation_start, $reply_citation_end;
139
140$reply_citation_style =
141 getPref($data_dir, $username, 'reply_citation_style', SMPREF_NONE );
142$reply_citation_start = getPref($data_dir, $username, 'reply_citation_start');
143$reply_citation_end = getPref($data_dir, $username, 'reply_citation_end');
144
145global $left_refresh, $sort;
146$left_refresh = getPref($data_dir, $username, 'left_refresh', SMPREF_NONE );
147$sort = getPref($data_dir, $username, 'sort', 6 );
148
149/** Load up the Signature file **/
150global $signature_abs;
151if ($use_signature) {
152 $signature_abs = $signature = getSig($data_dir, $username);
153} else {
154 $signature_abs = getSig($data_dir, $username);
155}
156
157/* Highlight comes in with the form: name, color, header, value. */
158global $message_highlight_list;
159for ($i = 0; $hlt = getPref($data_dir, $username, "highlight$i"); ++$i) {
160 $highlight_array = explode(',', $hlt);
161 $message_highlight_list[$i]['name'] = $highlight_array[0];
162 $message_highlight_list[$i]['color'] = $highlight_array[1];
163 $message_highlight_list[$i]['value'] = $highlight_array[2];
164 $message_highlight_list[$i]['match_type'] = $highlight_array[3];
165}
166
167/* Index order lets you change the order of the message index */
168global $index_order;
169$order = getPref($data_dir, $username, 'order1');
170for ($i = 1; $order; ++$i) {
171 $index_order[$i] = $order;
172 $order = getPref($data_dir, $username, 'order'.($i+1));
173}
174if (!isset($index_order)) {
175 $index_order[1] = 1;
176 $index_order[2] = 2;
177 $index_order[3] = 3;
178 $index_order[4] = 5;
179 $index_order[5] = 4;
180}
181
182global $alt_index_colors;
183$alt_index_colors =
184 getPref($data_dir, $username, 'alt_index_colors', SMPREF_ON );
185
186global $location_of_bar, $location_of_buttons;
187$location_of_bar =
188 getPref($data_dir, $username, 'location_of_bar', SMPREF_LOC_LEFT);
189$location_of_buttons =
190 getPref($data_dir, $username, 'location_of_buttons', SMPREF_LOC_BETWEEN);
191
192global $collapse_folders, $show_html_default, $show_xmailer_default;
193global $attachment_common_show_images, $pf_subtle_link, $pf_cleandisplay;
194$collapse_folders =
195 getPref($data_dir, $username, 'collapse_folders', SMPREF_ON);
196
197/* show_html_default is a int value. */
198$show_html_default =
199 intval(getPref($data_dir, $username, 'show_html_default', SMPREF_OFF));
200
201$show_xmailer_default =
202 getPref($data_dir, $username, 'show_xmailer_default', SMPREF_OFF );
203$attachment_common_show_images = getPref($data_dir, $username, 'attachment_common_show_images', SMPREF_OFF );
204$pf_subtle_link = getPref($data_dir, $username, 'pf_subtle_link', SMPREF_ON);
205$pf_cleandisplay = getPref($data_dir, $username, 'pf_cleandisplay', SMPREF_OFF);
206
207global $include_self_reply_all;
208$include_self_reply_all =
209 getPref($data_dir, $username, 'include_self_reply_all', SMPREF_ON);
210
211global $page_selector, $page_selector_max;
212$page_selector = getPref($data_dir, $username, 'page_selector', SMPREF_ON);
213$page_selector_max = getPref($data_dir, $username, 'page_selector_max', 10);
214
215/* SqClock now in the core */
216global $date_format, $hour_format, $username, $data_dir;
217$date_format = getPref($data_dir, $username, 'date_format', 3);
218$hour_format = getPref($data_dir, $username, 'hour_format', 2);
219
220/* Load the javascript settings. */
221global $javascript_setting, $javascript_on;
222$javascript_setting =
223 getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT);
224$javascript_on = getPref($data_dir, $username, 'javascript_on', SMPREF_ON);
225
226do_hook('loading_prefs');
227
228?>