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