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');
17 /* Define the group constants for the folder options page. */
18 define('SMOPT_GRP_SPCFOLDER', 0);
19 define('SMOPT_GRP_FOLDERLIST', 1);
21 /* Define the optpage load function for the folder options page. */
22 function load_optpage_data_folder() {
23 global $username, $key, $imapServerAddress, $imapPort;
24 global $folder_prefix, $default_folder_prefix, $show_prefix_option;
26 /* Get some imap data we need later. */
28 sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
29 $boxes = sqimap_mailbox_list($imapConnection);
30 sqimap_logout($imapConnection);
32 /* Build a simple array into which we will build options. */
36 /******************************************************/
37 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
38 /******************************************************/
40 /*** Load the General Options into the array ***/
41 $optgrps[SMOPT_GRP_SPCFOLDER
] = _("Special Folder Options");
42 $optvals[SMOPT_GRP_SPCFOLDER
] = array();
44 if (!isset($folder_prefix)) { $folder_prefix = $default_folder_prefix; }
45 if ($show_prefix_option) {
46 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
47 'name' => 'folder_prefix',
48 'caption' => _("Folder Path"),
49 'type' => SMOPT_TYPE_STRING
,
50 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
51 'size' => SMOPT_SIZE_LARGE
55 $special_folder_values = array();
56 foreach ($boxes as $folder) {
57 if (strtolower($folder['unformatted']) != 'inbox') {
58 $real_value = $folder['unformatted-dm'];
59 $disp_value = str_replace(' ', ' ', $folder['formatted']);
60 $special_folder_values[$real_value] = $disp_value;
64 $trash_none = array(SMPREF_NONE
=> _("Do not use Trash"));
65 $trash_folder_values = array_merge($trash_none, $special_folder_values);
66 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
67 'name' => 'trash_folder',
68 'caption' => _("Trash Folder"),
69 'type' => SMOPT_TYPE_STRLIST
,
70 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
71 'posvals' => $trash_folder_values,
72 'save' => 'save_option_trash_folder'
75 $sent_none = array(SMPREF_NONE
=> _("Do not use Sent"));
76 $sent_folder_values = array_merge($sent_none, $special_folder_values);
77 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
78 'name' => 'sent_folder',
79 'caption' => _("Sent Folder"),
80 'type' => SMOPT_TYPE_STRLIST
,
81 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
82 'posvals' => $sent_folder_values,
83 'save' => 'save_option_sent_folder'
86 $draft_none = array(SMPREF_NONE
=> _("Do not use Drafts"));
87 $draft_folder_values = array_merge($draft_none, $special_folder_values);
88 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
89 'name' => 'draft_folder',
90 'caption' => _("Draft Folder"),
91 'type' => SMOPT_TYPE_STRLIST
,
92 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
93 'posvals' => $draft_folder_values,
94 'save' => 'save_option_draft_folder'
97 /*** Load the General Options into the array ***/
98 $optgrps[SMOPT_GRP_FOLDERLIST
] = _("Folder List Options");
99 $optvals[SMOPT_GRP_FOLDERLIST
] = array();
101 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
102 'name' => 'location_of_bar',
103 'caption' => _("Location of Folder List"),
104 'type' => SMOPT_TYPE_STRLIST
,
105 'refresh' => SMOPT_REFRESH_ALL
,
106 'posvals' => array(SMPREF_LOC_LEFT
=> _("Left"),
107 SMPREF_LOC_RIGHT
=> _("Right"))
110 $left_size_values = array();
111 for ($lsv = 100; $lsv <= 300; $lsv +
= 10) {
112 $left_size_values[$lsv] = "$lsv " . _("pixels");
114 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
115 'name' => 'left_size',
116 'caption' => _("Width of Folder List"),
117 'type' => SMOPT_TYPE_STRLIST
,
118 'refresh' => SMOPT_REFRESH_ALL
,
119 'posvals' => $left_size_values
122 $minute_str = _("Minutes");
123 $left_refresh_values = array(SMPREF_NONE
=> _("Never"));
124 foreach (array(30,60,120,180,300,600) as $lr_val) {
126 $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds");
127 } else if ($lr_val == 60) {
128 $left_refresh_values[$lr_val] = "1 " . _("Minute");
130 $left_refresh_values[$lr_val] = ($lr_val/60) . " $minute_str";
133 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
134 'name' => 'left_refresh',
135 'caption' => _("Auto Refresh Folder List"),
136 'type' => SMOPT_TYPE_STRLIST
,
137 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
138 'posvals' => $left_refresh_values
141 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
142 'name' => 'unseen_notify',
143 'caption' => _("Enable Unread Message Notification"),
144 'type' => SMOPT_TYPE_STRLIST
,
145 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
146 'posvals' => array(SMPREF_UNSEEN_NONE
=> _("No Notification"),
147 SMPREF_UNSEEN_INBOX
=> _("Only INBOX"),
148 SMPREF_UNSEEN_ALL
=> _("All Folders"))
151 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
152 'name' => 'unseen_type',
153 'caption' => _("Unread Message Notification Type"),
154 'type' => SMOPT_TYPE_STRLIST
,
155 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
156 'posvals' => array(SMPREF_UNSEEN_ONLY
=> _("Only Unseen"),
157 SMPREF_UNSEEN_TOTAL
=> _("Unseen and Total"))
160 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
161 'name' => 'collapse_folders',
162 'caption' => _("Enable Collapsable Folders"),
163 'type' => SMOPT_TYPE_BOOLEAN
,
164 '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"),
206 /* Assemble all this together and return it as our result. */
214 /******************************************************************/
215 /** Define any specialized save functions for this option page. ***/
216 /******************************************************************/
217 function save_option_trash_folder($option) {
218 global $data_dir, $username;
220 /* Set move to trash on or off. */
221 $trash_on = ($option->new_value
== SMPREF_NONE ? SMPREF_OFF
: SMPREF_ON
);
222 setPref($data_dir, $username, 'move_to_trash', $trash_on);
224 /* Now just save the option as normal. */
225 save_option($option);
228 function save_option_sent_folder($option) {
229 global $data_dir, $username;
231 /* Set move to sent on or off. */
232 $sent_on = ($option->new_value
== SMPREF_NONE ? SMPREF_OFF
: SMPREF_ON
);
233 setPref($data_dir, $username, 'move_to_sent', $sent_on);
235 /* Now just save the option as normal. */
236 save_option($option);
239 function save_option_draft_folder($option) {
240 global $data_dir, $username;
242 /* Set move to draft on or off. */
243 $draft_on = ($option->new_value
== SMPREF_NONE ? SMPREF_OFF
: SMPREF_ON
);
244 setPref($data_dir, $username, 'save_as_draft', $draft_on);
246 /* Now just save the option as normal. */
247 save_option($option);