added check for new save replies with original message option
[squirrelmail.git] / include / options / folder.php
CommitLineData
c36ed9cf 1<?php
c36ed9cf 2
35586184 3/**
4 * options_folder.php
5 *
76911253 6 * Copyright (c) 1999-2003 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$
2b646597 12 * @package squirrelmail
35586184 13 */
cbe5423b 14
2b646597 15/** SquirrelMail required files. */
86725763 16require_once(SM_PATH . 'functions/imap.php');
be2d5495 17require_once(SM_PATH . 'functions/imap_general.php');
cbe5423b 18
19/* Define the group constants for the folder options page. */
20define('SMOPT_GRP_SPCFOLDER', 0);
21define('SMOPT_GRP_FOLDERLIST', 1);
be2d5495 22define('SMOPT_GRP_FOLDERSELECT', 2);
cbe5423b 23
48af4b64 24/**
25 * This function builds an array with all the information about
26 * the options available to the user, and returns it. The options
27 * are grouped by the groups in which they are displayed.
28 * For each option, the following information is stored:
29 * - name: the internal (variable) name
30 * - caption: the description of the option in the UI
31 * - type: one of SMOPT_TYPE_*
32 * - refresh: one of SMOPT_REFRESH_*
33 * - size: one of SMOPT_SIZE_*
34 * - save: the name of a function to call when saving this option
35 * @return array all option information
36 */
cbe5423b 37function load_optpage_data_folder() {
38 global $username, $key, $imapServerAddress, $imapPort;
2fad95fa 39 global $folder_prefix, $default_folder_prefix, $show_prefix_option;
cbe5423b 40
41 /* Get some imap data we need later. */
42 $imapConnection =
43 sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
44 $boxes = sqimap_mailbox_list($imapConnection);
bbcafebd 45
b5efadfa 46 /* Build a simple array into which we will build options. */
bbcafebd 47 $optgrps = array();
b5efadfa 48 $optvals = array();
49
bbcafebd 50 /******************************************************/
51 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
52 /******************************************************/
bbcafebd 53
54 /*** Load the General Options into the array ***/
55 $optgrps[SMOPT_GRP_SPCFOLDER] = _("Special Folder Options");
56 $optvals[SMOPT_GRP_SPCFOLDER] = array();
57
cbe5423b 58 if (!isset($folder_prefix)) { $folder_prefix = $default_folder_prefix; }
59 if ($show_prefix_option) {
60 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
61 'name' => 'folder_prefix',
62 'caption' => _("Folder Path"),
63 'type' => SMOPT_TYPE_STRING,
64 'refresh' => SMOPT_REFRESH_FOLDERLIST,
65 'size' => SMOPT_SIZE_LARGE
66 );
67 }
68
be2d5495 69 $trash_folder_values = array(SMPREF_NONE => '[ '._("Do not use Trash").' ]',
70 'whatever' => $boxes);
bbcafebd 71 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
b5efadfa 72 'name' => 'trash_folder',
73 'caption' => _("Trash Folder"),
be2d5495 74 'type' => SMOPT_TYPE_FLDRLIST,
b5efadfa 75 'refresh' => SMOPT_REFRESH_FOLDERLIST,
cbe5423b 76 'posvals' => $trash_folder_values,
77 'save' => 'save_option_trash_folder'
b5efadfa 78 );
79
be2d5495 80 $sent_folder_values = array(SMPREF_NONE => '[ '._("Do not use Sent").' ]',
81 'whatever' => $boxes);
bbcafebd 82 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
b5efadfa 83 'name' => 'sent_folder',
84 'caption' => _("Sent Folder"),
be2d5495 85 'type' => SMOPT_TYPE_FLDRLIST,
b5efadfa 86 'refresh' => SMOPT_REFRESH_FOLDERLIST,
cbe5423b 87 'posvals' => $sent_folder_values,
88 'save' => 'save_option_sent_folder'
b5efadfa 89 );
90
be2d5495 91 $draft_folder_values = array(SMPREF_NONE => '[ '._("Do not use Drafts").' ]',
92 'whatever' => $boxes);
bbcafebd 93 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
b5efadfa 94 'name' => 'draft_folder',
95 'caption' => _("Draft Folder"),
be2d5495 96 'type' => SMOPT_TYPE_FLDRLIST,
b5efadfa 97 'refresh' => SMOPT_REFRESH_FOLDERLIST,
cbe5423b 98 'posvals' => $draft_folder_values,
99 'save' => 'save_option_draft_folder'
b5efadfa 100 );
101
bbcafebd 102 /*** Load the General Options into the array ***/
103 $optgrps[SMOPT_GRP_FOLDERLIST] = _("Folder List Options");
104 $optvals[SMOPT_GRP_FOLDERLIST] = array();
105
106 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 107 'name' => 'location_of_bar',
108 'caption' => _("Location of Folder List"),
109 'type' => SMOPT_TYPE_STRLIST,
110 'refresh' => SMOPT_REFRESH_ALL,
111 'posvals' => array(SMPREF_LOC_LEFT => _("Left"),
112 SMPREF_LOC_RIGHT => _("Right"))
113 );
114
115 $left_size_values = array();
116 for ($lsv = 100; $lsv <= 300; $lsv += 10) {
117 $left_size_values[$lsv] = "$lsv " . _("pixels");
118 }
bbcafebd 119 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 120 'name' => 'left_size',
121 'caption' => _("Width of Folder List"),
122 'type' => SMOPT_TYPE_STRLIST,
123 'refresh' => SMOPT_REFRESH_ALL,
124 'posvals' => $left_size_values
125 );
126
127 $minute_str = _("Minutes");
128 $left_refresh_values = array(SMPREF_NONE => _("Never"));
129 foreach (array(30,60,120,180,300,600) as $lr_val) {
130 if ($lr_val < 60) {
131 $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds");
132 } else if ($lr_val == 60) {
133 $left_refresh_values[$lr_val] = "1 " . _("Minute");
134 } else {
135 $left_refresh_values[$lr_val] = ($lr_val/60) . " $minute_str";
136 }
137 }
bbcafebd 138 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 139 'name' => 'left_refresh',
140 'caption' => _("Auto Refresh Folder List"),
141 'type' => SMOPT_TYPE_STRLIST,
142 'refresh' => SMOPT_REFRESH_FOLDERLIST,
143 'posvals' => $left_refresh_values
144 );
145
bbcafebd 146 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 147 'name' => 'unseen_notify',
10ff0c3d 148 'caption' => _("Enable Unread Message Notification"),
a440e68f 149 'type' => SMOPT_TYPE_STRLIST,
150 'refresh' => SMOPT_REFRESH_FOLDERLIST,
151 'posvals' => array(SMPREF_UNSEEN_NONE => _("No Notification"),
152 SMPREF_UNSEEN_INBOX => _("Only INBOX"),
153 SMPREF_UNSEEN_ALL => _("All Folders"))
154 );
155
bbcafebd 156 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 157 'name' => 'unseen_type',
10ff0c3d 158 'caption' => _("Unread Message Notification Type"),
a440e68f 159 'type' => SMOPT_TYPE_STRLIST,
160 'refresh' => SMOPT_REFRESH_FOLDERLIST,
161 'posvals' => array(SMPREF_UNSEEN_ONLY => _("Only Unseen"),
162 SMPREF_UNSEEN_TOTAL => _("Unseen and Total"))
163 );
164
bbcafebd 165 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 166 'name' => 'collapse_folders',
167 'caption' => _("Enable Collapsable Folders"),
168 'type' => SMOPT_TYPE_BOOLEAN,
169 'refresh' => SMOPT_REFRESH_FOLDERLIST
170 );
171
bbcafebd 172 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
f612a235 173 'name' => 'unseen_cum',
174 'caption' => _("Enable Cumulative Unread Message Notification"),
175 'type' => SMOPT_TYPE_BOOLEAN,
176 'refresh' => SMOPT_REFRESH_FOLDERLIST
177 );
178
179
180 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 181 'name' => 'date_format',
182 'caption' => _("Show Clock on Folders Panel"),
183 'type' => SMOPT_TYPE_STRLIST,
184 'refresh' => SMOPT_REFRESH_FOLDERLIST,
185 'posvals' => array( '1' => 'MM/DD/YY HH:MM',
186 '2' => 'DD/MM/YY HH:MM',
157e9c5e 187 '3' => _("Show weekday and time"),
188 '4' => _("Show time with seconds"),
189 '5' => _("Show time"),
a440e68f 190 '6' => _("No Clock")),
191 );
192
bbcafebd 193 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 194 'name' => 'hour_format',
195 'caption' => _("Hour Format"),
196 'type' => SMOPT_TYPE_STRLIST,
197 'refresh' => SMOPT_REFRESH_FOLDERLIST,
198 'posvals' => array(SMPREF_TIME_12HR => _("12-hour clock"),
199 SMPREF_TIME_24HR => _("24-hour clock"))
200 );
201
0d672ac0 202 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
203 'name' => 'search_memory',
204 'caption' => _("Memory Search"),
205 'type' => SMOPT_TYPE_STRLIST,
90568047 206 'refresh' => SMOPT_REFRESH_NONE,
0d672ac0 207 'posvals' => array( 0 => _("Disabled"),
208 1 => '1',
209 2 => '2',
210 3 => '3',
211 4 => '4',
212 5 => '5',
213 6 => '6',
214 7 => '7',
215 8 => '8',
a2bc1180 216 9 => '9')
217 );
0d672ac0 218
be2d5495 219
220 /*** Load the General Options into the array ***/
221 $optgrps[SMOPT_GRP_FOLDERSELECT] = _("Folder Selection Options");
222 $optvals[SMOPT_GRP_FOLDERSELECT] = array();
223
ebbf2fd0 224 $delim = sqimap_get_delimiter($imapConnection);
be2d5495 225 $optvals[SMOPT_GRP_FOLDERSELECT][] = array(
226 'name' => 'mailbox_select_style',
227 'caption' => _("Selection List Style"),
228 'type' => SMOPT_TYPE_STRLIST,
229 'refresh' => SMOPT_REFRESH_NONE,
28df812d 230 'posvals' => array( 0 => _("Long: ") . '"' . _("Folder") . $delim . _("Subfolder") . '"',
231 1 => _("Indented: ") . '"&nbsp;&nbsp;&nbsp;&nbsp;' . _("Subfolder") . '"',
232 2 => _("Delimited: ") . '".&nbsp;' . _("Subfolder") . '"')
be2d5495 233 );
234
cbe5423b 235 /* Assemble all this together and return it as our result. */
236 $result = array(
237 'grps' => $optgrps,
238 'vals' => $optvals
239 );
ebbf2fd0 240 sqimap_logout($imapConnection);
cbe5423b 241 return ($result);
242}
243
244/******************************************************************/
245/** Define any specialized save functions for this option page. ***/
246/******************************************************************/
48af4b64 247
248/**
249 * Saves the trash folder option.
250 */
cbe5423b 251function save_option_trash_folder($option) {
252 global $data_dir, $username;
253
254 /* Set move to trash on or off. */
255 $trash_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
256 setPref($data_dir, $username, 'move_to_trash', $trash_on);
a440e68f 257
cbe5423b 258 /* Now just save the option as normal. */
259 save_option($option);
260}
2016e645 261
48af4b64 262/**
263 * Saves the sent folder option.
264 */
cbe5423b 265function save_option_sent_folder($option) {
266 global $data_dir, $username;
e7db48af 267
cbe5423b 268 /* Set move to sent on or off. */
269 $sent_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
270 setPref($data_dir, $username, 'move_to_sent', $sent_on);
e7db48af 271
cbe5423b 272 /* Now just save the option as normal. */
273 save_option($option);
274}
e7db48af 275
48af4b64 276/**
277 * Saves the draft folder option.
278 */
cbe5423b 279function save_option_draft_folder($option) {
280 global $data_dir, $username;
281
282 /* Set move to draft on or off. */
283 $draft_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
284 setPref($data_dir, $username, 'save_as_draft', $draft_on);
285
286 /* Now just save the option as normal. */
287 save_option($option);
288}
289
290?>