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