38f5bd130b72e70d632c3f17955651884f4aa972
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Displays all options relating to folders
14 /* SquirrelMail required files. */
15 require_once(SM_PATH
. 'functions/imap.php');
16 require_once(SM_PATH
. 'functions/imap_general.php');
18 /* Define the group constants for the folder options page. */
19 define('SMOPT_GRP_SPCFOLDER', 0);
20 define('SMOPT_GRP_FOLDERLIST', 1);
21 define('SMOPT_GRP_FOLDERSELECT', 2);
23 /* Define the optpage load function for the folder options page. */
24 function load_optpage_data_folder() {
25 global $username, $key, $imapServerAddress, $imapPort;
26 global $folder_prefix, $default_folder_prefix, $show_prefix_option;
28 /* Get some imap data we need later. */
30 sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
31 $boxes = sqimap_mailbox_list($imapConnection);
33 /* Build a simple array into which we will build options. */
37 /******************************************************/
38 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
39 /******************************************************/
41 /*** Load the General Options into the array ***/
42 $optgrps[SMOPT_GRP_SPCFOLDER
] = _("Special Folder Options");
43 $optvals[SMOPT_GRP_SPCFOLDER
] = array();
45 if (!isset($folder_prefix)) { $folder_prefix = $default_folder_prefix; }
46 if ($show_prefix_option) {
47 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
48 'name' => 'folder_prefix',
49 'caption' => _("Folder Path"),
50 'type' => SMOPT_TYPE_STRING
,
51 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
52 'size' => SMOPT_SIZE_LARGE
56 $trash_folder_values = array(SMPREF_NONE
=> '[ '._("Do not use Trash").' ]',
57 'whatever' => $boxes);
58 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
59 'name' => 'trash_folder',
60 'caption' => _("Trash Folder"),
61 'type' => SMOPT_TYPE_FLDRLIST
,
62 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
63 'posvals' => $trash_folder_values,
64 'save' => 'save_option_trash_folder'
67 $sent_folder_values = array(SMPREF_NONE
=> '[ '._("Do not use Sent").' ]',
68 'whatever' => $boxes);
69 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
70 'name' => 'sent_folder',
71 'caption' => _("Sent Folder"),
72 'type' => SMOPT_TYPE_FLDRLIST
,
73 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
74 'posvals' => $sent_folder_values,
75 'save' => 'save_option_sent_folder'
78 $draft_folder_values = array(SMPREF_NONE
=> '[ '._("Do not use Drafts").' ]',
79 'whatever' => $boxes);
80 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
81 'name' => 'draft_folder',
82 'caption' => _("Draft Folder"),
83 'type' => SMOPT_TYPE_FLDRLIST
,
84 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
85 'posvals' => $draft_folder_values,
86 'save' => 'save_option_draft_folder'
89 /*** Load the General Options into the array ***/
90 $optgrps[SMOPT_GRP_FOLDERLIST
] = _("Folder List Options");
91 $optvals[SMOPT_GRP_FOLDERLIST
] = array();
93 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
94 'name' => 'location_of_bar',
95 'caption' => _("Location of Folder List"),
96 'type' => SMOPT_TYPE_STRLIST
,
97 'refresh' => SMOPT_REFRESH_ALL
,
98 'posvals' => array(SMPREF_LOC_LEFT
=> _("Left"),
99 SMPREF_LOC_RIGHT
=> _("Right"))
102 $left_size_values = array();
103 for ($lsv = 100; $lsv <= 300; $lsv +
= 10) {
104 $left_size_values[$lsv] = "$lsv " . _("pixels");
106 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
107 'name' => 'left_size',
108 'caption' => _("Width of Folder List"),
109 'type' => SMOPT_TYPE_STRLIST
,
110 'refresh' => SMOPT_REFRESH_ALL
,
111 'posvals' => $left_size_values
114 $minute_str = _("Minutes");
115 $left_refresh_values = array(SMPREF_NONE
=> _("Never"));
116 foreach (array(30,60,120,180,300,600) as $lr_val) {
118 $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds");
119 } else if ($lr_val == 60) {
120 $left_refresh_values[$lr_val] = "1 " . _("Minute");
122 $left_refresh_values[$lr_val] = ($lr_val/60) . " $minute_str";
125 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
126 'name' => 'left_refresh',
127 'caption' => _("Auto Refresh Folder List"),
128 'type' => SMOPT_TYPE_STRLIST
,
129 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
130 'posvals' => $left_refresh_values
133 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
134 'name' => 'unseen_notify',
135 'caption' => _("Enable Unread Message Notification"),
136 'type' => SMOPT_TYPE_STRLIST
,
137 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
138 'posvals' => array(SMPREF_UNSEEN_NONE
=> _("No Notification"),
139 SMPREF_UNSEEN_INBOX
=> _("Only INBOX"),
140 SMPREF_UNSEEN_ALL
=> _("All Folders"))
143 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
144 'name' => 'unseen_type',
145 'caption' => _("Unread Message Notification Type"),
146 'type' => SMOPT_TYPE_STRLIST
,
147 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
148 'posvals' => array(SMPREF_UNSEEN_ONLY
=> _("Only Unseen"),
149 SMPREF_UNSEEN_TOTAL
=> _("Unseen and Total"))
152 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
153 'name' => 'collapse_folders',
154 'caption' => _("Enable Collapsable Folders"),
155 'type' => SMOPT_TYPE_BOOLEAN
,
156 'refresh' => SMOPT_REFRESH_FOLDERLIST
159 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
160 'name' => 'unseen_cum',
161 'caption' => _("Enable Cumulative Unread Message Notification"),
162 'type' => SMOPT_TYPE_BOOLEAN
,
163 'refresh' => SMOPT_REFRESH_FOLDERLIST
167 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
168 'name' => 'date_format',
169 'caption' => _("Show Clock on Folders Panel"),
170 'type' => SMOPT_TYPE_STRLIST
,
171 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
172 'posvals' => array( '1' => 'MM/DD/YY HH:MM',
173 '2' => 'DD/MM/YY HH:MM',
177 '6' => _("No Clock")),
180 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
181 'name' => 'hour_format',
182 'caption' => _("Hour Format"),
183 'type' => SMOPT_TYPE_STRLIST
,
184 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
185 'posvals' => array(SMPREF_TIME_12HR
=> _("12-hour clock"),
186 SMPREF_TIME_24HR
=> _("24-hour clock"))
189 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
190 'name' => 'search_memory',
191 'caption' => _("Memory Search"),
192 'type' => SMOPT_TYPE_STRLIST
,
193 'refresh' => SMOPT_REFRESH_NONE
,
194 'posvals' => array( 0 => _("Disabled"),
207 /*** Load the General Options into the array ***/
208 $optgrps[SMOPT_GRP_FOLDERSELECT
] = _("Folder Selection Options");
209 $optvals[SMOPT_GRP_FOLDERSELECT
] = array();
211 $delim = sqimap_get_delimiter($imapConnection);
212 $optvals[SMOPT_GRP_FOLDERSELECT
][] = array(
213 'name' => 'mailbox_select_style',
214 'caption' => _("Selection List Style"),
215 'type' => SMOPT_TYPE_STRLIST
,
216 'refresh' => SMOPT_REFRESH_NONE
,
217 'posvals' => array( 0 => _("Long: ") . '"Folder' . $delim . 'Subfolder"',
218 1 => _("Indented: ") . '" ' . 'Subfolder"',
219 2 => _("Delimited: ") . '". ' . 'Subfolder"')
222 /* Assemble all this together and return it as our result. */
227 sqimap_logout($imapConnection);
231 /******************************************************************/
232 /** Define any specialized save functions for this option page. ***/
233 /******************************************************************/
234 function save_option_trash_folder($option) {
235 global $data_dir, $username;
237 /* Set move to trash on or off. */
238 $trash_on = ($option->new_value
== SMPREF_NONE ? SMPREF_OFF
: SMPREF_ON
);
239 setPref($data_dir, $username, 'move_to_trash', $trash_on);
241 /* Now just save the option as normal. */
242 save_option($option);
245 function save_option_sent_folder($option) {
246 global $data_dir, $username;
248 /* Set move to sent on or off. */
249 $sent_on = ($option->new_value
== SMPREF_NONE ? SMPREF_OFF
: SMPREF_ON
);
250 setPref($data_dir, $username, 'move_to_sent', $sent_on);
252 /* Now just save the option as normal. */
253 save_option($option);
256 function save_option_draft_folder($option) {
257 global $data_dir, $username;
259 /* Set move to draft on or off. */
260 $draft_on = ($option->new_value
== SMPREF_NONE ? SMPREF_OFF
: SMPREF_ON
);
261 setPref($data_dir, $username, 'save_as_draft', $draft_on);
263 /* Now just save the option as normal. */
264 save_option($option);