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