c36ed9cf |
1 | <?php |
c36ed9cf |
2 | |
35586184 |
3 | /** |
4 | * options_folder.php |
5 | * |
76911253 |
6 | * Copyright (c) 1999-2003 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * Displays all options relating to folders |
10 | * |
11 | * $Id$ |
2b646597 |
12 | * @package squirrelmail |
35586184 |
13 | */ |
cbe5423b |
14 | |
2b646597 |
15 | /** SquirrelMail required files. */ |
86725763 |
16 | require_once(SM_PATH . 'functions/imap.php'); |
be2d5495 |
17 | require_once(SM_PATH . 'functions/imap_general.php'); |
cbe5423b |
18 | |
19 | /* Define the group constants for the folder options page. */ |
20 | define('SMOPT_GRP_SPCFOLDER', 0); |
21 | define('SMOPT_GRP_FOLDERLIST', 1); |
be2d5495 |
22 | define('SMOPT_GRP_FOLDERSELECT', 2); |
cbe5423b |
23 | |
24 | /* Define the optpage load function for the folder options page. */ |
25 | function load_optpage_data_folder() { |
26 | global $username, $key, $imapServerAddress, $imapPort; |
2fad95fa |
27 | global $folder_prefix, $default_folder_prefix, $show_prefix_option; |
cbe5423b |
28 | |
29 | /* Get some imap data we need later. */ |
30 | $imapConnection = |
31 | sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
32 | $boxes = sqimap_mailbox_list($imapConnection); |
bbcafebd |
33 | |
b5efadfa |
34 | /* Build a simple array into which we will build options. */ |
bbcafebd |
35 | $optgrps = array(); |
b5efadfa |
36 | $optvals = array(); |
37 | |
bbcafebd |
38 | /******************************************************/ |
39 | /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */ |
40 | /******************************************************/ |
bbcafebd |
41 | |
42 | /*** Load the General Options into the array ***/ |
43 | $optgrps[SMOPT_GRP_SPCFOLDER] = _("Special Folder Options"); |
44 | $optvals[SMOPT_GRP_SPCFOLDER] = array(); |
45 | |
cbe5423b |
46 | if (!isset($folder_prefix)) { $folder_prefix = $default_folder_prefix; } |
47 | if ($show_prefix_option) { |
48 | $optvals[SMOPT_GRP_SPCFOLDER][] = array( |
49 | 'name' => 'folder_prefix', |
50 | 'caption' => _("Folder Path"), |
51 | 'type' => SMOPT_TYPE_STRING, |
52 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
53 | 'size' => SMOPT_SIZE_LARGE |
54 | ); |
55 | } |
56 | |
be2d5495 |
57 | $trash_folder_values = array(SMPREF_NONE => '[ '._("Do not use Trash").' ]', |
58 | 'whatever' => $boxes); |
bbcafebd |
59 | $optvals[SMOPT_GRP_SPCFOLDER][] = array( |
b5efadfa |
60 | 'name' => 'trash_folder', |
61 | 'caption' => _("Trash Folder"), |
be2d5495 |
62 | 'type' => SMOPT_TYPE_FLDRLIST, |
b5efadfa |
63 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
cbe5423b |
64 | 'posvals' => $trash_folder_values, |
65 | 'save' => 'save_option_trash_folder' |
b5efadfa |
66 | ); |
67 | |
be2d5495 |
68 | $sent_folder_values = array(SMPREF_NONE => '[ '._("Do not use Sent").' ]', |
69 | 'whatever' => $boxes); |
bbcafebd |
70 | $optvals[SMOPT_GRP_SPCFOLDER][] = array( |
b5efadfa |
71 | 'name' => 'sent_folder', |
72 | 'caption' => _("Sent Folder"), |
be2d5495 |
73 | 'type' => SMOPT_TYPE_FLDRLIST, |
b5efadfa |
74 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
cbe5423b |
75 | 'posvals' => $sent_folder_values, |
76 | 'save' => 'save_option_sent_folder' |
b5efadfa |
77 | ); |
78 | |
be2d5495 |
79 | $draft_folder_values = array(SMPREF_NONE => '[ '._("Do not use Drafts").' ]', |
80 | 'whatever' => $boxes); |
bbcafebd |
81 | $optvals[SMOPT_GRP_SPCFOLDER][] = array( |
b5efadfa |
82 | 'name' => 'draft_folder', |
83 | 'caption' => _("Draft Folder"), |
be2d5495 |
84 | 'type' => SMOPT_TYPE_FLDRLIST, |
b5efadfa |
85 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
cbe5423b |
86 | 'posvals' => $draft_folder_values, |
87 | 'save' => 'save_option_draft_folder' |
b5efadfa |
88 | ); |
89 | |
bbcafebd |
90 | /*** Load the General Options into the array ***/ |
91 | $optgrps[SMOPT_GRP_FOLDERLIST] = _("Folder List Options"); |
92 | $optvals[SMOPT_GRP_FOLDERLIST] = array(); |
93 | |
94 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
95 | 'name' => 'location_of_bar', |
96 | 'caption' => _("Location of Folder List"), |
97 | 'type' => SMOPT_TYPE_STRLIST, |
98 | 'refresh' => SMOPT_REFRESH_ALL, |
99 | 'posvals' => array(SMPREF_LOC_LEFT => _("Left"), |
100 | SMPREF_LOC_RIGHT => _("Right")) |
101 | ); |
102 | |
103 | $left_size_values = array(); |
104 | for ($lsv = 100; $lsv <= 300; $lsv += 10) { |
105 | $left_size_values[$lsv] = "$lsv " . _("pixels"); |
106 | } |
bbcafebd |
107 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
108 | 'name' => 'left_size', |
109 | 'caption' => _("Width of Folder List"), |
110 | 'type' => SMOPT_TYPE_STRLIST, |
111 | 'refresh' => SMOPT_REFRESH_ALL, |
112 | 'posvals' => $left_size_values |
113 | ); |
114 | |
115 | $minute_str = _("Minutes"); |
116 | $left_refresh_values = array(SMPREF_NONE => _("Never")); |
117 | foreach (array(30,60,120,180,300,600) as $lr_val) { |
118 | if ($lr_val < 60) { |
119 | $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds"); |
120 | } else if ($lr_val == 60) { |
121 | $left_refresh_values[$lr_val] = "1 " . _("Minute"); |
122 | } else { |
123 | $left_refresh_values[$lr_val] = ($lr_val/60) . " $minute_str"; |
124 | } |
125 | } |
bbcafebd |
126 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
127 | 'name' => 'left_refresh', |
128 | 'caption' => _("Auto Refresh Folder List"), |
129 | 'type' => SMOPT_TYPE_STRLIST, |
130 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
131 | 'posvals' => $left_refresh_values |
132 | ); |
133 | |
bbcafebd |
134 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
135 | 'name' => 'unseen_notify', |
10ff0c3d |
136 | 'caption' => _("Enable Unread Message Notification"), |
a440e68f |
137 | 'type' => SMOPT_TYPE_STRLIST, |
138 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
139 | 'posvals' => array(SMPREF_UNSEEN_NONE => _("No Notification"), |
140 | SMPREF_UNSEEN_INBOX => _("Only INBOX"), |
141 | SMPREF_UNSEEN_ALL => _("All Folders")) |
142 | ); |
143 | |
bbcafebd |
144 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
145 | 'name' => 'unseen_type', |
10ff0c3d |
146 | 'caption' => _("Unread Message Notification Type"), |
a440e68f |
147 | 'type' => SMOPT_TYPE_STRLIST, |
148 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
149 | 'posvals' => array(SMPREF_UNSEEN_ONLY => _("Only Unseen"), |
150 | SMPREF_UNSEEN_TOTAL => _("Unseen and Total")) |
151 | ); |
152 | |
bbcafebd |
153 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
154 | 'name' => 'collapse_folders', |
155 | 'caption' => _("Enable Collapsable Folders"), |
156 | 'type' => SMOPT_TYPE_BOOLEAN, |
157 | 'refresh' => SMOPT_REFRESH_FOLDERLIST |
158 | ); |
159 | |
f612a235 |
160 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
161 | 'name' => 'unseen_cum', |
162 | 'caption' => _("Enable Cumulative Unread Message Notification"), |
163 | 'type' => SMOPT_TYPE_BOOLEAN, |
164 | 'refresh' => SMOPT_REFRESH_FOLDERLIST |
165 | ); |
166 | |
167 | |
bbcafebd |
168 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
169 | 'name' => 'date_format', |
170 | 'caption' => _("Show Clock on Folders Panel"), |
171 | 'type' => SMOPT_TYPE_STRLIST, |
172 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
173 | 'posvals' => array( '1' => 'MM/DD/YY HH:MM', |
174 | '2' => 'DD/MM/YY HH:MM', |
157e9c5e |
175 | '3' => _("Show weekday and time"), |
176 | '4' => _("Show time with seconds"), |
177 | '5' => _("Show time"), |
a440e68f |
178 | '6' => _("No Clock")), |
179 | ); |
180 | |
bbcafebd |
181 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
182 | 'name' => 'hour_format', |
183 | 'caption' => _("Hour Format"), |
184 | 'type' => SMOPT_TYPE_STRLIST, |
185 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
186 | 'posvals' => array(SMPREF_TIME_12HR => _("12-hour clock"), |
187 | SMPREF_TIME_24HR => _("24-hour clock")) |
188 | ); |
189 | |
0d672ac0 |
190 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
191 | 'name' => 'search_memory', |
192 | 'caption' => _("Memory Search"), |
193 | 'type' => SMOPT_TYPE_STRLIST, |
90568047 |
194 | 'refresh' => SMOPT_REFRESH_NONE, |
0d672ac0 |
195 | 'posvals' => array( 0 => _("Disabled"), |
196 | 1 => '1', |
197 | 2 => '2', |
198 | 3 => '3', |
199 | 4 => '4', |
200 | 5 => '5', |
201 | 6 => '6', |
202 | 7 => '7', |
203 | 8 => '8', |
a2bc1180 |
204 | 9 => '9') |
205 | ); |
0d672ac0 |
206 | |
be2d5495 |
207 | |
208 | /*** Load the General Options into the array ***/ |
209 | $optgrps[SMOPT_GRP_FOLDERSELECT] = _("Folder Selection Options"); |
210 | $optvals[SMOPT_GRP_FOLDERSELECT] = array(); |
211 | |
ebbf2fd0 |
212 | $delim = sqimap_get_delimiter($imapConnection); |
be2d5495 |
213 | $optvals[SMOPT_GRP_FOLDERSELECT][] = array( |
214 | 'name' => 'mailbox_select_style', |
215 | 'caption' => _("Selection List Style"), |
216 | 'type' => SMOPT_TYPE_STRLIST, |
217 | 'refresh' => SMOPT_REFRESH_NONE, |
28df812d |
218 | 'posvals' => array( 0 => _("Long: ") . '"' . _("Folder") . $delim . _("Subfolder") . '"', |
219 | 1 => _("Indented: ") . '" ' . _("Subfolder") . '"', |
220 | 2 => _("Delimited: ") . '". ' . _("Subfolder") . '"') |
be2d5495 |
221 | ); |
222 | |
cbe5423b |
223 | /* Assemble all this together and return it as our result. */ |
224 | $result = array( |
225 | 'grps' => $optgrps, |
226 | 'vals' => $optvals |
227 | ); |
ebbf2fd0 |
228 | sqimap_logout($imapConnection); |
cbe5423b |
229 | return ($result); |
230 | } |
231 | |
232 | /******************************************************************/ |
233 | /** Define any specialized save functions for this option page. ***/ |
234 | /******************************************************************/ |
235 | function save_option_trash_folder($option) { |
236 | global $data_dir, $username; |
237 | |
238 | /* Set move to trash on or off. */ |
239 | $trash_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON); |
240 | setPref($data_dir, $username, 'move_to_trash', $trash_on); |
a440e68f |
241 | |
cbe5423b |
242 | /* Now just save the option as normal. */ |
243 | save_option($option); |
244 | } |
2016e645 |
245 | |
cbe5423b |
246 | function save_option_sent_folder($option) { |
247 | global $data_dir, $username; |
e7db48af |
248 | |
cbe5423b |
249 | /* Set move to sent on or off. */ |
250 | $sent_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON); |
251 | setPref($data_dir, $username, 'move_to_sent', $sent_on); |
e7db48af |
252 | |
cbe5423b |
253 | /* Now just save the option as normal. */ |
254 | save_option($option); |
255 | } |
e7db48af |
256 | |
cbe5423b |
257 | function save_option_draft_folder($option) { |
258 | global $data_dir, $username; |
259 | |
260 | /* Set move to draft on or off. */ |
261 | $draft_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON); |
262 | setPref($data_dir, $username, 'save_as_draft', $draft_on); |
263 | |
264 | /* Now just save the option as normal. */ |
265 | save_option($option); |
266 | } |
267 | |
268 | ?> |