6 * Displays all options relating to folders
8 * @copyright © 1999-2005 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @package squirrelmail
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);
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
36 function load_optpage_data_folder() {
37 global $username, $key, $imapServerAddress, $imapPort;
38 global $folder_prefix, $default_folder_prefix, $show_prefix_option;
40 /* Get some imap data we need later. */
42 sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
43 $boxes = sqimap_mailbox_list($imapConnection);
45 /* Build a simple array into which we will build options. */
49 /******************************************************/
50 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
51 /******************************************************/
53 /*** Load the General Options into the array ***/
54 $optgrps[SMOPT_GRP_SPCFOLDER
] = _("Special Folder Options");
55 $optvals[SMOPT_GRP_SPCFOLDER
] = array();
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
68 $trash_folder_values = array(SMPREF_NONE
=> '[ '._("Do not use Trash").' ]',
69 'whatever' => $boxes);
70 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
71 'name' => 'trash_folder',
72 'caption' => _("Trash Folder"),
73 'type' => SMOPT_TYPE_FLDRLIST
,
74 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
75 'posvals' => $trash_folder_values,
76 'save' => 'save_option_trash_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 $sent_folder_values = array(SMPREF_NONE
=> '[ '._("Do not use Sent").' ]',
91 'whatever' => $boxes);
92 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
93 'name' => 'sent_folder',
94 'caption' => _("Sent Folder"),
95 'type' => SMOPT_TYPE_FLDRLIST
,
96 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
97 'posvals' => $sent_folder_values,
98 'save' => 'save_option_sent_folder'
101 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
102 'name' => 'save_reply_with_orig',
103 'caption' => _("Save Replies with Original Message"),
104 'type' => SMOPT_TYPE_BOOLEAN
,
105 'refresh' => SMOPT_REFRESH_FOLDERLIST
108 /*** Load the General Options into the array ***/
109 $optgrps[SMOPT_GRP_FOLDERLIST
] = _("Folder List Options");
110 $optvals[SMOPT_GRP_FOLDERLIST
] = array();
112 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
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"))
121 $left_size_values = array();
122 for ($lsv = 100; $lsv <= 300; $lsv +
= 10) {
123 $left_size_values[$lsv] = "$lsv " . _("pixels");
125 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
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
133 $left_refresh_values = array(SMPREF_NONE
=> _("Never"));
134 foreach (array(30,60,120,180,300,600,1200) as $lr_val) {
136 $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds");
138 $left_refresh_values[$lr_val] = sprintf(ngettext("%d Minute","%d Minutes",($lr_val/60)),($lr_val/60));
141 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
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
149 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
150 'name' => 'unseen_notify',
151 'caption' => _("Enable Unread Message Notification"),
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"))
159 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
160 'name' => 'unseen_type',
161 'caption' => _("Unread Message Notification Type"),
162 'type' => SMOPT_TYPE_STRLIST
,
163 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
164 'posvals' => array(SMPREF_UNSEEN_ONLY
=> _("Only Unseen"),
165 SMPREF_UNSEEN_TOTAL
=> _("Unseen and Total"))
168 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
169 'name' => 'collapse_folders',
170 'caption' => _("Enable Collapsable Folders"),
171 'type' => SMOPT_TYPE_BOOLEAN
,
172 'refresh' => SMOPT_REFRESH_FOLDERLIST
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
183 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
184 'name' => 'date_format',
185 'caption' => _("Show Clock on Folders Panel"),
186 'type' => SMOPT_TYPE_STRLIST
,
187 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
188 'posvals' => array( '0' => _("International date and time"),
189 '1' => _("American date and time"),
190 '2' => _("European date and time"),
191 '3' => _("Show weekday and time"),
192 '4' => _("Show time with seconds"),
193 '5' => _("Show time"),
194 '6' => _("No Clock")),
197 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
198 'name' => 'search_memory',
199 'caption' => _("Memory Search"),
200 'type' => SMOPT_TYPE_STRLIST
,
201 'refresh' => SMOPT_REFRESH_NONE
,
202 'posvals' => array( 0 => _("Disabled"),
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
221 /*** Load the General Options into the array ***/
222 $optgrps[SMOPT_GRP_FOLDERSELECT
] = _("Folder Selection Options");
223 $optvals[SMOPT_GRP_FOLDERSELECT
] = array();
225 $delim = sqimap_get_delimiter($imapConnection);
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
,
231 'posvals' => array( 0 => _("Long:") . ' "' . _("Folder") . $delim . _("Subfolder") . '"',
232 1 => _("Indented:") . ' " ' . _("Subfolder") . '"',
233 2 => _("Delimited:") . ' ". ' . _("Subfolder") . '"'),
234 'htmlencoded' => true
237 /* Assemble all this together and return it as our result. */
242 sqimap_logout($imapConnection);
246 /******************************************************************/
247 /** Define any specialized save functions for this option page. ***/
248 /******************************************************************/
251 * Saves the trash folder option.
253 function save_option_trash_folder($option) {
254 global $data_dir, $username;
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);
260 /* Now just save the option as normal. */
261 save_option($option);
265 * Saves the sent folder option.
267 function save_option_sent_folder($option) {
268 global $data_dir, $username;
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);
274 /* Now just save the option as normal. */
275 save_option($option);
279 * Saves the draft folder option.
281 function save_option_draft_folder($option) {
282 global $data_dir, $username;
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);
288 /* Now just save the option as normal. */
289 save_option($option);