ead93b862707f3c027dfb006d5c3789c2b1f9910
[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 &copy; 1999-2007 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, $oTemplate,
37 $folder_prefix, $default_folder_prefix, $show_prefix_option;
38
39 /* Get some imap data we need later. */
40 $imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
41 $boxes = sqimap_mailbox_list($imapConnection);
42
43 /* Build a simple array into which we will build options. */
44 $optgrps = array();
45 $optvals = array();
46
47 /******************************************************/
48 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
49 /******************************************************/
50
51 /*** Load the General Options into the array ***/
52 $optgrps[SMOPT_GRP_SPCFOLDER] = _("Special Folder Options");
53 $optvals[SMOPT_GRP_SPCFOLDER] = array();
54
55 if (!isset($folder_prefix)) { $folder_prefix = $default_folder_prefix; }
56 if ($show_prefix_option) {
57 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
58 'name' => 'folder_prefix',
59 'caption' => _("Folder Path"),
60 'type' => SMOPT_TYPE_STRING,
61 'refresh' => SMOPT_REFRESH_FOLDERLIST,
62 'size' => SMOPT_SIZE_LARGE
63 );
64 }
65
66 $trash_folder_values = array(SMPREF_NONE => '[ '._("Do not use Trash").' ]',
67 'ignore' => $boxes);
68 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
69 'name' => 'trash_folder',
70 'caption' => _("Trash Folder"),
71 'type' => SMOPT_TYPE_FLDRLIST,
72 'refresh' => SMOPT_REFRESH_FOLDERLIST,
73 'posvals' => $trash_folder_values,
74 'save' => 'save_option_trash_folder'
75 );
76
77 $draft_folder_values = array(SMPREF_NONE => '[ '._("Do not use Drafts").' ]',
78 'ignore' => $boxes);
79 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
80 'name' => 'draft_folder',
81 'caption' => _("Draft Folder"),
82 'type' => SMOPT_TYPE_FLDRLIST,
83 'refresh' => SMOPT_REFRESH_FOLDERLIST,
84 'posvals' => $draft_folder_values,
85 'save' => 'save_option_draft_folder'
86 );
87
88 $sent_folder_values = array(SMPREF_NONE => '[ '._("Do not use Sent").' ]',
89 'ignore' => $boxes);
90 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
91 'name' => 'sent_folder',
92 'caption' => _("Sent Folder"),
93 'type' => SMOPT_TYPE_FLDRLIST,
94 'refresh' => SMOPT_REFRESH_FOLDERLIST,
95 'posvals' => $sent_folder_values,
96 'save' => 'save_option_sent_folder'
97 );
98
99 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
100 'name' => 'translate_special_folders',
101 'caption' => _("Translate Special Folders"),
102 'type' => SMOPT_TYPE_BOOLEAN,
103 'refresh' => SMOPT_REFRESH_FOLDERLIST
104 );
105
106 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
107 'name' => 'save_reply_with_orig',
108 'caption' => _("Save Replies with Original Message"),
109 'type' => SMOPT_TYPE_BOOLEAN,
110 'refresh' => SMOPT_REFRESH_FOLDERLIST
111 );
112
113 /*** Load the General Options into the array ***/
114 $optgrps[SMOPT_GRP_FOLDERLIST] = _("Folder List Options");
115 $optvals[SMOPT_GRP_FOLDERLIST] = array();
116
117 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
118 'name' => 'location_of_bar',
119 'caption' => _("Location of Folder List"),
120 'type' => SMOPT_TYPE_STRLIST,
121 'refresh' => SMOPT_REFRESH_ALL,
122 'posvals' => array(SMPREF_LOC_LEFT => _("Left"),
123 SMPREF_LOC_RIGHT => _("Right"))
124 );
125
126 $left_size_values = array();
127 for ($lsv = 100; $lsv <= 300; $lsv += 10) {
128 $left_size_values[$lsv] = "$lsv " . _("pixels");
129 }
130 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
131 'name' => 'left_size',
132 'caption' => _("Width of Folder List"),
133 'type' => SMOPT_TYPE_STRLIST,
134 'refresh' => SMOPT_REFRESH_ALL,
135 'posvals' => $left_size_values
136 );
137
138 $left_refresh_values = array(SMPREF_NONE => _("Never"));
139 foreach (array(30,60,120,180,300,600,1200) as $lr_val) {
140 if ($lr_val < 60) {
141 $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds");
142 } else {
143 $left_refresh_values[$lr_val] = sprintf(ngettext("%d Minute","%d Minutes",($lr_val/60)),($lr_val/60));
144 }
145 }
146 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
147 'name' => 'left_refresh',
148 'caption' => _("Auto Refresh Folder List"),
149 'type' => SMOPT_TYPE_STRLIST,
150 'refresh' => SMOPT_REFRESH_FOLDERLIST,
151 'posvals' => $left_refresh_values
152 );
153
154 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
155 'name' => 'unseen_notify',
156 'caption' => _("Enable Unread Message Notification"),
157 'type' => SMOPT_TYPE_STRLIST,
158 'refresh' => SMOPT_REFRESH_FOLDERLIST,
159 'posvals' => array(SMPREF_UNSEEN_NONE => _("No Notification"),
160 SMPREF_UNSEEN_INBOX => _("Only INBOX"),
161 SMPREF_UNSEEN_ALL => _("All Folders"))
162 );
163
164 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
165 'name' => 'unseen_type',
166 'caption' => _("Unread Message Notification Type"),
167 'type' => SMOPT_TYPE_STRLIST,
168 'refresh' => SMOPT_REFRESH_FOLDERLIST,
169 'posvals' => array(SMPREF_UNSEEN_ONLY => _("Only Unseen"),
170 SMPREF_UNSEEN_TOTAL => _("Unseen and Total"))
171 );
172
173 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
174 'name' => 'collapse_folders',
175 'caption' => _("Enable Collapsable Folders"),
176 'type' => SMOPT_TYPE_BOOLEAN,
177 'refresh' => SMOPT_REFRESH_FOLDERLIST
178 );
179
180 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
181 'name' => 'unseen_cum',
182 'caption' => _("Enable Cumulative Unread Message Notification"),
183 'type' => SMOPT_TYPE_BOOLEAN,
184 'refresh' => SMOPT_REFRESH_FOLDERLIST
185 );
186
187
188 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
189 'name' => 'date_format',
190 'caption' => _("Show Clock on Folders Panel"),
191 'type' => SMOPT_TYPE_STRLIST,
192 'refresh' => SMOPT_REFRESH_FOLDERLIST,
193 'posvals' => array( '0' => _("International date and time"),
194 '1' => _("American date and time"),
195 '2' => _("European date and time"),
196 '3' => _("Show weekday and time"),
197 '4' => _("Show time with seconds"),
198 '5' => _("Show time"),
199 '6' => _("No Clock")),
200 );
201
202 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
203 'name' => 'search_memory',
204 'caption' => _("Memory Search"),
205 'type' => SMOPT_TYPE_STRLIST,
206 'refresh' => SMOPT_REFRESH_NONE,
207 'posvals' => array( 0 => _("Disabled"),
208 1 => '1',
209 2 => '2',
210 3 => '3',
211 4 => '4',
212 5 => '5',
213 6 => '6',
214 7 => '7',
215 8 => '8',
216 9 => '9')
217 );
218
219 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
220 'name' => 'show_only_subscribed_folders',
221 'caption' => _("Show only subscribed folders"),
222 'type' => SMOPT_TYPE_BOOLEAN,
223 'refresh' => SMOPT_REFRESH_FOLDERLIST
224 );
225
226 /*** Load the General Options into the array ***/
227 $optgrps[SMOPT_GRP_FOLDERSELECT] = _("Folder Selection Options");
228 $optvals[SMOPT_GRP_FOLDERSELECT] = array();
229
230 $nbsp = $oTemplate->fetch('non_breaking_space.tpl');
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( 0 => _("Long:") . ' "' . _("Folder") . $delim . _("Subfolder") . '"',
238 1 => _("Indented:") . " \"$nbsp$nbsp$nbsp$nbsp" . _("Subfolder") . '"',
239 2 => _("Delimited:") . " \".$nbsp" . _("Subfolder") . '"'),
240 'htmlencoded' => true
241 );
242
243 /* Assemble all this together and return it as our result. */
244 $result = array(
245 'grps' => $optgrps,
246 'vals' => $optvals
247 );
248 sqimap_logout($imapConnection);
249 return ($result);
250 }
251
252 /******************************************************************/
253 /** Define any specialized save functions for this option page. ***/
254 /******************************************************************/
255
256 /**
257 * Saves the trash folder option.
258 * @param object $option SquirrelOption object
259 * @since 1.3.2
260 */
261 function save_option_trash_folder($option) {
262 global $data_dir, $username;
263
264 if (strtolower($option->new_value)=='inbox') {
265 // make sure that it is not INBOX
266 error_option_save(_("You can't select INBOX as Trash folder."));
267 } else {
268 /* Set move to trash on or off. */
269 $trash_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
270 setPref($data_dir, $username, 'move_to_trash', $trash_on);
271
272 /* Now just save the option as normal. */
273 save_option($option);
274 }
275 }
276
277 /**
278 * Saves the sent folder option.
279 * @param object $option SquirrelOption object
280 * @since 1.3.2
281 */
282 function save_option_sent_folder($option) {
283 global $data_dir, $username;
284
285 if (strtolower($option->new_value)=='inbox') {
286 // make sure that it is not INBOX
287 error_option_save(_("You can't select INBOX as Sent folder."));
288 } else {
289 /* Set move to sent on or off. */
290 $sent_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
291 setPref($data_dir, $username, 'move_to_sent', $sent_on);
292
293 /* Now just save the option as normal. */
294 save_option($option);
295 }
296 }
297
298 /**
299 * Saves the draft folder option.
300 * @param object $option SquirrelOption object
301 * @since 1.3.2
302 */
303 function save_option_draft_folder($option) {
304 global $data_dir, $username;
305
306 if (strtolower($option->new_value)=='inbox') {
307 // make sure that it is not INBOX
308 error_option_save(_("You can't select INBOX as Draft folder."));
309 } else {
310 /* Set move to draft on or off. */
311 $draft_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
312 setPref($data_dir, $username, 'save_as_draft', $draft_on);
313
314 /* Now just save the option as normal. */
315 save_option($option);
316 }
317 }