c36ed9cf |
1 | <?php |
c36ed9cf |
2 | |
35586184 |
3 | /** |
4 | * options_folder.php |
5 | * |
35586184 |
6 | * Displays all options relating to folders |
7 | * |
77a1e3d1 |
8 | * @copyright 1999-2022 The SquirrelMail Project Team |
4b4abf93 |
9 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
763b63fe |
10 | * @version $Id$ |
2b646597 |
11 | * @package squirrelmail |
35586184 |
12 | */ |
cbe5423b |
13 | |
2b646597 |
14 | /** SquirrelMail required files. */ |
202bcbcc |
15 | include(SM_PATH . 'functions/imap_general.php'); |
cbe5423b |
16 | |
aedb6605 |
17 | /* Define the group constants for the folder options page. */ |
cbe5423b |
18 | define('SMOPT_GRP_SPCFOLDER', 0); |
19 | define('SMOPT_GRP_FOLDERLIST', 1); |
be2d5495 |
20 | define('SMOPT_GRP_FOLDERSELECT', 2); |
cbe5423b |
21 | |
48af4b64 |
22 | /** |
23 | * This function builds an array with all the information about |
24 | * the options available to the user, and returns it. The options |
25 | * are grouped by the groups in which they are displayed. |
26 | * For each option, the following information is stored: |
27 | * - name: the internal (variable) name |
28 | * - caption: the description of the option in the UI |
29 | * - type: one of SMOPT_TYPE_* |
30 | * - refresh: one of SMOPT_REFRESH_* |
31 | * - size: one of SMOPT_SIZE_* |
32 | * - save: the name of a function to call when saving this option |
33 | * @return array all option information |
34 | */ |
cbe5423b |
35 | function load_optpage_data_folder() { |
a9805897 |
36 | global $username, $imapServerAddress, $imapPort, $imap_stream_options, |
9aaa9ae2 |
37 | $oTemplate, $nbsp, $folder_prefix, $default_folder_prefix, |
38 | $show_prefix_option; |
cbe5423b |
39 | |
40 | /* Get some imap data we need later. */ |
a9805897 |
41 | $imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options); |
cbe5423b |
42 | $boxes = sqimap_mailbox_list($imapConnection); |
bbcafebd |
43 | |
b5efadfa |
44 | /* Build a simple array into which we will build options. */ |
bbcafebd |
45 | $optgrps = array(); |
b5efadfa |
46 | $optvals = array(); |
47 | |
bbcafebd |
48 | /******************************************************/ |
49 | /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */ |
50 | /******************************************************/ |
bbcafebd |
51 | |
52 | /*** Load the General Options into the array ***/ |
53 | $optgrps[SMOPT_GRP_SPCFOLDER] = _("Special Folder Options"); |
54 | $optvals[SMOPT_GRP_SPCFOLDER] = array(); |
55 | |
cbe5423b |
56 | if (!isset($folder_prefix)) { $folder_prefix = $default_folder_prefix; } |
57 | if ($show_prefix_option) { |
58 | $optvals[SMOPT_GRP_SPCFOLDER][] = array( |
59 | 'name' => 'folder_prefix', |
60 | 'caption' => _("Folder Path"), |
61 | 'type' => SMOPT_TYPE_STRING, |
62 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
63 | 'size' => SMOPT_SIZE_LARGE |
64 | ); |
65 | } |
66 | |
be2d5495 |
67 | $trash_folder_values = array(SMPREF_NONE => '[ '._("Do not use Trash").' ]', |
0177059f |
68 | 'ignore' => $boxes); |
bbcafebd |
69 | $optvals[SMOPT_GRP_SPCFOLDER][] = array( |
b5efadfa |
70 | 'name' => 'trash_folder', |
71 | 'caption' => _("Trash Folder"), |
be2d5495 |
72 | 'type' => SMOPT_TYPE_FLDRLIST, |
b5efadfa |
73 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
cbe5423b |
74 | 'posvals' => $trash_folder_values, |
75 | 'save' => 'save_option_trash_folder' |
b5efadfa |
76 | ); |
aedb6605 |
77 | |
78 | $draft_folder_values = array(SMPREF_NONE => '[ '._("Do not use Drafts").' ]', |
0177059f |
79 | 'ignore' => $boxes); |
aedb6605 |
80 | $optvals[SMOPT_GRP_SPCFOLDER][] = array( |
81 | 'name' => 'draft_folder', |
82 | 'caption' => _("Draft Folder"), |
83 | 'type' => SMOPT_TYPE_FLDRLIST, |
84 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
85 | 'posvals' => $draft_folder_values, |
86 | 'save' => 'save_option_draft_folder' |
87 | ); |
88 | |
be2d5495 |
89 | $sent_folder_values = array(SMPREF_NONE => '[ '._("Do not use Sent").' ]', |
0177059f |
90 | 'ignore' => $boxes); |
bbcafebd |
91 | $optvals[SMOPT_GRP_SPCFOLDER][] = array( |
b5efadfa |
92 | 'name' => 'sent_folder', |
93 | 'caption' => _("Sent Folder"), |
be2d5495 |
94 | 'type' => SMOPT_TYPE_FLDRLIST, |
b5efadfa |
95 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
cbe5423b |
96 | 'posvals' => $sent_folder_values, |
97 | 'save' => 'save_option_sent_folder' |
b5efadfa |
98 | ); |
aedb6605 |
99 | |
7652c651 |
100 | $optvals[SMOPT_GRP_SPCFOLDER][] = array( |
101 | 'name' => 'translate_special_folders', |
102 | 'caption' => _("Translate Special Folders"), |
103 | 'type' => SMOPT_TYPE_BOOLEAN, |
104 | 'refresh' => SMOPT_REFRESH_FOLDERLIST |
105 | ); |
106 | |
ec424753 |
107 | $optvals[SMOPT_GRP_SPCFOLDER][] = array( |
108 | 'name' => 'mark_as_read_upon_delete', |
109 | 'caption' => _("Mark Deleted Messages as Read"), |
110 | 'type' => SMOPT_TYPE_BOOLEAN, |
111 | 'refresh' => SMOPT_REFRESH_NONE |
112 | ); |
113 | |
114 | //TODO: Arguably, this should go in Compose preferences, not here |
bbcafebd |
115 | $optvals[SMOPT_GRP_SPCFOLDER][] = array( |
aedb6605 |
116 | 'name' => 'save_reply_with_orig', |
117 | 'caption' => _("Save Replies with Original Message"), |
118 | 'type' => SMOPT_TYPE_BOOLEAN, |
119 | 'refresh' => SMOPT_REFRESH_FOLDERLIST |
b5efadfa |
120 | ); |
121 | |
bbcafebd |
122 | /*** Load the General Options into the array ***/ |
123 | $optgrps[SMOPT_GRP_FOLDERLIST] = _("Folder List Options"); |
124 | $optvals[SMOPT_GRP_FOLDERLIST] = array(); |
125 | |
126 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
127 | 'name' => 'location_of_bar', |
128 | 'caption' => _("Location of Folder List"), |
129 | 'type' => SMOPT_TYPE_STRLIST, |
130 | 'refresh' => SMOPT_REFRESH_ALL, |
131 | 'posvals' => array(SMPREF_LOC_LEFT => _("Left"), |
132 | SMPREF_LOC_RIGHT => _("Right")) |
133 | ); |
134 | |
135 | $left_size_values = array(); |
136 | for ($lsv = 100; $lsv <= 300; $lsv += 10) { |
137 | $left_size_values[$lsv] = "$lsv " . _("pixels"); |
138 | } |
bbcafebd |
139 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
140 | 'name' => 'left_size', |
141 | 'caption' => _("Width of Folder List"), |
142 | 'type' => SMOPT_TYPE_STRLIST, |
143 | 'refresh' => SMOPT_REFRESH_ALL, |
144 | 'posvals' => $left_size_values |
145 | ); |
146 | |
a440e68f |
147 | $left_refresh_values = array(SMPREF_NONE => _("Never")); |
721db745 |
148 | foreach (array(30,60,120,180,300,600,1200) as $lr_val) { |
a440e68f |
149 | if ($lr_val < 60) { |
150 | $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds"); |
a440e68f |
151 | } else { |
031b6f72 |
152 | $left_refresh_values[$lr_val] = sprintf(ngettext("%d Minute","%d Minutes",($lr_val/60)),($lr_val/60)); |
a440e68f |
153 | } |
154 | } |
bbcafebd |
155 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
156 | 'name' => 'left_refresh', |
157 | 'caption' => _("Auto Refresh Folder List"), |
158 | 'type' => SMOPT_TYPE_STRLIST, |
159 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
160 | 'posvals' => $left_refresh_values |
161 | ); |
162 | |
bbcafebd |
163 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
164 | 'name' => 'unseen_notify', |
10ff0c3d |
165 | 'caption' => _("Enable Unread Message Notification"), |
a440e68f |
166 | 'type' => SMOPT_TYPE_STRLIST, |
167 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
168 | 'posvals' => array(SMPREF_UNSEEN_NONE => _("No Notification"), |
169 | SMPREF_UNSEEN_INBOX => _("Only INBOX"), |
170 | SMPREF_UNSEEN_ALL => _("All Folders")) |
171 | ); |
172 | |
bbcafebd |
173 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
174 | 'name' => 'unseen_type', |
10ff0c3d |
175 | 'caption' => _("Unread Message Notification Type"), |
a440e68f |
176 | 'type' => SMOPT_TYPE_STRLIST, |
177 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
178 | 'posvals' => array(SMPREF_UNSEEN_ONLY => _("Only Unseen"), |
aedb6605 |
179 | SMPREF_UNSEEN_TOTAL => _("Unseen and Total")) |
a440e68f |
180 | ); |
181 | |
bbcafebd |
182 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
183 | 'name' => 'collapse_folders', |
184 | 'caption' => _("Enable Collapsable Folders"), |
185 | 'type' => SMOPT_TYPE_BOOLEAN, |
186 | 'refresh' => SMOPT_REFRESH_FOLDERLIST |
187 | ); |
188 | |
f612a235 |
189 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
190 | 'name' => 'unseen_cum', |
191 | 'caption' => _("Enable Cumulative Unread Message Notification"), |
192 | 'type' => SMOPT_TYPE_BOOLEAN, |
193 | 'refresh' => SMOPT_REFRESH_FOLDERLIST |
194 | ); |
195 | |
196 | |
bbcafebd |
197 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
198 | 'name' => 'date_format', |
199 | 'caption' => _("Show Clock on Folders Panel"), |
200 | 'type' => SMOPT_TYPE_STRLIST, |
201 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
e4f5158a |
202 | 'posvals' => array( '0' => _("International date and time"), |
300a044d |
203 | '1' => _("American date and time"), |
e4f5158a |
204 | '2' => _("European date and time"), |
157e9c5e |
205 | '3' => _("Show weekday and time"), |
206 | '4' => _("Show time with seconds"), |
207 | '5' => _("Show time"), |
a440e68f |
208 | '6' => _("No Clock")), |
209 | ); |
210 | |
0d672ac0 |
211 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
212 | 'name' => 'search_memory', |
213 | 'caption' => _("Memory Search"), |
214 | 'type' => SMOPT_TYPE_STRLIST, |
90568047 |
215 | 'refresh' => SMOPT_REFRESH_NONE, |
0d672ac0 |
216 | 'posvals' => array( 0 => _("Disabled"), |
217 | 1 => '1', |
218 | 2 => '2', |
219 | 3 => '3', |
220 | 4 => '4', |
221 | 5 => '5', |
222 | 6 => '6', |
223 | 7 => '7', |
224 | 8 => '8', |
a2bc1180 |
225 | 9 => '9') |
226 | ); |
0d672ac0 |
227 | |
4d5f2b31 |
228 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
229 | 'name' => 'show_only_subscribed_folders', |
230 | 'caption' => _("Show only subscribed folders"), |
231 | 'type' => SMOPT_TYPE_BOOLEAN, |
232 | 'refresh' => SMOPT_REFRESH_FOLDERLIST |
233 | ); |
be2d5495 |
234 | |
235 | /*** Load the General Options into the array ***/ |
236 | $optgrps[SMOPT_GRP_FOLDERSELECT] = _("Folder Selection Options"); |
237 | $optvals[SMOPT_GRP_FOLDERSELECT] = array(); |
238 | |
ebbf2fd0 |
239 | $delim = sqimap_get_delimiter($imapConnection); |
be2d5495 |
240 | $optvals[SMOPT_GRP_FOLDERSELECT][] = array( |
241 | 'name' => 'mailbox_select_style', |
242 | 'caption' => _("Selection List Style"), |
243 | 'type' => SMOPT_TYPE_STRLIST, |
244 | 'refresh' => SMOPT_REFRESH_NONE, |
d56050e1 |
245 | 'posvals' => array( |
246 | SMPREF_MAILBOX_SELECT_LONG => |
247 | _("Long:") . ' "' . _("Folder") . $delim . _("Subfolder") . '"', |
248 | SMPREF_MAILBOX_SELECT_INDENTED => |
249 | _("Indented:") . " \"$nbsp$nbsp$nbsp$nbsp" . _("Subfolder") . '"', |
250 | SMPREF_MAILBOX_SELECT_DELIMITED => |
251 | _("Delimited:") . " \".$nbsp" . _("Subfolder") . '"'), |
300a044d |
252 | 'htmlencoded' => true |
be2d5495 |
253 | ); |
254 | |
cbe5423b |
255 | /* Assemble all this together and return it as our result. */ |
256 | $result = array( |
257 | 'grps' => $optgrps, |
258 | 'vals' => $optvals |
259 | ); |
ebbf2fd0 |
260 | sqimap_logout($imapConnection); |
cbe5423b |
261 | return ($result); |
262 | } |
263 | |
264 | /******************************************************************/ |
265 | /** Define any specialized save functions for this option page. ***/ |
266 | /******************************************************************/ |
48af4b64 |
267 | |
268 | /** |
269 | * Saves the trash folder option. |
345e009b |
270 | * @param object $option SquirrelOption object |
271 | * @since 1.3.2 |
48af4b64 |
272 | */ |
cbe5423b |
273 | function save_option_trash_folder($option) { |
274 | global $data_dir, $username; |
275 | |
345e009b |
276 | if (strtolower($option->new_value)=='inbox') { |
277 | // make sure that it is not INBOX |
278 | error_option_save(_("You can't select INBOX as Trash folder.")); |
279 | } else { |
280 | /* Set move to trash on or off. */ |
281 | $trash_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON); |
282 | setPref($data_dir, $username, 'move_to_trash', $trash_on); |
a440e68f |
283 | |
345e009b |
284 | /* Now just save the option as normal. */ |
285 | save_option($option); |
286 | } |
cbe5423b |
287 | } |
2016e645 |
288 | |
48af4b64 |
289 | /** |
290 | * Saves the sent folder option. |
345e009b |
291 | * @param object $option SquirrelOption object |
292 | * @since 1.3.2 |
48af4b64 |
293 | */ |
cbe5423b |
294 | function save_option_sent_folder($option) { |
295 | global $data_dir, $username; |
e7db48af |
296 | |
345e009b |
297 | if (strtolower($option->new_value)=='inbox') { |
298 | // make sure that it is not INBOX |
299 | error_option_save(_("You can't select INBOX as Sent folder.")); |
300 | } else { |
301 | /* Set move to sent on or off. */ |
302 | $sent_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON); |
303 | setPref($data_dir, $username, 'move_to_sent', $sent_on); |
e7db48af |
304 | |
345e009b |
305 | /* Now just save the option as normal. */ |
306 | save_option($option); |
307 | } |
cbe5423b |
308 | } |
e7db48af |
309 | |
48af4b64 |
310 | /** |
311 | * Saves the draft folder option. |
345e009b |
312 | * @param object $option SquirrelOption object |
313 | * @since 1.3.2 |
48af4b64 |
314 | */ |
cbe5423b |
315 | function save_option_draft_folder($option) { |
316 | global $data_dir, $username; |
317 | |
345e009b |
318 | if (strtolower($option->new_value)=='inbox') { |
319 | // make sure that it is not INBOX |
320 | error_option_save(_("You can't select INBOX as Draft folder.")); |
321 | } else { |
322 | /* Set move to draft on or off. */ |
323 | $draft_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON); |
324 | setPref($data_dir, $username, 'save_as_draft', $draft_on); |
325 | |
326 | /* Now just save the option as normal. */ |
327 | save_option($option); |
328 | } |
cbe5423b |
329 | } |