f103cbc96794e8d69fbce239cccd636c55fe84e4
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 /* Path for SquirrelMail required files. */
15 define('SM_PATH','../');
17 /* SquirrelMail required files. */
18 require_once(SM_PATH
. 'functions/imap.php');
20 /* Define the group constants for the folder options page. */
21 define('SMOPT_GRP_SPCFOLDER', 0);
22 define('SMOPT_GRP_FOLDERLIST', 1);
24 /* Define the optpage load function for the folder options page. */
25 function load_optpage_data_folder() {
26 global $username, $key, $imapServerAddress, $imapPort;
27 global $folder_prefix, $default_folder_prefix, $show_prefix_option;
29 /* Get some imap data we need later. */
31 sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
32 $boxes = sqimap_mailbox_list($imapConnection);
33 sqimap_logout($imapConnection);
35 /* Build a simple array into which we will build options. */
39 /******************************************************/
40 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
41 /******************************************************/
43 /*** Load the General Options into the array ***/
44 $optgrps[SMOPT_GRP_SPCFOLDER
] = _("Special Folder Options");
45 $optvals[SMOPT_GRP_SPCFOLDER
] = array();
47 if (!isset($folder_prefix)) { $folder_prefix = $default_folder_prefix; }
48 if ($show_prefix_option) {
49 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
50 'name' => 'folder_prefix',
51 'caption' => _("Folder Path"),
52 'type' => SMOPT_TYPE_STRING
,
53 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
54 'size' => SMOPT_SIZE_LARGE
58 $special_folder_values = array();
59 foreach ($boxes as $folder) {
60 if (strtolower($folder['unformatted']) != 'inbox') {
61 $real_value = $folder['unformatted-dm'];
62 $disp_value = str_replace(' ', ' ', $folder['formatted']);
63 $special_folder_values[$real_value] = $disp_value;
67 $trash_none = array(SMPREF_NONE
=> _("Do not use Trash"));
68 $trash_folder_values = array_merge($trash_none, $special_folder_values);
69 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
70 'name' => 'trash_folder',
71 'caption' => _("Trash Folder"),
72 'type' => SMOPT_TYPE_STRLIST
,
73 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
74 'posvals' => $trash_folder_values,
75 'save' => 'save_option_trash_folder'
78 $sent_none = array(SMPREF_NONE
=> _("Do not use Sent"));
79 $sent_folder_values = array_merge($sent_none, $special_folder_values);
80 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
81 'name' => 'sent_folder',
82 'caption' => _("Sent Folder"),
83 'type' => SMOPT_TYPE_STRLIST
,
84 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
85 'posvals' => $sent_folder_values,
86 'save' => 'save_option_sent_folder'
89 $draft_none = array(SMPREF_NONE
=> _("Do not use Drafts"));
90 $draft_folder_values = array_merge($draft_none, $special_folder_values);
91 $optvals[SMOPT_GRP_SPCFOLDER
][] = array(
92 'name' => 'draft_folder',
93 'caption' => _("Draft Folder"),
94 'type' => SMOPT_TYPE_STRLIST
,
95 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
96 'posvals' => $draft_folder_values,
97 'save' => 'save_option_draft_folder'
100 /*** Load the General Options into the array ***/
101 $optgrps[SMOPT_GRP_FOLDERLIST
] = _("Folder List Options");
102 $optvals[SMOPT_GRP_FOLDERLIST
] = array();
104 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
105 'name' => 'location_of_bar',
106 'caption' => _("Location of Folder List"),
107 'type' => SMOPT_TYPE_STRLIST
,
108 'refresh' => SMOPT_REFRESH_ALL
,
109 'posvals' => array(SMPREF_LOC_LEFT
=> _("Left"),
110 SMPREF_LOC_RIGHT
=> _("Right"))
113 $left_size_values = array();
114 for ($lsv = 100; $lsv <= 300; $lsv +
= 10) {
115 $left_size_values[$lsv] = "$lsv " . _("pixels");
117 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
118 'name' => 'left_size',
119 'caption' => _("Width of Folder List"),
120 'type' => SMOPT_TYPE_STRLIST
,
121 'refresh' => SMOPT_REFRESH_ALL
,
122 'posvals' => $left_size_values
125 $minute_str = _("Minutes");
126 $left_refresh_values = array(SMPREF_NONE
=> _("Never"));
127 foreach (array(30,60,120,180,300,600) as $lr_val) {
129 $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds");
130 } else if ($lr_val == 60) {
131 $left_refresh_values[$lr_val] = "1 " . _("Minute");
133 $left_refresh_values[$lr_val] = ($lr_val/60) . " $minute_str";
136 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
137 'name' => 'left_refresh',
138 'caption' => _("Auto Refresh Folder List"),
139 'type' => SMOPT_TYPE_STRLIST
,
140 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
141 'posvals' => $left_refresh_values
144 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
145 'name' => 'unseen_notify',
146 'caption' => _("Enable Unread Message Notification"),
147 'type' => SMOPT_TYPE_STRLIST
,
148 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
149 'posvals' => array(SMPREF_UNSEEN_NONE
=> _("No Notification"),
150 SMPREF_UNSEEN_INBOX
=> _("Only INBOX"),
151 SMPREF_UNSEEN_ALL
=> _("All Folders"))
154 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
155 'name' => 'unseen_type',
156 'caption' => _("Unread Message Notification Type"),
157 'type' => SMOPT_TYPE_STRLIST
,
158 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
159 'posvals' => array(SMPREF_UNSEEN_ONLY
=> _("Only Unseen"),
160 SMPREF_UNSEEN_TOTAL
=> _("Unseen and Total"))
163 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
164 'name' => 'collapse_folders',
165 'caption' => _("Enable Collapsable Folders"),
166 'type' => SMOPT_TYPE_BOOLEAN
,
167 'refresh' => SMOPT_REFRESH_FOLDERLIST
170 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
171 'name' => 'date_format',
172 'caption' => _("Show Clock on Folders Panel"),
173 'type' => SMOPT_TYPE_STRLIST
,
174 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
175 'posvals' => array( '1' => 'MM/DD/YY HH:MM',
176 '2' => 'DD/MM/YY HH:MM',
180 '6' => _("No Clock")),
183 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
184 'name' => 'hour_format',
185 'caption' => _("Hour Format"),
186 'type' => SMOPT_TYPE_STRLIST
,
187 'refresh' => SMOPT_REFRESH_FOLDERLIST
,
188 'posvals' => array(SMPREF_TIME_12HR
=> _("12-hour clock"),
189 SMPREF_TIME_24HR
=> _("24-hour clock"))
192 $optvals[SMOPT_GRP_FOLDERLIST
][] = array(
193 'name' => 'search_memory',
194 'caption' => _("Memory Search"),
195 'type' => SMOPT_TYPE_STRLIST
,
196 'refresh' => SMOPT_REFRESH_NONE
,
197 'posvals' => array( 0 => _("Disabled"),
209 /* Assemble all this together and return it as our result. */
217 /******************************************************************/
218 /** Define any specialized save functions for this option page. ***/
219 /******************************************************************/
220 function save_option_trash_folder($option) {
221 global $data_dir, $username;
223 /* Set move to trash on or off. */
224 $trash_on = ($option->new_value
== SMPREF_NONE ? SMPREF_OFF
: SMPREF_ON
);
225 setPref($data_dir, $username, 'move_to_trash', $trash_on);
227 /* Now just save the option as normal. */
228 save_option($option);
231 function save_option_sent_folder($option) {
232 global $data_dir, $username;
234 /* Set move to sent on or off. */
235 $sent_on = ($option->new_value
== SMPREF_NONE ? SMPREF_OFF
: SMPREF_ON
);
236 setPref($data_dir, $username, 'move_to_sent', $sent_on);
238 /* Now just save the option as normal. */
239 save_option($option);
242 function save_option_draft_folder($option) {
243 global $data_dir, $username;
245 /* Set move to draft on or off. */
246 $draft_on = ($option->new_value
== SMPREF_NONE ? SMPREF_OFF
: SMPREF_ON
);
247 setPref($data_dir, $username, 'save_as_draft', $draft_on);
249 /* Now just save the option as normal. */
250 save_option($option);