6 * Displays all options relating to folders
8 * @copyright 1999-2017 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @package squirrelmail
14 /** SquirrelMail required files. */
15 include(SM_PATH
. 'functions/imap_general.php');
17 /* Define the group constants for the folder options page. */
18 define('SMOPT_GRP_SPCFOLDER', 0);
19 define('SMOPT_GRP_FOLDERLIST', 1);
20 define('SMOPT_GRP_FOLDERSELECT', 2);
23 * This function builds an array with all the information about
24 * the options available to the user, and returns it. The options
25 * are grouped by the groups in which they are displayed.
26 * For each option, the following information is stored:
27 * - name: the internal (variable) name
28 * - caption: the description of the option in the UI
29 * - type: one of SMOPT_TYPE_*
30 * - refresh: one of SMOPT_REFRESH_*
31 * - size: one of SMOPT_SIZE_*
32 * - save: the name of a function to call when saving this option
33 * @return array all option information
35 function load_optpage_data_folder() {
36 global $username, $imapServerAddress, $imapPort, $imap_stream_options,
37 $oTemplate, $nbsp, $folder_prefix, $default_folder_prefix,
40 /* Get some imap data we need later. */
41 $imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options);
42 $boxes = sqimap_mailbox_list($imapConnection);
44 /* Build a simple array into which we will build options. */
48 /******************************************************/
49 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
50 /******************************************************/
52 /*** Load the General Options into the array ***/
53 $optgrps[SMOPT_GRP_SPCFOLDER
] = _("Special Folder Options");
54 $optvals[SMOPT_GRP_SPCFOLDER
] = array();
56 if (!isset($folder_prefix)) { $folder_prefix = $default_folder_prefix; }
57 if ($show_prefix_option) {
58 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
59 'name' => 'folder_prefix',
60 'caption' => _("Folder Path"),
61 'type' => SMOPT_TYPE_STRING
,
62 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
63 'size' => SMOPT_SIZE_LARGE
67 $trash_folder_values = array(SMPREF_NONE
=> '[ '._("Do not use Trash").' ]',
69 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
70 'name' => 'trash_folder',
71 'caption' => _("Trash Folder"),
72 'type' => SMOPT_TYPE_FLDRLIST
,
73 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
74 'posvals' => $trash_folder_values,
75 'save' => 'save_option_trash_folder'
78 $draft_folder_values = array(SMPREF_NONE
=> '[ '._("Do not use Drafts").' ]',
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 $sent_folder_values = array(SMPREF_NONE
=> '[ '._("Do not use Sent").' ]',
91 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
92 'name' => 'sent_folder',
93 'caption' => _("Sent Folder"),
94 'type' => SMOPT_TYPE_FLDRLIST
,
95 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
96 'posvals' => $sent_folder_values,
97 'save' => 'save_option_sent_folder'
100 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
101 'name' => 'translate_special_folders',
102 'caption' => _("Translate Special Folders"),
103 'type' => SMOPT_TYPE_BOOLEAN
,
104 'refresh' => SMOPT_REFRESH_FOLDERLIST
107 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
108 'name' => 'save_reply_with_orig',
109 'caption' => _("Save Replies with Original Message"),
110 'type' => SMOPT_TYPE_BOOLEAN
,
111 'refresh' => SMOPT_REFRESH_FOLDERLIST
114 /*** Load the General Options into the array ***/
115 $optgrps[SMOPT_GRP_FOLDERLIST
] = _("Folder List Options");
116 $optvals[SMOPT_GRP_FOLDERLIST
] = array();
118 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
119 'name' => 'location_of_bar',
120 'caption' => _("Location of Folder List"),
121 'type' => SMOPT_TYPE_STRLIST
,
122 'refresh' => SMOPT_REFRESH_ALL
,
123 'posvals' => array(SMPREF_LOC_LEFT
=> _("Left"),
124 SMPREF_LOC_RIGHT
=> _("Right"))
127 $left_size_values = array();
128 for ($lsv = 100; $lsv <= 300; $lsv +
= 10) {
129 $left_size_values[$lsv] = "$lsv " . _("pixels");
131 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
132 'name' => 'left_size',
133 'caption' => _("Width of Folder List"),
134 'type' => SMOPT_TYPE_STRLIST
,
135 'refresh' => SMOPT_REFRESH_ALL
,
136 'posvals' => $left_size_values
139 $left_refresh_values = array(SMPREF_NONE
=> _("Never"));
140 foreach (array(30,60,120,180,300,600,1200) as $lr_val) {
142 $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds");
144 $left_refresh_values[$lr_val] = sprintf(ngettext("%d Minute","%d Minutes",($lr_val/60)),($lr_val/60));
147 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
148 'name' => 'left_refresh',
149 'caption' => _("Auto Refresh Folder List"),
150 'type' => SMOPT_TYPE_STRLIST
,
151 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
152 'posvals' => $left_refresh_values
155 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
156 'name' => 'unseen_notify',
157 'caption' => _("Enable Unread Message Notification"),
158 'type' => SMOPT_TYPE_STRLIST
,
159 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
160 'posvals' => array(SMPREF_UNSEEN_NONE
=> _("No Notification"),
161 SMPREF_UNSEEN_INBOX
=> _("Only INBOX"),
162 SMPREF_UNSEEN_ALL
=> _("All Folders"))
165 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
166 'name' => 'unseen_type',
167 'caption' => _("Unread Message Notification Type"),
168 'type' => SMOPT_TYPE_STRLIST
,
169 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
170 'posvals' => array(SMPREF_UNSEEN_ONLY
=> _("Only Unseen"),
171 SMPREF_UNSEEN_TOTAL
=> _("Unseen and Total"))
174 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
175 'name' => 'collapse_folders',
176 'caption' => _("Enable Collapsable Folders"),
177 'type' => SMOPT_TYPE_BOOLEAN
,
178 'refresh' => SMOPT_REFRESH_FOLDERLIST
181 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
182 'name' => 'unseen_cum',
183 'caption' => _("Enable Cumulative Unread Message Notification"),
184 'type' => SMOPT_TYPE_BOOLEAN
,
185 'refresh' => SMOPT_REFRESH_FOLDERLIST
189 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
190 'name' => 'date_format',
191 'caption' => _("Show Clock on Folders Panel"),
192 'type' => SMOPT_TYPE_STRLIST
,
193 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
194 'posvals' => array( '0' => _("International date and time"),
195 '1' => _("American date and time"),
196 '2' => _("European date and time"),
197 '3' => _("Show weekday and time"),
198 '4' => _("Show time with seconds"),
199 '5' => _("Show time"),
200 '6' => _("No Clock")),
203 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
204 'name' => 'search_memory',
205 'caption' => _("Memory Search"),
206 'type' => SMOPT_TYPE_STRLIST
,
207 'refresh' => SMOPT_REFRESH_NONE
,
208 'posvals' => array( 0 => _("Disabled"),
220 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
221 'name' => 'show_only_subscribed_folders',
222 'caption' => _("Show only subscribed folders"),
223 'type' => SMOPT_TYPE_BOOLEAN
,
224 'refresh' => SMOPT_REFRESH_FOLDERLIST
227 /*** Load the General Options into the array ***/
228 $optgrps[SMOPT_GRP_FOLDERSELECT
] = _("Folder Selection Options");
229 $optvals[SMOPT_GRP_FOLDERSELECT
] = array();
231 $delim = sqimap_get_delimiter($imapConnection);
232 $optvals[SMOPT_GRP_FOLDERSELECT
][] = array(
233 'name' => 'mailbox_select_style',
234 'caption' => _("Selection List Style"),
235 'type' => SMOPT_TYPE_STRLIST
,
236 'refresh' => SMOPT_REFRESH_NONE
,
238 SMPREF_MAILBOX_SELECT_LONG
=>
239 _("Long:") . ' "' . _("Folder") . $delim . _("Subfolder") . '"',
240 SMPREF_MAILBOX_SELECT_INDENTED
=>
241 _("Indented:") . " \"$nbsp$nbsp$nbsp$nbsp" . _("Subfolder") . '"',
242 SMPREF_MAILBOX_SELECT_DELIMITED
=>
243 _("Delimited:") . " \".$nbsp" . _("Subfolder") . '"'),
244 'htmlencoded' => true
247 /* Assemble all this together and return it as our result. */
252 sqimap_logout($imapConnection);
256 /******************************************************************/
257 /** Define any specialized save functions for this option page. ***/
258 /******************************************************************/
261 * Saves the trash folder option.
262 * @param object $option SquirrelOption object
265 function save_option_trash_folder($option) {
266 global $data_dir, $username;
268 if (strtolower($option->new_value
)=='inbox') {
269 // make sure that it is not INBOX
270 error_option_save(_("You can't select INBOX as Trash folder."));
272 /* Set move to trash on or off. */
273 $trash_on = ($option->new_value
== SMPREF_NONE ? SMPREF_OFF
: SMPREF_ON
);
274 setPref($data_dir, $username, 'move_to_trash', $trash_on);
276 /* Now just save the option as normal. */
277 save_option($option);
282 * Saves the sent folder option.
283 * @param object $option SquirrelOption object
286 function save_option_sent_folder($option) {
287 global $data_dir, $username;
289 if (strtolower($option->new_value
)=='inbox') {
290 // make sure that it is not INBOX
291 error_option_save(_("You can't select INBOX as Sent folder."));
293 /* Set move to sent on or off. */
294 $sent_on = ($option->new_value
== SMPREF_NONE ? SMPREF_OFF
: SMPREF_ON
);
295 setPref($data_dir, $username, 'move_to_sent', $sent_on);
297 /* Now just save the option as normal. */
298 save_option($option);
303 * Saves the draft folder option.
304 * @param object $option SquirrelOption object
307 function save_option_draft_folder($option) {
308 global $data_dir, $username;
310 if (strtolower($option->new_value
)=='inbox') {
311 // make sure that it is not INBOX
312 error_option_save(_("You can't select INBOX as Draft folder."));
314 /* Set move to draft on or off. */
315 $draft_on = ($option->new_value
== SMPREF_NONE ? SMPREF_OFF
: SMPREF_ON
);
316 setPref($data_dir, $username, 'save_as_draft', $draft_on);
318 /* Now just save the option as normal. */
319 save_option($option);