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