c36ed9cf |
1 | <?php |
c36ed9cf |
2 | |
35586184 |
3 | /** |
4 | * options_folder.php |
5 | * |
35586184 |
6 | * Displays all options relating to folders |
7 | * |
4b5049de |
8 | * @copyright © 1999-2007 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 |
15 | include(SM_PATH . 'functions/imap_general.php'); |
cbe5423b |
16 | |
aedb6605 |
17 | /* Define the group constants for the folder options page. */ |
cbe5423b |
18 | define('SMOPT_GRP_SPCFOLDER', 0); |
19 | define('SMOPT_GRP_FOLDERLIST', 1); |
be2d5495 |
20 | define('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 |
35 | function load_optpage_data_folder() { |
551c7b53 |
36 | global $username, $imapServerAddress, $imapPort, $oTemplate, $nbsp, |
0177059f |
37 | $folder_prefix, $default_folder_prefix, $show_prefix_option; |
cbe5423b |
38 | |
39 | /* Get some imap data we need later. */ |
045ec1a1 |
40 | $imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0); |
cbe5423b |
41 | $boxes = sqimap_mailbox_list($imapConnection); |
bbcafebd |
42 | |
b5efadfa |
43 | /* Build a simple array into which we will build options. */ |
bbcafebd |
44 | $optgrps = array(); |
b5efadfa |
45 | $optvals = array(); |
46 | |
bbcafebd |
47 | /******************************************************/ |
48 | /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */ |
49 | /******************************************************/ |
bbcafebd |
50 | |
51 | /*** Load the General Options into the array ***/ |
52 | $optgrps[SMOPT_GRP_SPCFOLDER] = _("Special Folder Options"); |
53 | $optvals[SMOPT_GRP_SPCFOLDER] = array(); |
54 | |
cbe5423b |
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 | |
be2d5495 |
66 | $trash_folder_values = array(SMPREF_NONE => '[ '._("Do not use Trash").' ]', |
0177059f |
67 | 'ignore' => $boxes); |
bbcafebd |
68 | $optvals[SMOPT_GRP_SPCFOLDER][] = array( |
b5efadfa |
69 | 'name' => 'trash_folder', |
70 | 'caption' => _("Trash Folder"), |
be2d5495 |
71 | 'type' => SMOPT_TYPE_FLDRLIST, |
b5efadfa |
72 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
cbe5423b |
73 | 'posvals' => $trash_folder_values, |
74 | 'save' => 'save_option_trash_folder' |
b5efadfa |
75 | ); |
aedb6605 |
76 | |
77 | $draft_folder_values = array(SMPREF_NONE => '[ '._("Do not use Drafts").' ]', |
0177059f |
78 | 'ignore' => $boxes); |
aedb6605 |
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 | |
be2d5495 |
88 | $sent_folder_values = array(SMPREF_NONE => '[ '._("Do not use Sent").' ]', |
0177059f |
89 | 'ignore' => $boxes); |
bbcafebd |
90 | $optvals[SMOPT_GRP_SPCFOLDER][] = array( |
b5efadfa |
91 | 'name' => 'sent_folder', |
92 | 'caption' => _("Sent Folder"), |
be2d5495 |
93 | 'type' => SMOPT_TYPE_FLDRLIST, |
b5efadfa |
94 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
cbe5423b |
95 | 'posvals' => $sent_folder_values, |
96 | 'save' => 'save_option_sent_folder' |
b5efadfa |
97 | ); |
aedb6605 |
98 | |
7652c651 |
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 | |
bbcafebd |
106 | $optvals[SMOPT_GRP_SPCFOLDER][] = array( |
aedb6605 |
107 | 'name' => 'save_reply_with_orig', |
108 | 'caption' => _("Save Replies with Original Message"), |
109 | 'type' => SMOPT_TYPE_BOOLEAN, |
110 | 'refresh' => SMOPT_REFRESH_FOLDERLIST |
b5efadfa |
111 | ); |
112 | |
bbcafebd |
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( |
a440e68f |
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 | } |
bbcafebd |
130 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
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 | |
a440e68f |
138 | $left_refresh_values = array(SMPREF_NONE => _("Never")); |
721db745 |
139 | foreach (array(30,60,120,180,300,600,1200) as $lr_val) { |
a440e68f |
140 | if ($lr_val < 60) { |
141 | $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds"); |
a440e68f |
142 | } else { |
031b6f72 |
143 | $left_refresh_values[$lr_val] = sprintf(ngettext("%d Minute","%d Minutes",($lr_val/60)),($lr_val/60)); |
a440e68f |
144 | } |
145 | } |
bbcafebd |
146 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
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 | |
bbcafebd |
154 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
155 | 'name' => 'unseen_notify', |
10ff0c3d |
156 | 'caption' => _("Enable Unread Message Notification"), |
a440e68f |
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 | |
bbcafebd |
164 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
165 | 'name' => 'unseen_type', |
10ff0c3d |
166 | 'caption' => _("Unread Message Notification Type"), |
a440e68f |
167 | 'type' => SMOPT_TYPE_STRLIST, |
168 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
169 | 'posvals' => array(SMPREF_UNSEEN_ONLY => _("Only Unseen"), |
aedb6605 |
170 | SMPREF_UNSEEN_TOTAL => _("Unseen and Total")) |
a440e68f |
171 | ); |
172 | |
bbcafebd |
173 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
174 | 'name' => 'collapse_folders', |
175 | 'caption' => _("Enable Collapsable Folders"), |
176 | 'type' => SMOPT_TYPE_BOOLEAN, |
177 | 'refresh' => SMOPT_REFRESH_FOLDERLIST |
178 | ); |
179 | |
f612a235 |
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 | |
bbcafebd |
188 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
189 | 'name' => 'date_format', |
190 | 'caption' => _("Show Clock on Folders Panel"), |
191 | 'type' => SMOPT_TYPE_STRLIST, |
192 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
e4f5158a |
193 | 'posvals' => array( '0' => _("International date and time"), |
300a044d |
194 | '1' => _("American date and time"), |
e4f5158a |
195 | '2' => _("European date and time"), |
157e9c5e |
196 | '3' => _("Show weekday and time"), |
197 | '4' => _("Show time with seconds"), |
198 | '5' => _("Show time"), |
a440e68f |
199 | '6' => _("No Clock")), |
200 | ); |
201 | |
0d672ac0 |
202 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
203 | 'name' => 'search_memory', |
204 | 'caption' => _("Memory Search"), |
205 | 'type' => SMOPT_TYPE_STRLIST, |
90568047 |
206 | 'refresh' => SMOPT_REFRESH_NONE, |
0d672ac0 |
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', |
a2bc1180 |
216 | 9 => '9') |
217 | ); |
0d672ac0 |
218 | |
4d5f2b31 |
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 | ); |
be2d5495 |
225 | |
226 | /*** Load the General Options into the array ***/ |
227 | $optgrps[SMOPT_GRP_FOLDERSELECT] = _("Folder Selection Options"); |
228 | $optvals[SMOPT_GRP_FOLDERSELECT] = array(); |
229 | |
ebbf2fd0 |
230 | $delim = sqimap_get_delimiter($imapConnection); |
be2d5495 |
231 | $optvals[SMOPT_GRP_FOLDERSELECT][] = array( |
232 | 'name' => 'mailbox_select_style', |
233 | 'caption' => _("Selection List Style"), |
234 | 'type' => SMOPT_TYPE_STRLIST, |
235 | 'refresh' => SMOPT_REFRESH_NONE, |
d56050e1 |
236 | 'posvals' => array( |
237 | SMPREF_MAILBOX_SELECT_LONG => |
238 | _("Long:") . ' "' . _("Folder") . $delim . _("Subfolder") . '"', |
239 | SMPREF_MAILBOX_SELECT_INDENTED => |
240 | _("Indented:") . " \"$nbsp$nbsp$nbsp$nbsp" . _("Subfolder") . '"', |
241 | SMPREF_MAILBOX_SELECT_DELIMITED => |
242 | _("Delimited:") . " \".$nbsp" . _("Subfolder") . '"'), |
300a044d |
243 | 'htmlencoded' => true |
be2d5495 |
244 | ); |
245 | |
cbe5423b |
246 | /* Assemble all this together and return it as our result. */ |
247 | $result = array( |
248 | 'grps' => $optgrps, |
249 | 'vals' => $optvals |
250 | ); |
ebbf2fd0 |
251 | sqimap_logout($imapConnection); |
cbe5423b |
252 | return ($result); |
253 | } |
254 | |
255 | /******************************************************************/ |
256 | /** Define any specialized save functions for this option page. ***/ |
257 | /******************************************************************/ |
48af4b64 |
258 | |
259 | /** |
260 | * Saves the trash folder option. |
345e009b |
261 | * @param object $option SquirrelOption object |
262 | * @since 1.3.2 |
48af4b64 |
263 | */ |
cbe5423b |
264 | function save_option_trash_folder($option) { |
265 | global $data_dir, $username; |
266 | |
345e009b |
267 | if (strtolower($option->new_value)=='inbox') { |
268 | // make sure that it is not INBOX |
269 | error_option_save(_("You can't select INBOX as Trash folder.")); |
270 | } else { |
271 | /* Set move to trash on or off. */ |
272 | $trash_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON); |
273 | setPref($data_dir, $username, 'move_to_trash', $trash_on); |
a440e68f |
274 | |
345e009b |
275 | /* Now just save the option as normal. */ |
276 | save_option($option); |
277 | } |
cbe5423b |
278 | } |
2016e645 |
279 | |
48af4b64 |
280 | /** |
281 | * Saves the sent folder option. |
345e009b |
282 | * @param object $option SquirrelOption object |
283 | * @since 1.3.2 |
48af4b64 |
284 | */ |
cbe5423b |
285 | function save_option_sent_folder($option) { |
286 | global $data_dir, $username; |
e7db48af |
287 | |
345e009b |
288 | if (strtolower($option->new_value)=='inbox') { |
289 | // make sure that it is not INBOX |
290 | error_option_save(_("You can't select INBOX as Sent folder.")); |
291 | } else { |
292 | /* Set move to sent on or off. */ |
293 | $sent_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON); |
294 | setPref($data_dir, $username, 'move_to_sent', $sent_on); |
e7db48af |
295 | |
345e009b |
296 | /* Now just save the option as normal. */ |
297 | save_option($option); |
298 | } |
cbe5423b |
299 | } |
e7db48af |
300 | |
48af4b64 |
301 | /** |
302 | * Saves the draft folder option. |
345e009b |
303 | * @param object $option SquirrelOption object |
304 | * @since 1.3.2 |
48af4b64 |
305 | */ |
cbe5423b |
306 | function save_option_draft_folder($option) { |
307 | global $data_dir, $username; |
308 | |
345e009b |
309 | if (strtolower($option->new_value)=='inbox') { |
310 | // make sure that it is not INBOX |
311 | error_option_save(_("You can't select INBOX as Draft folder.")); |
312 | } else { |
313 | /* Set move to draft on or off. */ |
314 | $draft_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON); |
315 | setPref($data_dir, $username, 'save_as_draft', $draft_on); |
316 | |
317 | /* Now just save the option as normal. */ |
318 | save_option($option); |
319 | } |
cbe5423b |
320 | } |