ea9c2b5e8ab45c87521bf373b3a9365ea99a80d0
[squirrelmail.git] / include / options / folder.php
1 <?php
2
3 /**
4 * options_folder.php
5 *
6 * Copyright (c) 1999-2005 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Displays all options relating to folders
10 *
11 * @version $Id$
12 * @package squirrelmail
13 */
14
15 /** SquirrelMail required files. */
16 require_once(SM_PATH . 'functions/imap.php');
17 require_once(SM_PATH . 'functions/imap_general.php');
18
19 /* Define the group constants for the folder options page. */
20 define('SMOPT_GRP_SPCFOLDER', 0);
21 define('SMOPT_GRP_FOLDERLIST', 1);
22 define('SMOPT_GRP_FOLDERSELECT', 2);
23
24 /**
25 * This function builds an array with all the information about
26 * the options available to the user, and returns it. The options
27 * are grouped by the groups in which they are displayed.
28 * For each option, the following information is stored:
29 * - name: the internal (variable) name
30 * - caption: the description of the option in the UI
31 * - type: one of SMOPT_TYPE_*
32 * - refresh: one of SMOPT_REFRESH_*
33 * - size: one of SMOPT_SIZE_*
34 * - save: the name of a function to call when saving this option
35 * @return array all option information
36 */
37 function load_optpage_data_folder() {
38 global $username, $key, $imapServerAddress, $imapPort;
39 global $folder_prefix, $default_folder_prefix, $show_prefix_option;
40
41 /* Get some imap data we need later. */
42 $imapConnection =
43 sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
44 $boxes = sqimap_mailbox_list($imapConnection);
45
46 /* Build a simple array into which we will build options. */
47 $optgrps = array();
48 $optvals = array();
49
50 /******************************************************/
51 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
52 /******************************************************/
53
54 /*** Load the General Options into the array ***/
55 $optgrps[SMOPT_GRP_SPCFOLDER] = _("Special Folder Options");
56 $optvals[SMOPT_GRP_SPCFOLDER] = array();
57
58 if (!isset($folder_prefix)) { $folder_prefix = $default_folder_prefix; }
59 if ($show_prefix_option) {
60 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
61 'name' => 'folder_prefix',
62 'caption' => _("Folder Path"),
63 'type' => SMOPT_TYPE_STRING,
64 'refresh' => SMOPT_REFRESH_FOLDERLIST,
65 'size' => SMOPT_SIZE_LARGE
66 );
67 }
68
69 $trash_folder_values = array(SMPREF_NONE => '[ '._("Do not use Trash").' ]',
70 'whatever' => $boxes);
71 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
72 'name' => 'trash_folder',
73 'caption' => _("Trash Folder"),
74 'type' => SMOPT_TYPE_FLDRLIST,
75 'refresh' => SMOPT_REFRESH_FOLDERLIST,
76 'posvals' => $trash_folder_values,
77 'save' => 'save_option_trash_folder'
78 );
79
80 $draft_folder_values = array(SMPREF_NONE => '[ '._("Do not use Drafts").' ]',
81 'whatever' => $boxes);
82 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
83 'name' => 'draft_folder',
84 'caption' => _("Draft Folder"),
85 'type' => SMOPT_TYPE_FLDRLIST,
86 'refresh' => SMOPT_REFRESH_FOLDERLIST,
87 'posvals' => $draft_folder_values,
88 'save' => 'save_option_draft_folder'
89 );
90
91 $sent_folder_values = array(SMPREF_NONE => '[ '._("Do not use Sent").' ]',
92 'whatever' => $boxes);
93 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
94 'name' => 'sent_folder',
95 'caption' => _("Sent Folder"),
96 'type' => SMOPT_TYPE_FLDRLIST,
97 'refresh' => SMOPT_REFRESH_FOLDERLIST,
98 'posvals' => $sent_folder_values,
99 'save' => 'save_option_sent_folder'
100 );
101
102 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
103 'name' => 'save_reply_with_orig',
104 'caption' => _("Save Replies with Original Message"),
105 'type' => SMOPT_TYPE_BOOLEAN,
106 'refresh' => SMOPT_REFRESH_FOLDERLIST
107 );
108
109 /*** Load the General Options into the array ***/
110 $optgrps[SMOPT_GRP_FOLDERLIST] = _("Folder List Options");
111 $optvals[SMOPT_GRP_FOLDERLIST] = array();
112
113 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
114 'name' => 'location_of_bar',
115 'caption' => _("Location of Folder List"),
116 'type' => SMOPT_TYPE_STRLIST,
117 'refresh' => SMOPT_REFRESH_ALL,
118 'posvals' => array(SMPREF_LOC_LEFT => _("Left"),
119 SMPREF_LOC_RIGHT => _("Right"))
120 );
121
122 $left_size_values = array();
123 for ($lsv = 100; $lsv <= 300; $lsv += 10) {
124 $left_size_values[$lsv] = "$lsv " . _("pixels");
125 }
126 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
127 'name' => 'left_size',
128 'caption' => _("Width of Folder List"),
129 'type' => SMOPT_TYPE_STRLIST,
130 'refresh' => SMOPT_REFRESH_ALL,
131 'posvals' => $left_size_values
132 );
133
134 $minute_str = _("Minutes");
135 $left_refresh_values = array(SMPREF_NONE => _("Never"));
136 foreach (array(30,60,120,180,300,600) as $lr_val) {
137 if ($lr_val < 60) {
138 $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds");
139 } else if ($lr_val == 60) {
140 $left_refresh_values[$lr_val] = "1 " . _("Minute");
141 } else {
142 $left_refresh_values[$lr_val] = ($lr_val/60) . " $minute_str";
143 }
144 }
145 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
146 'name' => 'left_refresh',
147 'caption' => _("Auto Refresh Folder List"),
148 'type' => SMOPT_TYPE_STRLIST,
149 'refresh' => SMOPT_REFRESH_FOLDERLIST,
150 'posvals' => $left_refresh_values
151 );
152
153 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
154 'name' => 'unseen_notify',
155 'caption' => _("Enable Unread Message Notification"),
156 'type' => SMOPT_TYPE_STRLIST,
157 'refresh' => SMOPT_REFRESH_FOLDERLIST,
158 'posvals' => array(SMPREF_UNSEEN_NONE => _("No Notification"),
159 SMPREF_UNSEEN_INBOX => _("Only INBOX"),
160 SMPREF_UNSEEN_ALL => _("All Folders"))
161 );
162
163 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
164 'name' => 'unseen_type',
165 'caption' => _("Unread Message Notification Type"),
166 'type' => SMOPT_TYPE_STRLIST,
167 'refresh' => SMOPT_REFRESH_FOLDERLIST,
168 'posvals' => array(SMPREF_UNSEEN_ONLY => _("Only Unseen"),
169 SMPREF_UNSEEN_TOTAL => _("Unseen and Total"))
170 );
171
172 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
173 'name' => 'collapse_folders',
174 'caption' => _("Enable Collapsable Folders"),
175 'type' => SMOPT_TYPE_BOOLEAN,
176 'refresh' => SMOPT_REFRESH_FOLDERLIST
177 );
178
179 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
180 'name' => 'unseen_cum',
181 'caption' => _("Enable Cumulative Unread Message Notification"),
182 'type' => SMOPT_TYPE_BOOLEAN,
183 'refresh' => SMOPT_REFRESH_FOLDERLIST
184 );
185
186
187 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
188 'name' => 'date_format',
189 'caption' => _("Show Clock on Folders Panel"),
190 'type' => SMOPT_TYPE_STRLIST,
191 'refresh' => SMOPT_REFRESH_FOLDERLIST,
192 'posvals' => array( '0' => _("International date and time"),
193 '1' => _("American date and time"),
194 '2' => _("European date and time"),
195 '3' => _("Show weekday and time"),
196 '4' => _("Show time with seconds"),
197 '5' => _("Show time"),
198 '6' => _("No Clock")),
199 );
200
201 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
202 'name' => 'hour_format',
203 'caption' => _("Hour Format"),
204 'type' => SMOPT_TYPE_STRLIST,
205 'refresh' => SMOPT_REFRESH_FOLDERLIST,
206 'posvals' => array(SMPREF_TIME_12HR => _("12-hour clock"),
207 SMPREF_TIME_24HR => _("24-hour clock"))
208 );
209
210 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
211 'name' => 'search_memory',
212 'caption' => _("Memory Search"),
213 'type' => SMOPT_TYPE_STRLIST,
214 'refresh' => SMOPT_REFRESH_NONE,
215 'posvals' => array( 0 => _("Disabled"),
216 1 => '1',
217 2 => '2',
218 3 => '3',
219 4 => '4',
220 5 => '5',
221 6 => '6',
222 7 => '7',
223 8 => '8',
224 9 => '9')
225 );
226
227
228 /*** Load the General Options into the array ***/
229 $optgrps[SMOPT_GRP_FOLDERSELECT] = _("Folder Selection Options");
230 $optvals[SMOPT_GRP_FOLDERSELECT] = array();
231
232 $delim = sqimap_get_delimiter($imapConnection);
233 $optvals[SMOPT_GRP_FOLDERSELECT][] = array(
234 'name' => 'mailbox_select_style',
235 'caption' => _("Selection List Style"),
236 'type' => SMOPT_TYPE_STRLIST,
237 'refresh' => SMOPT_REFRESH_NONE,
238 'posvals' => array( 0 => _("Long: ") . '"' . _("Folder") . $delim . _("Subfolder") . '"',
239 1 => _("Indented: ") . '"&nbsp;&nbsp;&nbsp;&nbsp;' . _("Subfolder") . '"',
240 2 => _("Delimited: ") . '".&nbsp;' . _("Subfolder") . '"'),
241 'htmlencoded' => true
242 );
243
244 /* Assemble all this together and return it as our result. */
245 $result = array(
246 'grps' => $optgrps,
247 'vals' => $optvals
248 );
249 sqimap_logout($imapConnection);
250 return ($result);
251 }
252
253 /******************************************************************/
254 /** Define any specialized save functions for this option page. ***/
255 /******************************************************************/
256
257 /**
258 * Saves the trash folder option.
259 */
260 function save_option_trash_folder($option) {
261 global $data_dir, $username;
262
263 /* Set move to trash on or off. */
264 $trash_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
265 setPref($data_dir, $username, 'move_to_trash', $trash_on);
266
267 /* Now just save the option as normal. */
268 save_option($option);
269 }
270
271 /**
272 * Saves the sent folder option.
273 */
274 function save_option_sent_folder($option) {
275 global $data_dir, $username;
276
277 /* Set move to sent on or off. */
278 $sent_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
279 setPref($data_dir, $username, 'move_to_sent', $sent_on);
280
281 /* Now just save the option as normal. */
282 save_option($option);
283 }
284
285 /**
286 * Saves the draft folder option.
287 */
288 function save_option_draft_folder($option) {
289 global $data_dir, $username;
290
291 /* Set move to draft on or off. */
292 $draft_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
293 setPref($data_dir, $username, 'save_as_draft', $draft_on);
294
295 /* Now just save the option as normal. */
296 save_option($option);
297 }
298
299 ?>