Part 1 of switch to use of SM_PATH with require_once.
[squirrelmail.git] / src / options_folder.php
CommitLineData
c36ed9cf 1<?php
c36ed9cf 2
35586184 3/**
4 * options_folder.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
35586184 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Displays all options relating to folders
10 *
11 * $Id$
12 */
cbe5423b 13
86725763 14/* Path for SquirrelMail required files. */
15define('SM_PATH','../');
16
17/* SquirrelMail required files. */
18require_once(SM_PATH . 'functions/imap.php');
cbe5423b 19
20/* Define the group constants for the folder options page. */
21define('SMOPT_GRP_SPCFOLDER', 0);
22define('SMOPT_GRP_FOLDERLIST', 1);
23
24/* Define the optpage load function for the folder options page. */
25function load_optpage_data_folder() {
26 global $username, $key, $imapServerAddress, $imapPort;
2fad95fa 27 global $folder_prefix, $default_folder_prefix, $show_prefix_option;
cbe5423b 28
29 /* Get some imap data we need later. */
30 $imapConnection =
31 sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
32 $boxes = sqimap_mailbox_list($imapConnection);
33 sqimap_logout($imapConnection);
bbcafebd 34
b5efadfa 35 /* Build a simple array into which we will build options. */
bbcafebd 36 $optgrps = array();
b5efadfa 37 $optvals = array();
38
bbcafebd 39 /******************************************************/
40 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
41 /******************************************************/
bbcafebd 42
43 /*** Load the General Options into the array ***/
44 $optgrps[SMOPT_GRP_SPCFOLDER] = _("Special Folder Options");
45 $optvals[SMOPT_GRP_SPCFOLDER] = array();
46
cbe5423b 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
55 );
56 }
57
b5efadfa 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(' ', '&nbsp;', $folder['formatted']);
63 $special_folder_values[$real_value] = $disp_value;
64 }
65 }
66
67 $trash_none = array(SMPREF_NONE => _("Do not use Trash"));
68 $trash_folder_values = array_merge($trash_none, $special_folder_values);
bbcafebd 69 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
b5efadfa 70 'name' => 'trash_folder',
71 'caption' => _("Trash Folder"),
72 'type' => SMOPT_TYPE_STRLIST,
73 'refresh' => SMOPT_REFRESH_FOLDERLIST,
cbe5423b 74 'posvals' => $trash_folder_values,
75 'save' => 'save_option_trash_folder'
b5efadfa 76 );
77
78 $sent_none = array(SMPREF_NONE => _("Do not use Sent"));
79 $sent_folder_values = array_merge($sent_none, $special_folder_values);
bbcafebd 80 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
b5efadfa 81 'name' => 'sent_folder',
82 'caption' => _("Sent Folder"),
83 'type' => SMOPT_TYPE_STRLIST,
84 'refresh' => SMOPT_REFRESH_FOLDERLIST,
cbe5423b 85 'posvals' => $sent_folder_values,
86 'save' => 'save_option_sent_folder'
b5efadfa 87 );
88
89dbabc2 89 $draft_none = array(SMPREF_NONE => _("Do not use Drafts"));
b5efadfa 90 $draft_folder_values = array_merge($draft_none, $special_folder_values);
bbcafebd 91 $optvals[SMOPT_GRP_SPCFOLDER][] = array(
b5efadfa 92 'name' => 'draft_folder',
93 'caption' => _("Draft Folder"),
94 'type' => SMOPT_TYPE_STRLIST,
95 'refresh' => SMOPT_REFRESH_FOLDERLIST,
cbe5423b 96 'posvals' => $draft_folder_values,
97 'save' => 'save_option_draft_folder'
b5efadfa 98 );
99
bbcafebd 100 /*** Load the General Options into the array ***/
101 $optgrps[SMOPT_GRP_FOLDERLIST] = _("Folder List Options");
102 $optvals[SMOPT_GRP_FOLDERLIST] = array();
103
104 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 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"))
111 );
112
113 $left_size_values = array();
114 for ($lsv = 100; $lsv <= 300; $lsv += 10) {
115 $left_size_values[$lsv] = "$lsv " . _("pixels");
116 }
bbcafebd 117 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 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
123 );
124
125 $minute_str = _("Minutes");
126 $left_refresh_values = array(SMPREF_NONE => _("Never"));
127 foreach (array(30,60,120,180,300,600) as $lr_val) {
128 if ($lr_val < 60) {
129 $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds");
130 } else if ($lr_val == 60) {
131 $left_refresh_values[$lr_val] = "1 " . _("Minute");
132 } else {
133 $left_refresh_values[$lr_val] = ($lr_val/60) . " $minute_str";
134 }
135 }
bbcafebd 136 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 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
142 );
143
bbcafebd 144 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 145 'name' => 'unseen_notify',
10ff0c3d 146 'caption' => _("Enable Unread Message Notification"),
a440e68f 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"))
152 );
153
bbcafebd 154 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 155 'name' => 'unseen_type',
10ff0c3d 156 'caption' => _("Unread Message Notification Type"),
a440e68f 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"))
161 );
162
bbcafebd 163 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 164 'name' => 'collapse_folders',
165 'caption' => _("Enable Collapsable Folders"),
166 'type' => SMOPT_TYPE_BOOLEAN,
167 'refresh' => SMOPT_REFRESH_FOLDERLIST
168 );
169
bbcafebd 170 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 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',
177 '3' => 'DDD, HH:MM',
178 '4' => 'HH:MM:SS',
179 '5' => 'HH:MM',
180 '6' => _("No Clock")),
181 );
182
bbcafebd 183 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
a440e68f 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"))
190 );
191
0d672ac0 192 $optvals[SMOPT_GRP_FOLDERLIST][] = array(
193 'name' => 'search_memory',
194 'caption' => _("Memory Search"),
195 'type' => SMOPT_TYPE_STRLIST,
90568047 196 'refresh' => SMOPT_REFRESH_NONE,
0d672ac0 197 'posvals' => array( 0 => _("Disabled"),
198 1 => '1',
199 2 => '2',
200 3 => '3',
201 4 => '4',
202 5 => '5',
203 6 => '6',
204 7 => '7',
205 8 => '8',
a2bc1180 206 9 => '9')
207 );
0d672ac0 208
cbe5423b 209 /* Assemble all this together and return it as our result. */
210 $result = array(
211 'grps' => $optgrps,
212 'vals' => $optvals
213 );
214 return ($result);
215}
216
217/******************************************************************/
218/** Define any specialized save functions for this option page. ***/
219/******************************************************************/
220function save_option_trash_folder($option) {
221 global $data_dir, $username;
222
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);
a440e68f 226
cbe5423b 227 /* Now just save the option as normal. */
228 save_option($option);
229}
2016e645 230
cbe5423b 231function save_option_sent_folder($option) {
232 global $data_dir, $username;
e7db48af 233
cbe5423b 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);
e7db48af 237
cbe5423b 238 /* Now just save the option as normal. */
239 save_option($option);
240}
e7db48af 241
cbe5423b 242function save_option_draft_folder($option) {
243 global $data_dir, $username;
244
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);
248
249 /* Now just save the option as normal. */
250 save_option($option);
251}
252
253?>