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 require_once('../functions/imap.php');
16 /* Define the group constants for the folder options page. */
17 define('SMOPT_GRP_SPCFOLDER', 0);
18 define('SMOPT_GRP_FOLDERLIST', 1);
20 /* Define the optpage load function for the folder options page. */
21 function load_optpage_data_folder() {
22 global $username, $key, $imapServerAddress, $imapPort;
23 global $folder_prefix, $default_folder_prefix, $show_prefix_option;
25 /* Get some imap data we need later. */
27 sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
28 $boxes = sqimap_mailbox_list($imapConnection);
29 sqimap_logout($imapConnection);
31 /* Build a simple array into which we will build options. */
35 /******************************************************/
36 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
37 /******************************************************/
39 /*** Load the General Options into the array ***/
40 $optgrps[SMOPT_GRP_SPCFOLDER
] = _("Special Folder Options");
41 $optvals[SMOPT_GRP_SPCFOLDER
] = array();
43 if (!isset($folder_prefix)) { $folder_prefix = $default_folder_prefix; }
44 if ($show_prefix_option) {
45 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
46 'name' => 'folder_prefix',
47 'caption' => _("Folder Path"),
48 'type' => SMOPT_TYPE_STRING
,
49 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
50 'size' => SMOPT_SIZE_LARGE
54 $special_folder_values = array();
55 foreach ($boxes as $folder) {
56 if (strtolower($folder['unformatted']) != 'inbox') {
57 $real_value = $folder['unformatted-dm'];
58 $disp_value = str_replace(' ', ' ', $folder['formatted']);
59 $special_folder_values[$real_value] = $disp_value;
63 $trash_none = array(SMPREF_NONE
=> _("Do not use Trash"));
64 $trash_folder_values = array_merge($trash_none, $special_folder_values);
65 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
66 'name' => 'trash_folder',
67 'caption' => _("Trash Folder"),
68 'type' => SMOPT_TYPE_STRLIST
,
69 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
70 'posvals' => $trash_folder_values,
71 'save' => 'save_option_trash_folder'
74 $sent_none = array(SMPREF_NONE
=> _("Do not use Sent"));
75 $sent_folder_values = array_merge($sent_none, $special_folder_values);
76 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
77 'name' => 'sent_folder',
78 'caption' => _("Sent Folder"),
79 'type' => SMOPT_TYPE_STRLIST
,
80 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
81 'posvals' => $sent_folder_values,
82 'save' => 'save_option_sent_folder'
85 $draft_none = array(SMPREF_NONE
=> _("Do not use Drafts"));
86 $draft_folder_values = array_merge($draft_none, $special_folder_values);
87 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
88 'name' => 'draft_folder',
89 'caption' => _("Draft Folder"),
90 'type' => SMOPT_TYPE_STRLIST
,
91 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
92 'posvals' => $draft_folder_values,
93 'save' => 'save_option_draft_folder'
96 /*** Load the General Options into the array ***/
97 $optgrps[SMOPT_GRP_FOLDERLIST
] = _("Folder List Options");
98 $optvals[SMOPT_GRP_FOLDERLIST
] = array();
100 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
101 'name' => 'location_of_bar',
102 'caption' => _("Location of Folder List"),
103 'type' => SMOPT_TYPE_STRLIST
,
104 'refresh' => SMOPT_REFRESH_ALL
,
105 'posvals' => array(SMPREF_LOC_LEFT
=> _("Left"),
106 SMPREF_LOC_RIGHT
=> _("Right"))
109 $left_size_values = array();
110 for ($lsv = 100; $lsv <= 300; $lsv +
= 10) {
111 $left_size_values[$lsv] = "$lsv " . _("pixels");
113 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
114 'name' => 'left_size',
115 'caption' => _("Width of Folder List"),
116 'type' => SMOPT_TYPE_STRLIST
,
117 'refresh' => SMOPT_REFRESH_ALL
,
118 'posvals' => $left_size_values
121 $minute_str = _("Minutes");
122 $left_refresh_values = array(SMPREF_NONE
=> _("Never"));
123 foreach (array(30,60,120,180,300,600) as $lr_val) {
125 $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds");
126 } else if ($lr_val == 60) {
127 $left_refresh_values[$lr_val] = "1 " . _("Minute");
129 $left_refresh_values[$lr_val] = ($lr_val/60) . " $minute_str";
132 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
133 'name' => 'left_refresh',
134 'caption' => _("Auto Refresh Folder List"),
135 'type' => SMOPT_TYPE_STRLIST
,
136 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
137 'posvals' => $left_refresh_values
140 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
141 'name' => 'unseen_notify',
142 'caption' => _("Enable Unread Message Notification"),
143 'type' => SMOPT_TYPE_STRLIST
,
144 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
145 'posvals' => array(SMPREF_UNSEEN_NONE
=> _("No Notification"),
146 SMPREF_UNSEEN_INBOX
=> _("Only INBOX"),
147 SMPREF_UNSEEN_ALL
=> _("All Folders"))
150 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
151 'name' => 'unseen_type',
152 'caption' => _("Unread Message Notification Type"),
153 'type' => SMOPT_TYPE_STRLIST
,
154 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
155 'posvals' => array(SMPREF_UNSEEN_ONLY
=> _("Only Unseen"),
156 SMPREF_UNSEEN_TOTAL
=> _("Unseen and Total"))
159 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
160 'name' => 'collapse_folders',
161 'caption' => _("Enable Collapsable Folders"),
162 'type' => SMOPT_TYPE_BOOLEAN
,
163 'refresh' => SMOPT_REFRESH_FOLDERLIST
166 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
167 'name' => 'date_format',
168 'caption' => _("Show Clock on Folders Panel"),
169 'type' => SMOPT_TYPE_STRLIST
,
170 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
171 'posvals' => array( '1' => 'MM/DD/YY HH:MM',
172 '2' => 'DD/MM/YY HH:MM',
176 '6' => _("No Clock")),
179 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
180 'name' => 'hour_format',
181 'caption' => _("Hour Format"),
182 'type' => SMOPT_TYPE_STRLIST
,
183 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
184 'posvals' => array(SMPREF_TIME_12HR
=> _("12-hour clock"),
185 SMPREF_TIME_24HR
=> _("24-hour clock"))
188 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
189 'name' => 'search_memory',
190 'caption' => _("Memory Search"),
191 'type' => SMOPT_TYPE_STRLIST
,
192 'refresh' => SMOPT_REFRESH_NONE
,
193 'posvals' => array( 0 => _("Disabled"),
205 /* Assemble all this together and return it as our result. */
213 /******************************************************************/
214 /** Define any specialized save functions for this option page. ***/
215 /******************************************************************/
216 function save_option_trash_folder($option) {
217 global $data_dir, $username;
219 /* Set move to trash on or off. */
220 $trash_on = ($option->new_value
== SMPREF_NONE ? SMPREF_OFF
: SMPREF_ON
);
221 setPref($data_dir, $username, 'move_to_trash', $trash_on);
223 /* Now just save the option as normal. */
224 save_option($option);
227 function save_option_sent_folder($option) {
228 global $data_dir, $username;
230 /* Set move to sent on or off. */
231 $sent_on = ($option->new_value
== SMPREF_NONE ? SMPREF_OFF
: SMPREF_ON
);
232 setPref($data_dir, $username, 'move_to_sent', $sent_on);
234 /* Now just save the option as normal. */
235 save_option($option);
238 function save_option_draft_folder($option) {
239 global $data_dir, $username;
241 /* Set move to draft on or off. */
242 $draft_on = ($option->new_value
== SMPREF_NONE ? SMPREF_OFF
: SMPREF_ON
);
243 setPref($data_dir, $username, 'save_as_draft', $draft_on);
245 /* Now just save the option as normal. */
246 save_option($option);