c36ed9cf |
1 | <?php |
c36ed9cf |
2 | |
35586184 |
3 | /** |
4 | * options_folder.php |
5 | * |
6c84ba1e |
6 | * Copyright (c) 1999-2005 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * Displays all options relating to folders |
10 | * |
763b63fe |
11 | * @version $Id$ |
2b646597 |
12 | * @package squirrelmail |
35586184 |
13 | */ |
cbe5423b |
14 | |
2b646597 |
15 | /** SquirrelMail required files. */ |
86725763 |
16 | require_once(SM_PATH . 'functions/imap.php'); |
be2d5495 |
17 | require_once(SM_PATH . 'functions/imap_general.php'); |
cbe5423b |
18 | |
aedb6605 |
19 | /* Define the group constants for the folder options page. */ |
cbe5423b |
20 | define('SMOPT_GRP_SPCFOLDER', 0); |
21 | define('SMOPT_GRP_FOLDERLIST', 1); |
be2d5495 |
22 | define('SMOPT_GRP_FOLDERSELECT', 2); |
cbe5423b |
23 | |
48af4b64 |
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 | */ |
cbe5423b |
37 | function load_optpage_data_folder() { |
38 | global $username, $key, $imapServerAddress, $imapPort; |
2fad95fa |
39 | global $folder_prefix, $default_folder_prefix, $show_prefix_option; |
cbe5423b |
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); |
bbcafebd |
45 | |
b5efadfa |
46 | /* Build a simple array into which we will build options. */ |
bbcafebd |
47 | $optgrps = array(); |
b5efadfa |
48 | $optvals = array(); |
49 | |
bbcafebd |
50 | /******************************************************/ |
51 | /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */ |
52 | /******************************************************/ |
bbcafebd |
53 | |
54 | /*** Load the General Options into the array ***/ |
55 | $optgrps[SMOPT_GRP_SPCFOLDER] = _("Special Folder Options"); |
56 | $optvals[SMOPT_GRP_SPCFOLDER] = array(); |
57 | |
cbe5423b |
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 | |
be2d5495 |
69 | $trash_folder_values = array(SMPREF_NONE => '[ '._("Do not use Trash").' ]', |
70 | 'whatever' => $boxes); |
bbcafebd |
71 | $optvals[SMOPT_GRP_SPCFOLDER][] = array( |
b5efadfa |
72 | 'name' => 'trash_folder', |
73 | 'caption' => _("Trash Folder"), |
be2d5495 |
74 | 'type' => SMOPT_TYPE_FLDRLIST, |
b5efadfa |
75 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
cbe5423b |
76 | 'posvals' => $trash_folder_values, |
77 | 'save' => 'save_option_trash_folder' |
b5efadfa |
78 | ); |
aedb6605 |
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 | |
be2d5495 |
91 | $sent_folder_values = array(SMPREF_NONE => '[ '._("Do not use Sent").' ]', |
92 | 'whatever' => $boxes); |
bbcafebd |
93 | $optvals[SMOPT_GRP_SPCFOLDER][] = array( |
b5efadfa |
94 | 'name' => 'sent_folder', |
95 | 'caption' => _("Sent Folder"), |
be2d5495 |
96 | 'type' => SMOPT_TYPE_FLDRLIST, |
b5efadfa |
97 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
cbe5423b |
98 | 'posvals' => $sent_folder_values, |
99 | 'save' => 'save_option_sent_folder' |
b5efadfa |
100 | ); |
aedb6605 |
101 | |
bbcafebd |
102 | $optvals[SMOPT_GRP_SPCFOLDER][] = array( |
aedb6605 |
103 | 'name' => 'save_reply_with_orig', |
104 | 'caption' => _("Save Replies with Original Message"), |
105 | 'type' => SMOPT_TYPE_BOOLEAN, |
106 | 'refresh' => SMOPT_REFRESH_FOLDERLIST |
b5efadfa |
107 | ); |
108 | |
bbcafebd |
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( |
a440e68f |
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 | } |
bbcafebd |
126 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
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 | |
a440e68f |
134 | $left_refresh_values = array(SMPREF_NONE => _("Never")); |
721db745 |
135 | foreach (array(30,60,120,180,300,600,1200) as $lr_val) { |
a440e68f |
136 | if ($lr_val < 60) { |
137 | $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds"); |
a440e68f |
138 | } else { |
031b6f72 |
139 | $left_refresh_values[$lr_val] = sprintf(ngettext("%d Minute","%d Minutes",($lr_val/60)),($lr_val/60)); |
a440e68f |
140 | } |
141 | } |
bbcafebd |
142 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
143 | 'name' => 'left_refresh', |
144 | 'caption' => _("Auto Refresh Folder List"), |
145 | 'type' => SMOPT_TYPE_STRLIST, |
146 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
147 | 'posvals' => $left_refresh_values |
148 | ); |
149 | |
bbcafebd |
150 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
151 | 'name' => 'unseen_notify', |
10ff0c3d |
152 | 'caption' => _("Enable Unread Message Notification"), |
a440e68f |
153 | 'type' => SMOPT_TYPE_STRLIST, |
154 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
155 | 'posvals' => array(SMPREF_UNSEEN_NONE => _("No Notification"), |
156 | SMPREF_UNSEEN_INBOX => _("Only INBOX"), |
157 | SMPREF_UNSEEN_ALL => _("All Folders")) |
158 | ); |
159 | |
bbcafebd |
160 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
161 | 'name' => 'unseen_type', |
10ff0c3d |
162 | 'caption' => _("Unread Message Notification Type"), |
a440e68f |
163 | 'type' => SMOPT_TYPE_STRLIST, |
164 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
165 | 'posvals' => array(SMPREF_UNSEEN_ONLY => _("Only Unseen"), |
aedb6605 |
166 | SMPREF_UNSEEN_TOTAL => _("Unseen and Total")) |
a440e68f |
167 | ); |
168 | |
bbcafebd |
169 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
170 | 'name' => 'collapse_folders', |
171 | 'caption' => _("Enable Collapsable Folders"), |
172 | 'type' => SMOPT_TYPE_BOOLEAN, |
173 | 'refresh' => SMOPT_REFRESH_FOLDERLIST |
174 | ); |
175 | |
f612a235 |
176 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
177 | 'name' => 'unseen_cum', |
178 | 'caption' => _("Enable Cumulative Unread Message Notification"), |
179 | 'type' => SMOPT_TYPE_BOOLEAN, |
180 | 'refresh' => SMOPT_REFRESH_FOLDERLIST |
181 | ); |
182 | |
183 | |
bbcafebd |
184 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
a440e68f |
185 | 'name' => 'date_format', |
186 | 'caption' => _("Show Clock on Folders Panel"), |
187 | 'type' => SMOPT_TYPE_STRLIST, |
188 | 'refresh' => SMOPT_REFRESH_FOLDERLIST, |
e4f5158a |
189 | 'posvals' => array( '0' => _("International date and time"), |
300a044d |
190 | '1' => _("American date and time"), |
e4f5158a |
191 | '2' => _("European date and time"), |
157e9c5e |
192 | '3' => _("Show weekday and time"), |
193 | '4' => _("Show time with seconds"), |
194 | '5' => _("Show time"), |
a440e68f |
195 | '6' => _("No Clock")), |
196 | ); |
197 | |
0d672ac0 |
198 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
199 | 'name' => 'search_memory', |
200 | 'caption' => _("Memory Search"), |
201 | 'type' => SMOPT_TYPE_STRLIST, |
90568047 |
202 | 'refresh' => SMOPT_REFRESH_NONE, |
0d672ac0 |
203 | 'posvals' => array( 0 => _("Disabled"), |
204 | 1 => '1', |
205 | 2 => '2', |
206 | 3 => '3', |
207 | 4 => '4', |
208 | 5 => '5', |
209 | 6 => '6', |
210 | 7 => '7', |
211 | 8 => '8', |
a2bc1180 |
212 | 9 => '9') |
213 | ); |
0d672ac0 |
214 | |
4d5f2b31 |
215 | $optvals[SMOPT_GRP_FOLDERLIST][] = array( |
216 | 'name' => 'show_only_subscribed_folders', |
217 | 'caption' => _("Show only subscribed folders"), |
218 | 'type' => SMOPT_TYPE_BOOLEAN, |
219 | 'refresh' => SMOPT_REFRESH_FOLDERLIST |
220 | ); |
be2d5495 |
221 | |
222 | /*** Load the General Options into the array ***/ |
223 | $optgrps[SMOPT_GRP_FOLDERSELECT] = _("Folder Selection Options"); |
224 | $optvals[SMOPT_GRP_FOLDERSELECT] = array(); |
225 | |
ebbf2fd0 |
226 | $delim = sqimap_get_delimiter($imapConnection); |
be2d5495 |
227 | $optvals[SMOPT_GRP_FOLDERSELECT][] = array( |
228 | 'name' => 'mailbox_select_style', |
229 | 'caption' => _("Selection List Style"), |
230 | 'type' => SMOPT_TYPE_STRLIST, |
231 | 'refresh' => SMOPT_REFRESH_NONE, |
0e1a248b |
232 | 'posvals' => array( 0 => _("Long:") . ' "' . _("Folder") . $delim . _("Subfolder") . '"', |
233 | 1 => _("Indented:") . ' " ' . _("Subfolder") . '"', |
234 | 2 => _("Delimited:") . ' ". ' . _("Subfolder") . '"'), |
300a044d |
235 | 'htmlencoded' => true |
be2d5495 |
236 | ); |
237 | |
cbe5423b |
238 | /* Assemble all this together and return it as our result. */ |
239 | $result = array( |
240 | 'grps' => $optgrps, |
241 | 'vals' => $optvals |
242 | ); |
ebbf2fd0 |
243 | sqimap_logout($imapConnection); |
cbe5423b |
244 | return ($result); |
245 | } |
246 | |
247 | /******************************************************************/ |
248 | /** Define any specialized save functions for this option page. ***/ |
249 | /******************************************************************/ |
48af4b64 |
250 | |
251 | /** |
252 | * Saves the trash folder option. |
253 | */ |
cbe5423b |
254 | function save_option_trash_folder($option) { |
255 | global $data_dir, $username; |
256 | |
257 | /* Set move to trash on or off. */ |
258 | $trash_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON); |
259 | setPref($data_dir, $username, 'move_to_trash', $trash_on); |
a440e68f |
260 | |
cbe5423b |
261 | /* Now just save the option as normal. */ |
262 | save_option($option); |
263 | } |
2016e645 |
264 | |
48af4b64 |
265 | /** |
266 | * Saves the sent folder option. |
267 | */ |
cbe5423b |
268 | function save_option_sent_folder($option) { |
269 | global $data_dir, $username; |
e7db48af |
270 | |
cbe5423b |
271 | /* Set move to sent on or off. */ |
272 | $sent_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON); |
273 | setPref($data_dir, $username, 'move_to_sent', $sent_on); |
e7db48af |
274 | |
cbe5423b |
275 | /* Now just save the option as normal. */ |
276 | save_option($option); |
277 | } |
e7db48af |
278 | |
48af4b64 |
279 | /** |
280 | * Saves the draft folder option. |
281 | */ |
cbe5423b |
282 | function save_option_draft_folder($option) { |
283 | global $data_dir, $username; |
284 | |
285 | /* Set move to draft on or off. */ |
286 | $draft_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON); |
287 | setPref($data_dir, $username, 'save_as_draft', $draft_on); |
288 | |
289 | /* Now just save the option as normal. */ |
290 | save_option($option); |
291 | } |
292 | |
0e1a248b |
293 | ?> |