f5910eafb0b51abe242b0d345329078a10b83d00
[squirrelmail.git] / include / options / folder.php
1 <?php
2
3 /**
4 * options_folder.php
5 *
6 * Displays all options relating to folders
7 *
8 * @copyright 1999-2014 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
10 * @version $Id$
11 * @package squirrelmail
12 */
13
14 /** SquirrelMail required files. */
15 include(SM_PATH . 'functions/imap_general.php');
16
17 /* Define the group constants for the folder options page. */
18 define('SMOPT_GRP_SPCFOLDER', 0);
19 define('SMOPT_GRP_FOLDERLIST', 1);
20 define('SMOPT_GRP_FOLDERSELECT', 2);
21
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 */
35 function load_optpage_data_folder() {
36 global $username, $imapServerAddress, $imapPort, $imap_stream_options,
37 $oTemplate, $nbsp, $folder_prefix, $default_folder_prefix,
38 $show_prefix_option;
39
40 /* Get some imap data we need later. */
41 $imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options);
42 $boxes = sqimap_mailbox_list($imapConnection);
43
44 /* Build a simple array into which we will build options. */
45 $optgrps = array();
46 $optvals = array();
47
48 /******************************************************/
49 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
50 /******************************************************/
51
52 /*** Load the General Options into the array ***/
53 $optgrps[SMOPT_GRP_SPCFOLDER] = _("Special Folder Options");
54 $optvals[SMOPT_GRP_SPCFOLDER] = array();
55
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
67 $trash_folder_values = array(SMPREF_NONE => '[ '._("Do not use Trash").' ]',
68 'ignore' => $boxes);
69 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
70 'name' => 'trash_folder',
71 'caption' => _("Trash Folder"),
72 'type' => SMOPT_TYPE_FLDRLIST,
73 'refresh' => SMOPT_REFRESH_FOLDERLIST,
74 'posvals' => $trash_folder_values,
75 'save' => 'save_option_trash_folder'
76 );
77
78 $draft_folder_values = array(SMPREF_NONE => '[ '._("Do not use Drafts").' ]',
79 'ignore' => $boxes);
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
89 $sent_folder_values = array(SMPREF_NONE => '[ '._("Do not use Sent").' ]',
90 'ignore' => $boxes);
91 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
92 'name' => 'sent_folder',
93 'caption' => _("Sent Folder"),
94 'type' => SMOPT_TYPE_FLDRLIST,
95 'refresh' => SMOPT_REFRESH_FOLDERLIST,
96 'posvals' => $sent_folder_values,
97 'save' => 'save_option_sent_folder'
98 );
99
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
107 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
108 'name' => 'save_reply_with_orig',
109 'caption' => _("Save Replies with Original Message"),
110 'type' => SMOPT_TYPE_BOOLEAN,
111 'refresh' => SMOPT_REFRESH_FOLDERLIST
112 );
113
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(
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 }
131 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
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
139 $left_refresh_values = array(SMPREF_NONE => _("Never"));
140 foreach (array(30,60,120,180,300,600,1200) as $lr_val) {
141 if ($lr_val < 60) {
142 $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds");
143 } else {
144 $left_refresh_values[$lr_val] = sprintf(ngettext("%d Minute","%d Minutes",($lr_val/60)),($lr_val/60));
145 }
146 }
147 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
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
155 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
156 'name' => 'unseen_notify',
157 'caption' => _("Enable Unread Message Notification"),
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
165 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
166 'name' => 'unseen_type',
167 'caption' => _("Unread Message Notification Type"),
168 'type' => SMOPT_TYPE_STRLIST,
169 'refresh' => SMOPT_REFRESH_FOLDERLIST,
170 'posvals' => array(SMPREF_UNSEEN_ONLY => _("Only Unseen"),
171 SMPREF_UNSEEN_TOTAL => _("Unseen and Total"))
172 );
173
174 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
175 'name' => 'collapse_folders',
176 'caption' => _("Enable Collapsable Folders"),
177 'type' => SMOPT_TYPE_BOOLEAN,
178 'refresh' => SMOPT_REFRESH_FOLDERLIST
179 );
180
181 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
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(
190 'name' => 'date_format',
191 'caption' => _("Show Clock on Folders Panel"),
192 'type' => SMOPT_TYPE_STRLIST,
193 'refresh' => SMOPT_REFRESH_FOLDERLIST,
194 'posvals' => array( '0' => _("International date and time"),
195 '1' => _("American date and time"),
196 '2' => _("European date and time"),
197 '3' => _("Show weekday and time"),
198 '4' => _("Show time with seconds"),
199 '5' => _("Show time"),
200 '6' => _("No Clock")),
201 );
202
203 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
204 'name' => 'search_memory',
205 'caption' => _("Memory Search"),
206 'type' => SMOPT_TYPE_STRLIST,
207 'refresh' => SMOPT_REFRESH_NONE,
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',
217 9 => '9')
218 );
219
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 );
226
227 /*** Load the General Options into the array ***/
228 $optgrps[SMOPT_GRP_FOLDERSELECT] = _("Folder Selection Options");
229 $optvals[SMOPT_GRP_FOLDERSELECT] = array();
230
231 $delim = sqimap_get_delimiter($imapConnection);
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,
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") . '"'),
244 'htmlencoded' => true
245 );
246
247 /* Assemble all this together and return it as our result. */
248 $result = array(
249 'grps' => $optgrps,
250 'vals' => $optvals
251 );
252 sqimap_logout($imapConnection);
253 return ($result);
254 }
255
256 /******************************************************************/
257 /** Define any specialized save functions for this option page. ***/
258 /******************************************************************/
259
260 /**
261 * Saves the trash folder option.
262 * @param object $option SquirrelOption object
263 * @since 1.3.2
264 */
265 function save_option_trash_folder($option) {
266 global $data_dir, $username;
267
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);
275
276 /* Now just save the option as normal. */
277 save_option($option);
278 }
279 }
280
281 /**
282 * Saves the sent folder option.
283 * @param object $option SquirrelOption object
284 * @since 1.3.2
285 */
286 function save_option_sent_folder($option) {
287 global $data_dir, $username;
288
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);
296
297 /* Now just save the option as normal. */
298 save_option($option);
299 }
300 }
301
302 /**
303 * Saves the draft folder option.
304 * @param object $option SquirrelOption object
305 * @since 1.3.2
306 */
307 function save_option_draft_folder($option) {
308 global $data_dir, $username;
309
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 }
321 }