099868cb893be346f4eefae4c4143804992fef6a
[squirrelmail.git] / src / options_folder.php
1 <?php
2
3 /**
4 * options_folder.php
5 *
6 * Copyright (c) 1999-2001 The SquirrelMail Development 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 */
13
14 require_once('../functions/imap.php');
15
16 /* Define the group constants for the folder options page. */
17 define('SMOPT_GRP_SPCFOLDER', 0);
18 define('SMOPT_GRP_FOLDERLIST', 1);
19
20 /* Define the optpage load function for the folder options page. */
21 function load_optpage_data_folder() {
22 global $username, $key, $imapServerAddress, $imapPort;
23 global $folder_prefix, $default_folder_prefix, $show_prefix_option;
24
25 /* Get some imap data we need later. */
26 $imapConnection =
27 sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
28 $boxes = sqimap_mailbox_list($imapConnection);
29 sqimap_logout($imapConnection);
30
31 /* Build a simple array into which we will build options. */
32 $optgrps = array();
33 $optvals = array();
34
35 /******************************************************/
36 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
37 /******************************************************/
38
39 /*** Load the General Options into the array ***/
40 $optgrps[SMOPT_GRP_SPCFOLDER] = _("Special Folder Options");
41 $optvals[SMOPT_GRP_SPCFOLDER] = array();
42
43 if (!isset($folder_prefix)) { $folder_prefix = $default_folder_prefix; }
44 if ($show_prefix_option) {
45 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
46 'name' => 'folder_prefix',
47 'caption' => _("Folder Path"),
48 'type' => SMOPT_TYPE_STRING,
49 'refresh' => SMOPT_REFRESH_FOLDERLIST,
50 'size' => SMOPT_SIZE_LARGE
51 );
52 }
53
54 $special_folder_values = array();
55 foreach ($boxes as $folder) {
56 if (strtolower($folder['unformatted']) != 'inbox') {
57 $real_value = $folder['unformatted-dm'];
58 $disp_value = str_replace(' ', '&nbsp;', $folder['formatted']);
59 $special_folder_values[$real_value] = $disp_value;
60 }
61 }
62
63 $trash_none = array(SMPREF_NONE => _("Do not use Trash"));
64 $trash_folder_values = array_merge($trash_none, $special_folder_values);
65 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
66 'name' => 'trash_folder',
67 'caption' => _("Trash Folder"),
68 'type' => SMOPT_TYPE_STRLIST,
69 'refresh' => SMOPT_REFRESH_FOLDERLIST,
70 'posvals' => $trash_folder_values,
71 'save' => 'save_option_trash_folder'
72 );
73
74 $sent_none = array(SMPREF_NONE => _("Do not use Sent"));
75 $sent_folder_values = array_merge($sent_none, $special_folder_values);
76 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
77 'name' => 'sent_folder',
78 'caption' => _("Sent Folder"),
79 'type' => SMOPT_TYPE_STRLIST,
80 'refresh' => SMOPT_REFRESH_FOLDERLIST,
81 'posvals' => $sent_folder_values,
82 'save' => 'save_option_sent_folder'
83 );
84
85 $draft_none = array(SMPREF_NONE => _("Do not use Drafts"));
86 $draft_folder_values = array_merge($draft_none, $special_folder_values);
87 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
88 'name' => 'draft_folder',
89 'caption' => _("Draft Folder"),
90 'type' => SMOPT_TYPE_STRLIST,
91 'refresh' => SMOPT_REFRESH_FOLDERLIST,
92 'posvals' => $draft_folder_values,
93 'save' => 'save_option_draft_folder'
94 );
95
96 /*** Load the General Options into the array ***/
97 $optgrps[SMOPT_GRP_FOLDERLIST] = _("Folder List Options");
98 $optvals[SMOPT_GRP_FOLDERLIST] = array();
99
100 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
101 'name' => 'location_of_bar',
102 'caption' => _("Location of Folder List"),
103 'type' => SMOPT_TYPE_STRLIST,
104 'refresh' => SMOPT_REFRESH_ALL,
105 'posvals' => array(SMPREF_LOC_LEFT => _("Left"),
106 SMPREF_LOC_RIGHT => _("Right"))
107 );
108
109 $left_size_values = array();
110 for ($lsv = 100; $lsv <= 300; $lsv += 10) {
111 $left_size_values[$lsv] = "$lsv " . _("pixels");
112 }
113 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
114 'name' => 'left_size',
115 'caption' => _("Width of Folder List"),
116 'type' => SMOPT_TYPE_STRLIST,
117 'refresh' => SMOPT_REFRESH_ALL,
118 'posvals' => $left_size_values
119 );
120
121 $minute_str = _("Minutes");
122 $left_refresh_values = array(SMPREF_NONE => _("Never"));
123 foreach (array(30,60,120,180,300,600) as $lr_val) {
124 if ($lr_val < 60) {
125 $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds");
126 } else if ($lr_val == 60) {
127 $left_refresh_values[$lr_val] = "1 " . _("Minute");
128 } else {
129 $left_refresh_values[$lr_val] = ($lr_val/60) . " $minute_str";
130 }
131 }
132 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
133 'name' => 'left_refresh',
134 'caption' => _("Auto Refresh Folder List"),
135 'type' => SMOPT_TYPE_STRLIST,
136 'refresh' => SMOPT_REFRESH_FOLDERLIST,
137 'posvals' => $left_refresh_values
138 );
139
140 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
141 'name' => 'unseen_notify',
142 'caption' => _("Enable Unread Message Notification"),
143 'type' => SMOPT_TYPE_STRLIST,
144 'refresh' => SMOPT_REFRESH_FOLDERLIST,
145 'posvals' => array(SMPREF_UNSEEN_NONE => _("No Notification"),
146 SMPREF_UNSEEN_INBOX => _("Only INBOX"),
147 SMPREF_UNSEEN_ALL => _("All Folders"))
148 );
149
150 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
151 'name' => 'unseen_type',
152 'caption' => _("Unread Message Notification Type"),
153 'type' => SMOPT_TYPE_STRLIST,
154 'refresh' => SMOPT_REFRESH_FOLDERLIST,
155 'posvals' => array(SMPREF_UNSEEN_ONLY => _("Only Unseen"),
156 SMPREF_UNSEEN_TOTAL => _("Unseen and Total"))
157 );
158
159 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
160 'name' => 'collapse_folders',
161 'caption' => _("Enable Collapsable Folders"),
162 'type' => SMOPT_TYPE_BOOLEAN,
163 'refresh' => SMOPT_REFRESH_FOLDERLIST
164 );
165
166 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
167 'name' => 'date_format',
168 'caption' => _("Show Clock on Folders Panel"),
169 'type' => SMOPT_TYPE_STRLIST,
170 'refresh' => SMOPT_REFRESH_FOLDERLIST,
171 'posvals' => array( '1' => 'MM/DD/YY HH:MM',
172 '2' => 'DD/MM/YY HH:MM',
173 '3' => 'DDD, HH:MM',
174 '4' => 'HH:MM:SS',
175 '5' => 'HH:MM',
176 '6' => _("No Clock")),
177 );
178
179 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
180 'name' => 'hour_format',
181 'caption' => _("Hour Format"),
182 'type' => SMOPT_TYPE_STRLIST,
183 'refresh' => SMOPT_REFRESH_FOLDERLIST,
184 'posvals' => array(SMPREF_TIME_12HR => _("12-hour clock"),
185 SMPREF_TIME_24HR => _("24-hour clock"))
186 );
187
188 /* Assemble all this together and return it as our result. */
189 $result = array(
190 'grps' => $optgrps,
191 'vals' => $optvals
192 );
193 return ($result);
194 }
195
196 /******************************************************************/
197 /** Define any specialized save functions for this option page. ***/
198 /******************************************************************/
199 function save_option_trash_folder($option) {
200 global $data_dir, $username;
201
202 /* Set move to trash on or off. */
203 $trash_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
204 setPref($data_dir, $username, 'move_to_trash', $trash_on);
205
206 /* Now just save the option as normal. */
207 save_option($option);
208 }
209
210 function save_option_sent_folder($option) {
211 global $data_dir, $username;
212
213 /* Set move to sent on or off. */
214 $sent_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
215 setPref($data_dir, $username, 'move_to_sent', $sent_on);
216
217 /* Now just save the option as normal. */
218 save_option($option);
219 }
220
221 function save_option_draft_folder($option) {
222 global $data_dir, $username;
223
224 /* Set move to draft on or off. */
225 $draft_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
226 setPref($data_dir, $username, 'save_as_draft', $draft_on);
227
228 /* Now just save the option as normal. */
229 save_option($option);
230 }
231
232 ?>