Getting ready for 1.4.0 RC1
[squirrelmail.git] / include / options / folder.php
1 <?php
2
3 /**
4 * options_folder.php
5 *
6 * Copyright (c) 1999-2003 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 * $Id$
12 */
13
14 /* SquirrelMail required files. */
15 require_once(SM_PATH . 'functions/imap.php');
16 require_once(SM_PATH . 'functions/imap_general.php');
17
18 /* Define the group constants for the folder options page. */
19 define('SMOPT_GRP_SPCFOLDER', 0);
20 define('SMOPT_GRP_FOLDERLIST', 1);
21 define('SMOPT_GRP_FOLDERSELECT', 2);
22
23 /* Define the optpage load function for the folder options page. */
24 function load_optpage_data_folder() {
25 global $username, $key, $imapServerAddress, $imapPort;
26 global $folder_prefix, $default_folder_prefix, $show_prefix_option;
27
28 /* Get some imap data we need later. */
29 $imapConnection =
30 sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
31 $boxes = sqimap_mailbox_list($imapConnection);
32
33 /* Build a simple array into which we will build options. */
34 $optgrps = array();
35 $optvals = array();
36
37 /******************************************************/
38 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
39 /******************************************************/
40
41 /*** Load the General Options into the array ***/
42 $optgrps[SMOPT_GRP_SPCFOLDER] = _("Special Folder Options");
43 $optvals[SMOPT_GRP_SPCFOLDER] = array();
44
45 if (!isset($folder_prefix)) { $folder_prefix = $default_folder_prefix; }
46 if ($show_prefix_option) {
47 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
48 'name' => 'folder_prefix',
49 'caption' => _("Folder Path"),
50 'type' => SMOPT_TYPE_STRING,
51 'refresh' => SMOPT_REFRESH_FOLDERLIST,
52 'size' => SMOPT_SIZE_LARGE
53 );
54 }
55
56 $trash_folder_values = array(SMPREF_NONE => '[ '._("Do not use Trash").' ]',
57 'whatever' => $boxes);
58 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
59 'name' => 'trash_folder',
60 'caption' => _("Trash Folder"),
61 'type' => SMOPT_TYPE_FLDRLIST,
62 'refresh' => SMOPT_REFRESH_FOLDERLIST,
63 'posvals' => $trash_folder_values,
64 'save' => 'save_option_trash_folder'
65 );
66
67 $sent_folder_values = array(SMPREF_NONE => '[ '._("Do not use Sent").' ]',
68 'whatever' => $boxes);
69 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
70 'name' => 'sent_folder',
71 'caption' => _("Sent Folder"),
72 'type' => SMOPT_TYPE_FLDRLIST,
73 'refresh' => SMOPT_REFRESH_FOLDERLIST,
74 'posvals' => $sent_folder_values,
75 'save' => 'save_option_sent_folder'
76 );
77
78 $draft_folder_values = array(SMPREF_NONE => '[ '._("Do not use Drafts").' ]',
79 'whatever' => $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 /*** Load the General Options into the array ***/
90 $optgrps[SMOPT_GRP_FOLDERLIST] = _("Folder List Options");
91 $optvals[SMOPT_GRP_FOLDERLIST] = array();
92
93 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
94 'name' => 'location_of_bar',
95 'caption' => _("Location of Folder List"),
96 'type' => SMOPT_TYPE_STRLIST,
97 'refresh' => SMOPT_REFRESH_ALL,
98 'posvals' => array(SMPREF_LOC_LEFT => _("Left"),
99 SMPREF_LOC_RIGHT => _("Right"))
100 );
101
102 $left_size_values = array();
103 for ($lsv = 100; $lsv <= 300; $lsv += 10) {
104 $left_size_values[$lsv] = "$lsv " . _("pixels");
105 }
106 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
107 'name' => 'left_size',
108 'caption' => _("Width of Folder List"),
109 'type' => SMOPT_TYPE_STRLIST,
110 'refresh' => SMOPT_REFRESH_ALL,
111 'posvals' => $left_size_values
112 );
113
114 $minute_str = _("Minutes");
115 $left_refresh_values = array(SMPREF_NONE => _("Never"));
116 foreach (array(30,60,120,180,300,600) as $lr_val) {
117 if ($lr_val < 60) {
118 $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds");
119 } else if ($lr_val == 60) {
120 $left_refresh_values[$lr_val] = "1 " . _("Minute");
121 } else {
122 $left_refresh_values[$lr_val] = ($lr_val/60) . " $minute_str";
123 }
124 }
125 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
126 'name' => 'left_refresh',
127 'caption' => _("Auto Refresh Folder List"),
128 'type' => SMOPT_TYPE_STRLIST,
129 'refresh' => SMOPT_REFRESH_FOLDERLIST,
130 'posvals' => $left_refresh_values
131 );
132
133 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
134 'name' => 'unseen_notify',
135 'caption' => _("Enable Unread Message Notification"),
136 'type' => SMOPT_TYPE_STRLIST,
137 'refresh' => SMOPT_REFRESH_FOLDERLIST,
138 'posvals' => array(SMPREF_UNSEEN_NONE => _("No Notification"),
139 SMPREF_UNSEEN_INBOX => _("Only INBOX"),
140 SMPREF_UNSEEN_ALL => _("All Folders"))
141 );
142
143 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
144 'name' => 'unseen_type',
145 'caption' => _("Unread Message Notification Type"),
146 'type' => SMOPT_TYPE_STRLIST,
147 'refresh' => SMOPT_REFRESH_FOLDERLIST,
148 'posvals' => array(SMPREF_UNSEEN_ONLY => _("Only Unseen"),
149 SMPREF_UNSEEN_TOTAL => _("Unseen and Total"))
150 );
151
152 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
153 'name' => 'collapse_folders',
154 'caption' => _("Enable Collapsable Folders"),
155 'type' => SMOPT_TYPE_BOOLEAN,
156 'refresh' => SMOPT_REFRESH_FOLDERLIST
157 );
158
159 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
160 'name' => 'unseen_cum',
161 'caption' => _("Enable Cumulative Unread Message Notification"),
162 'type' => SMOPT_TYPE_BOOLEAN,
163 'refresh' => SMOPT_REFRESH_FOLDERLIST
164 );
165
166
167 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
168 'name' => 'date_format',
169 'caption' => _("Show Clock on Folders Panel"),
170 'type' => SMOPT_TYPE_STRLIST,
171 'refresh' => SMOPT_REFRESH_FOLDERLIST,
172 'posvals' => array( '1' => 'MM/DD/YY HH:MM',
173 '2' => 'DD/MM/YY HH:MM',
174 '3' => 'DDD, HH:MM',
175 '4' => 'HH:MM:SS',
176 '5' => 'HH:MM',
177 '6' => _("No Clock")),
178 );
179
180 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
181 'name' => 'hour_format',
182 'caption' => _("Hour Format"),
183 'type' => SMOPT_TYPE_STRLIST,
184 'refresh' => SMOPT_REFRESH_FOLDERLIST,
185 'posvals' => array(SMPREF_TIME_12HR => _("12-hour clock"),
186 SMPREF_TIME_24HR => _("24-hour clock"))
187 );
188
189 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
190 'name' => 'search_memory',
191 'caption' => _("Memory Search"),
192 'type' => SMOPT_TYPE_STRLIST,
193 'refresh' => SMOPT_REFRESH_NONE,
194 'posvals' => array( 0 => _("Disabled"),
195 1 => '1',
196 2 => '2',
197 3 => '3',
198 4 => '4',
199 5 => '5',
200 6 => '6',
201 7 => '7',
202 8 => '8',
203 9 => '9')
204 );
205
206
207 /*** Load the General Options into the array ***/
208 $optgrps[SMOPT_GRP_FOLDERSELECT] = _("Folder Selection Options");
209 $optvals[SMOPT_GRP_FOLDERSELECT] = array();
210
211 $delim = sqimap_get_delimiter($imapConnection);
212 $optvals[SMOPT_GRP_FOLDERSELECT][] = array(
213 'name' => 'mailbox_select_style',
214 'caption' => _("Selection List Style"),
215 'type' => SMOPT_TYPE_STRLIST,
216 'refresh' => SMOPT_REFRESH_NONE,
217 'posvals' => array( 0 => _("Long: ") . '"Folder' . $delim . 'Subfolder"',
218 1 => _("Indented: ") . '"&nbsp;&nbsp;&nbsp;&nbsp;' . 'Subfolder"',
219 2 => _("Delimited: ") . '".&nbsp;' . 'Subfolder"')
220 );
221
222 /* Assemble all this together and return it as our result. */
223 $result = array(
224 'grps' => $optgrps,
225 'vals' => $optvals
226 );
227 sqimap_logout($imapConnection);
228 return ($result);
229 }
230
231 /******************************************************************/
232 /** Define any specialized save functions for this option page. ***/
233 /******************************************************************/
234 function save_option_trash_folder($option) {
235 global $data_dir, $username;
236
237 /* Set move to trash on or off. */
238 $trash_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
239 setPref($data_dir, $username, 'move_to_trash', $trash_on);
240
241 /* Now just save the option as normal. */
242 save_option($option);
243 }
244
245 function save_option_sent_folder($option) {
246 global $data_dir, $username;
247
248 /* Set move to sent on or off. */
249 $sent_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
250 setPref($data_dir, $username, 'move_to_sent', $sent_on);
251
252 /* Now just save the option as normal. */
253 save_option($option);
254 }
255
256 function save_option_draft_folder($option) {
257 global $data_dir, $username;
258
259 /* Set move to draft on or off. */
260 $draft_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
261 setPref($data_dir, $username, 'save_as_draft', $draft_on);
262
263 /* Now just save the option as normal. */
264 save_option($option);
265 }
266
267 ?>