#612148: Enable TZ in safe_mode if safe_mode_allowed_env_vars permits this bug
[squirrelmail.git] / include / options / folder.php
CommitLineData
c36ed9cf 1<?php
c36ed9cf 2
35586184 3/**
4 * options_folder.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
35586184 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
86725763 14/* SquirrelMail required files. */
15require_once(SM_PATH . 'functions/imap.php');
cbe5423b 16
17/* Define the group constants for the folder options page. */
18define('SMOPT_GRP_SPCFOLDER', 0);
19define('SMOPT_GRP_FOLDERLIST', 1);
20
21/* Define the optpage load function for the folder options page. */
22function load_optpage_data_folder() {
23 global $username, $key, $imapServerAddress, $imapPort;
2fad95fa 24 global $folder_prefix, $default_folder_prefix, $show_prefix_option;
cbe5423b 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);
bbcafebd 31
b5efadfa 32 /* Build a simple array into which we will build options. */
bbcafebd 33 $optgrps = array();
b5efadfa 34 $optvals = array();
35
bbcafebd 36 /******************************************************/
37 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
38 /******************************************************/
bbcafebd 39
40 /*** Load the General Options into the array ***/
41 $optgrps[SMOPT_GRP_SPCFOLDER] = _("Special Folder Options");
42 $optvals[SMOPT_GRP_SPCFOLDER] = array();
43
cbe5423b 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
b5efadfa 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);
bbcafebd 66 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
b5efadfa 67 'name' => 'trash_folder',
68 'caption' => _("Trash Folder"),
69 'type' => SMOPT_TYPE_STRLIST,
70 'refresh' => SMOPT_REFRESH_FOLDERLIST,
cbe5423b 71 'posvals' => $trash_folder_values,
72 'save' => 'save_option_trash_folder'
b5efadfa 73 );
74
75 $sent_none = array(SMPREF_NONE => _("Do not use Sent"));
76 $sent_folder_values = array_merge($sent_none, $special_folder_values);
bbcafebd 77 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
b5efadfa 78 'name' => 'sent_folder',
79 'caption' => _("Sent Folder"),
80 'type' => SMOPT_TYPE_STRLIST,
81 'refresh' => SMOPT_REFRESH_FOLDERLIST,
cbe5423b 82 'posvals' => $sent_folder_values,
83 'save' => 'save_option_sent_folder'
b5efadfa 84 );
85
89dbabc2 86 $draft_none = array(SMPREF_NONE => _("Do not use Drafts"));
b5efadfa 87 $draft_folder_values = array_merge($draft_none, $special_folder_values);
bbcafebd 88 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
b5efadfa 89 'name' => 'draft_folder',
90 'caption' => _("Draft Folder"),
91 'type' => SMOPT_TYPE_STRLIST,
92 'refresh' => SMOPT_REFRESH_FOLDERLIST,
cbe5423b 93 'posvals' => $draft_folder_values,
94 'save' => 'save_option_draft_folder'
b5efadfa 95 );
96
bbcafebd 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(
a440e68f 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 }
bbcafebd 114 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 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 }
bbcafebd 133 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 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
bbcafebd 141 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 142 'name' => 'unseen_notify',
10ff0c3d 143 'caption' => _("Enable Unread Message Notification"),
a440e68f 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
bbcafebd 151 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 152 'name' => 'unseen_type',
10ff0c3d 153 'caption' => _("Unread Message Notification Type"),
a440e68f 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
bbcafebd 160 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 161 'name' => 'collapse_folders',
162 'caption' => _("Enable Collapsable Folders"),
163 'type' => SMOPT_TYPE_BOOLEAN,
164 'refresh' => SMOPT_REFRESH_FOLDERLIST
165 );
166
bbcafebd 167 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
f612a235 168 'name' => 'unseen_cum',
169 'caption' => _("Enable Cumulative Unread Message Notification"),
170 'type' => SMOPT_TYPE_BOOLEAN,
171 'refresh' => SMOPT_REFRESH_FOLDERLIST
172 );
173
174
175 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 176 'name' => 'date_format',
177 'caption' => _("Show Clock on Folders Panel"),
178 'type' => SMOPT_TYPE_STRLIST,
179 'refresh' => SMOPT_REFRESH_FOLDERLIST,
180 'posvals' => array( '1' => 'MM/DD/YY HH:MM',
181 '2' => 'DD/MM/YY HH:MM',
182 '3' => 'DDD, HH:MM',
183 '4' => 'HH:MM:SS',
184 '5' => 'HH:MM',
185 '6' => _("No Clock")),
186 );
187
bbcafebd 188 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 189 'name' => 'hour_format',
190 'caption' => _("Hour Format"),
191 'type' => SMOPT_TYPE_STRLIST,
192 'refresh' => SMOPT_REFRESH_FOLDERLIST,
193 'posvals' => array(SMPREF_TIME_12HR => _("12-hour clock"),
194 SMPREF_TIME_24HR => _("24-hour clock"))
195 );
196
0d672ac0 197 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
198 'name' => 'search_memory',
199 'caption' => _("Memory Search"),
200 'type' => SMOPT_TYPE_STRLIST,
90568047 201 'refresh' => SMOPT_REFRESH_NONE,
0d672ac0 202 'posvals' => array( 0 => _("Disabled"),
203 1 => '1',
204 2 => '2',
205 3 => '3',
206 4 => '4',
207 5 => '5',
208 6 => '6',
209 7 => '7',
210 8 => '8',
a2bc1180 211 9 => '9')
212 );
0d672ac0 213
cbe5423b 214 /* Assemble all this together and return it as our result. */
215 $result = array(
216 'grps' => $optgrps,
217 'vals' => $optvals
218 );
219 return ($result);
220}
221
222/******************************************************************/
223/** Define any specialized save functions for this option page. ***/
224/******************************************************************/
225function save_option_trash_folder($option) {
226 global $data_dir, $username;
227
228 /* Set move to trash on or off. */
229 $trash_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
230 setPref($data_dir, $username, 'move_to_trash', $trash_on);
a440e68f 231
cbe5423b 232 /* Now just save the option as normal. */
233 save_option($option);
234}
2016e645 235
cbe5423b 236function save_option_sent_folder($option) {
237 global $data_dir, $username;
e7db48af 238
cbe5423b 239 /* Set move to sent on or off. */
240 $sent_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
241 setPref($data_dir, $username, 'move_to_sent', $sent_on);
e7db48af 242
cbe5423b 243 /* Now just save the option as normal. */
244 save_option($option);
245}
e7db48af 246
cbe5423b 247function save_option_draft_folder($option) {
248 global $data_dir, $username;
249
250 /* Set move to draft on or off. */
251 $draft_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
252 setPref($data_dir, $username, 'save_as_draft', $draft_on);
253
254 /* Now just save the option as normal. */
255 save_option($option);
256}
257
258?>