Happy New Year
[squirrelmail.git] / include / options / folder.php
CommitLineData
c36ed9cf 1<?php
c36ed9cf 2
35586184 3/**
4 * options_folder.php
5 *
35586184 6 * Displays all options relating to folders
7 *
353d074a 8 * @copyright 1999-2018 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 15include(SM_PATH . 'functions/imap_general.php');
cbe5423b 16
aedb6605 17/* Define the group constants for the folder options page. */
cbe5423b 18define('SMOPT_GRP_SPCFOLDER', 0);
19define('SMOPT_GRP_FOLDERLIST', 1);
be2d5495 20define('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 35function 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
bbcafebd 100 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
7652c651 101 'name' => 'translate_special_folders',
102 'caption' => _("Translate Special Folders"),
103 'type' => SMOPT_TYPE_BOOLEAN,
104 'refresh' => SMOPT_REFRESH_FOLDERLIST
105 );
106
107 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
aedb6605 108 'name' => 'save_reply_with_orig',
109 'caption' => _("Save Replies with Original Message"),
110 'type' => SMOPT_TYPE_BOOLEAN,
111 'refresh' => SMOPT_REFRESH_FOLDERLIST
b5efadfa 112 );
113
bbcafebd 114 /*** Load the General Options into the array ***/
115 $optgrps[SMOPT_GRP_FOLDERLIST] = _("Folder List Options");
116 $optvals[SMOPT_GRP_FOLDERLIST] = array();
117
118 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 119 'name' => 'location_of_bar',
120 'caption' => _("Location of Folder List"),
121 'type' => SMOPT_TYPE_STRLIST,
122 'refresh' => SMOPT_REFRESH_ALL,
123 'posvals' => array(SMPREF_LOC_LEFT => _("Left"),
124 SMPREF_LOC_RIGHT => _("Right"))
125 );
126
127 $left_size_values = array();
128 for ($lsv = 100; $lsv <= 300; $lsv += 10) {
129 $left_size_values[$lsv] = "$lsv " . _("pixels");
130 }
bbcafebd 131 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 132 'name' => 'left_size',
133 'caption' => _("Width of Folder List"),
134 'type' => SMOPT_TYPE_STRLIST,
135 'refresh' => SMOPT_REFRESH_ALL,
136 'posvals' => $left_size_values
137 );
138
a440e68f 139 $left_refresh_values = array(SMPREF_NONE => _("Never"));
721db745 140 foreach (array(30,60,120,180,300,600,1200) as $lr_val) {
a440e68f 141 if ($lr_val < 60) {
142 $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds");
a440e68f 143 } else {
031b6f72 144 $left_refresh_values[$lr_val] = sprintf(ngettext("%d Minute","%d Minutes",($lr_val/60)),($lr_val/60));
a440e68f 145 }
146 }
bbcafebd 147 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 148 'name' => 'left_refresh',
149 'caption' => _("Auto Refresh Folder List"),
150 'type' => SMOPT_TYPE_STRLIST,
151 'refresh' => SMOPT_REFRESH_FOLDERLIST,
152 'posvals' => $left_refresh_values
153 );
154
bbcafebd 155 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 156 'name' => 'unseen_notify',
10ff0c3d 157 'caption' => _("Enable Unread Message Notification"),
a440e68f 158 'type' => SMOPT_TYPE_STRLIST,
159 'refresh' => SMOPT_REFRESH_FOLDERLIST,
160 'posvals' => array(SMPREF_UNSEEN_NONE => _("No Notification"),
161 SMPREF_UNSEEN_INBOX => _("Only INBOX"),
162 SMPREF_UNSEEN_ALL => _("All Folders"))
163 );
164
bbcafebd 165 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 166 'name' => 'unseen_type',
10ff0c3d 167 'caption' => _("Unread Message Notification Type"),
a440e68f 168 'type' => SMOPT_TYPE_STRLIST,
169 'refresh' => SMOPT_REFRESH_FOLDERLIST,
170 'posvals' => array(SMPREF_UNSEEN_ONLY => _("Only Unseen"),
aedb6605 171 SMPREF_UNSEEN_TOTAL => _("Unseen and Total"))
a440e68f 172 );
173
bbcafebd 174 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 175 'name' => 'collapse_folders',
176 'caption' => _("Enable Collapsable Folders"),
177 'type' => SMOPT_TYPE_BOOLEAN,
178 'refresh' => SMOPT_REFRESH_FOLDERLIST
179 );
180
bbcafebd 181 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
f612a235 182 'name' => 'unseen_cum',
183 'caption' => _("Enable Cumulative Unread Message Notification"),
184 'type' => SMOPT_TYPE_BOOLEAN,
185 'refresh' => SMOPT_REFRESH_FOLDERLIST
186 );
187
188
189 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 190 'name' => 'date_format',
191 'caption' => _("Show Clock on Folders Panel"),
192 'type' => SMOPT_TYPE_STRLIST,
193 'refresh' => SMOPT_REFRESH_FOLDERLIST,
e4f5158a 194 'posvals' => array( '0' => _("International date and time"),
300a044d 195 '1' => _("American date and time"),
e4f5158a 196 '2' => _("European date and time"),
157e9c5e 197 '3' => _("Show weekday and time"),
198 '4' => _("Show time with seconds"),
199 '5' => _("Show time"),
a440e68f 200 '6' => _("No Clock")),
201 );
202
bbcafebd 203 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
0d672ac0 204 'name' => 'search_memory',
205 'caption' => _("Memory Search"),
206 'type' => SMOPT_TYPE_STRLIST,
90568047 207 'refresh' => SMOPT_REFRESH_NONE,
0d672ac0 208 'posvals' => array( 0 => _("Disabled"),
209 1 => '1',
210 2 => '2',
211 3 => '3',
212 4 => '4',
213 5 => '5',
214 6 => '6',
215 7 => '7',
216 8 => '8',
a2bc1180 217 9 => '9')
218 );
0d672ac0 219
4d5f2b31 220 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
221 'name' => 'show_only_subscribed_folders',
222 'caption' => _("Show only subscribed folders"),
223 'type' => SMOPT_TYPE_BOOLEAN,
224 'refresh' => SMOPT_REFRESH_FOLDERLIST
225 );
be2d5495 226
227 /*** Load the General Options into the array ***/
228 $optgrps[SMOPT_GRP_FOLDERSELECT] = _("Folder Selection Options");
229 $optvals[SMOPT_GRP_FOLDERSELECT] = array();
230
ebbf2fd0 231 $delim = sqimap_get_delimiter($imapConnection);
be2d5495 232 $optvals[SMOPT_GRP_FOLDERSELECT][] = array(
233 'name' => 'mailbox_select_style',
234 'caption' => _("Selection List Style"),
235 'type' => SMOPT_TYPE_STRLIST,
236 'refresh' => SMOPT_REFRESH_NONE,
d56050e1 237 'posvals' => array(
238 SMPREF_MAILBOX_SELECT_LONG =>
239 _("Long:") . ' "' . _("Folder") . $delim . _("Subfolder") . '"',
240 SMPREF_MAILBOX_SELECT_INDENTED =>
241 _("Indented:") . " \"$nbsp$nbsp$nbsp$nbsp" . _("Subfolder") . '"',
242 SMPREF_MAILBOX_SELECT_DELIMITED =>
243 _("Delimited:") . " \".$nbsp" . _("Subfolder") . '"'),
300a044d 244 'htmlencoded' => true
be2d5495 245 );
246
cbe5423b 247 /* Assemble all this together and return it as our result. */
248 $result = array(
249 'grps' => $optgrps,
250 'vals' => $optvals
251 );
ebbf2fd0 252 sqimap_logout($imapConnection);
cbe5423b 253 return ($result);
254}
255
256/******************************************************************/
257/** Define any specialized save functions for this option page. ***/
258/******************************************************************/
48af4b64 259
260/**
261 * Saves the trash folder option.
345e009b 262 * @param object $option SquirrelOption object
263 * @since 1.3.2
48af4b64 264 */
cbe5423b 265function save_option_trash_folder($option) {
266 global $data_dir, $username;
267
345e009b 268 if (strtolower($option->new_value)=='inbox') {
269 // make sure that it is not INBOX
270 error_option_save(_("You can't select INBOX as Trash folder."));
271 } else {
272 /* Set move to trash on or off. */
273 $trash_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
274 setPref($data_dir, $username, 'move_to_trash', $trash_on);
a440e68f 275
345e009b 276 /* Now just save the option as normal. */
277 save_option($option);
278 }
cbe5423b 279}
2016e645 280
48af4b64 281/**
282 * Saves the sent folder option.
345e009b 283 * @param object $option SquirrelOption object
284 * @since 1.3.2
48af4b64 285 */
cbe5423b 286function save_option_sent_folder($option) {
287 global $data_dir, $username;
e7db48af 288
345e009b 289 if (strtolower($option->new_value)=='inbox') {
290 // make sure that it is not INBOX
291 error_option_save(_("You can't select INBOX as Sent folder."));
292 } else {
293 /* Set move to sent on or off. */
294 $sent_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
295 setPref($data_dir, $username, 'move_to_sent', $sent_on);
e7db48af 296
345e009b 297 /* Now just save the option as normal. */
298 save_option($option);
299 }
cbe5423b 300}
e7db48af 301
48af4b64 302/**
303 * Saves the draft folder option.
345e009b 304 * @param object $option SquirrelOption object
305 * @since 1.3.2
48af4b64 306 */
cbe5423b 307function save_option_draft_folder($option) {
308 global $data_dir, $username;
309
345e009b 310 if (strtolower($option->new_value)=='inbox') {
311 // make sure that it is not INBOX
312 error_option_save(_("You can't select INBOX as Draft folder."));
313 } else {
314 /* Set move to draft on or off. */
315 $draft_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
316 setPref($data_dir, $username, 'save_as_draft', $draft_on);
317
318 /* Now just save the option as normal. */
319 save_option($option);
320 }
cbe5423b 321}