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);
32 sqimap_logout($imapConnection);
34 /* Build a simple array into which we will build options. */
38 /******************************************************/
39 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
40 /******************************************************/
42 /*** Load the General Options into the array ***/
43 $optgrps[SMOPT_GRP_SPCFOLDER
] = _("Special Folder Options");
44 $optvals[SMOPT_GRP_SPCFOLDER
] = array();
46 if (!isset($folder_prefix)) { $folder_prefix = $default_folder_prefix; }
47 if ($show_prefix_option) {
48 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
49 'name' => 'folder_prefix',
50 'caption' => _("Folder Path"),
51 'type' => SMOPT_TYPE_STRING
,
52 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
53 'size' => SMOPT_SIZE_LARGE
57 $trash_folder_values = array(SMPREF_NONE
=> '[ '._("Do not use Trash").' ]',
58 'whatever' => $boxes);
59 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
60 'name' => 'trash_folder',
61 'caption' => _("Trash Folder"),
62 'type' => SMOPT_TYPE_FLDRLIST
,
63 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
64 'posvals' => $trash_folder_values,
65 'save' => 'save_option_trash_folder'
68 $sent_folder_values = array(SMPREF_NONE
=> '[ '._("Do not use Sent").' ]',
69 'whatever' => $boxes);
70 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
71 'name' => 'sent_folder',
72 'caption' => _("Sent Folder"),
73 'type' => SMOPT_TYPE_FLDRLIST
,
74 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
75 'posvals' => $sent_folder_values,
76 'save' => 'save_option_sent_folder'
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'
90 /*** Load the General Options into the array ***/
91 $optgrps[SMOPT_GRP_FOLDERLIST
] = _("Folder List Options");
92 $optvals[SMOPT_GRP_FOLDERLIST
] = array();
94 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
95 'name' => 'location_of_bar',
96 'caption' => _("Location of Folder List"),
97 'type' => SMOPT_TYPE_STRLIST
,
98 'refresh' => SMOPT_REFRESH_ALL
,
99 'posvals' => array(SMPREF_LOC_LEFT
=> _("Left"),
100 SMPREF_LOC_RIGHT
=> _("Right"))
103 $left_size_values = array();
104 for ($lsv = 100; $lsv <= 300; $lsv +
= 10) {
105 $left_size_values[$lsv] = "$lsv " . _("pixels");
107 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
108 'name' => 'left_size',
109 'caption' => _("Width of Folder List"),
110 'type' => SMOPT_TYPE_STRLIST
,
111 'refresh' => SMOPT_REFRESH_ALL
,
112 'posvals' => $left_size_values
115 $minute_str = _("Minutes");
116 $left_refresh_values = array(SMPREF_NONE
=> _("Never"));
117 foreach (array(30,60,120,180,300,600) as $lr_val) {
119 $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds");
120 } else if ($lr_val == 60) {
121 $left_refresh_values[$lr_val] = "1 " . _("Minute");
123 $left_refresh_values[$lr_val] = ($lr_val/60) . " $minute_str";
126 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
127 'name' => 'left_refresh',
128 'caption' => _("Auto Refresh Folder List"),
129 'type' => SMOPT_TYPE_STRLIST
,
130 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
131 'posvals' => $left_refresh_values
134 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
135 'name' => 'unseen_notify',
136 'caption' => _("Enable Unread Message Notification"),
137 'type' => SMOPT_TYPE_STRLIST
,
138 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
139 'posvals' => array(SMPREF_UNSEEN_NONE
=> _("No Notification"),
140 SMPREF_UNSEEN_INBOX
=> _("Only INBOX"),
141 SMPREF_UNSEEN_ALL
=> _("All Folders"))
144 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
145 'name' => 'unseen_type',
146 'caption' => _("Unread Message Notification Type"),
147 'type' => SMOPT_TYPE_STRLIST
,
148 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
149 'posvals' => array(SMPREF_UNSEEN_ONLY
=> _("Only Unseen"),
150 SMPREF_UNSEEN_TOTAL
=> _("Unseen and Total"))
153 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
154 'name' => 'collapse_folders',
155 'caption' => _("Enable Collapsable Folders"),
156 'type' => SMOPT_TYPE_BOOLEAN
,
157 'refresh' => SMOPT_REFRESH_FOLDERLIST
160 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
161 'name' => 'unseen_cum',
162 'caption' => _("Enable Cumulative Unread Message Notification"),
163 'type' => SMOPT_TYPE_BOOLEAN
,
164 'refresh' => SMOPT_REFRESH_FOLDERLIST
168 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
169 'name' => 'date_format',
170 'caption' => _("Show Clock on Folders Panel"),
171 'type' => SMOPT_TYPE_STRLIST
,
172 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
173 'posvals' => array( '1' => 'MM/DD/YY HH:MM',
174 '2' => 'DD/MM/YY HH:MM',
178 '6' => _("No Clock")),
181 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
182 'name' => 'hour_format',
183 'caption' => _("Hour Format"),
184 'type' => SMOPT_TYPE_STRLIST
,
185 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
186 'posvals' => array(SMPREF_TIME_12HR
=> _("12-hour clock"),
187 SMPREF_TIME_24HR
=> _("24-hour clock"))
190 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
191 'name' => 'search_memory',
192 'caption' => _("Memory Search"),
193 'type' => SMOPT_TYPE_STRLIST
,
194 'refresh' => SMOPT_REFRESH_NONE
,
195 'posvals' => array( 0 => _("Disabled"),
208 /*** Load the General Options into the array ***/
209 $optgrps[SMOPT_GRP_FOLDERSELECT
] = _("Folder Selection Options");
210 $optvals[SMOPT_GRP_FOLDERSELECT
] = array();
212 $delim = sqimap_get_delimiter();
213 $optvals[SMOPT_GRP_FOLDERSELECT
][] = array(
214 'name' => 'mailbox_select_style',
215 'caption' => _("Selection List Style"),
216 'type' => SMOPT_TYPE_STRLIST
,
217 'refresh' => SMOPT_REFRESH_NONE
,
218 'posvals' => array( 0 => _("Long: ") . '"Folder' . $delim . 'Subfolder"',
219 1 => _("Indented: ") . '" ' . 'Subfolder"',
220 2 => _("Delimited: ") . '". ' . 'Subfolder"')
223 /* Assemble all this together and return it as our result. */
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);