Changed default value for SpamFilters_YourHop
[squirrelmail.git] / src / options_folder.php
CommitLineData
c36ed9cf 1<?php
c36ed9cf 2
895905c0 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 **/
cbe5423b 13
14require_once('../functions/imap.php');
15
16/* Define the group constants for the folder options page. */
17define('SMOPT_GRP_SPCFOLDER', 0);
18define('SMOPT_GRP_FOLDERLIST', 1);
19
20/* Define the optpage load function for the folder options page. */
21function load_optpage_data_folder() {
22 global $username, $key, $imapServerAddress, $imapPort;
23 global $folder_prefix, $default_folder_prefix;
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);
bbcafebd 30
b5efadfa 31 /* Build a simple array into which we will build options. */
bbcafebd 32 $optgrps = array();
b5efadfa 33 $optvals = array();
34
bbcafebd 35 /******************************************************/
36 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
37 /******************************************************/
bbcafebd 38
39 /*** Load the General Options into the array ***/
40 $optgrps[SMOPT_GRP_SPCFOLDER] = _("Special Folder Options");
41 $optvals[SMOPT_GRP_SPCFOLDER] = array();
42
cbe5423b 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
b5efadfa 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);
bbcafebd 65 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
b5efadfa 66 'name' => 'trash_folder',
67 'caption' => _("Trash Folder"),
68 'type' => SMOPT_TYPE_STRLIST,
69 'refresh' => SMOPT_REFRESH_FOLDERLIST,
cbe5423b 70 'posvals' => $trash_folder_values,
71 'save' => 'save_option_trash_folder'
b5efadfa 72 );
73
74 $sent_none = array(SMPREF_NONE => _("Do not use Sent"));
75 $sent_folder_values = array_merge($sent_none, $special_folder_values);
bbcafebd 76 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
b5efadfa 77 'name' => 'sent_folder',
78 'caption' => _("Sent Folder"),
79 'type' => SMOPT_TYPE_STRLIST,
80 'refresh' => SMOPT_REFRESH_FOLDERLIST,
cbe5423b 81 'posvals' => $sent_folder_values,
82 'save' => 'save_option_sent_folder'
b5efadfa 83 );
84
89dbabc2 85 $draft_none = array(SMPREF_NONE => _("Do not use Drafts"));
b5efadfa 86 $draft_folder_values = array_merge($draft_none, $special_folder_values);
bbcafebd 87 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
b5efadfa 88 'name' => 'draft_folder',
89 'caption' => _("Draft Folder"),
90 'type' => SMOPT_TYPE_STRLIST,
91 'refresh' => SMOPT_REFRESH_FOLDERLIST,
cbe5423b 92 'posvals' => $draft_folder_values,
93 'save' => 'save_option_draft_folder'
b5efadfa 94 );
95
bbcafebd 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(
a440e68f 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 }
bbcafebd 113 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 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 }
bbcafebd 132 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 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
bbcafebd 140 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 141 'name' => 'unseen_notify',
142 'caption' => _("Enable Unseen 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
bbcafebd 150 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 151 'name' => 'unseen_type',
152 'caption' => _("Unseen 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
bbcafebd 159 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 160 'name' => 'collapse_folders',
161 'caption' => _("Enable Collapsable Folders"),
162 'type' => SMOPT_TYPE_BOOLEAN,
163 'refresh' => SMOPT_REFRESH_FOLDERLIST
164 );
165
bbcafebd 166 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 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
bbcafebd 179 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 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
cbe5423b 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/******************************************************************/
199function 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);
a440e68f 205
cbe5423b 206 /* Now just save the option as normal. */
207 save_option($option);
208}
2016e645 209
cbe5423b 210function save_option_sent_folder($option) {
211 global $data_dir, $username;
e7db48af 212
cbe5423b 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);
e7db48af 216
cbe5423b 217 /* Now just save the option as normal. */
218 save_option($option);
219}
e7db48af 220
cbe5423b 221function 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?>