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