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