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