squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

folder.php
Go to the documentation of this file.
1 <?php
2 
15 require_once(SM_PATH . 'functions/imap.php');
16 require_once(SM_PATH . 'functions/imap_general.php');
17 
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);
22 
37  global $username, $key, $imapServerAddress, $imapPort;
39 
40  /* Get some imap data we need later. */
44 
45  /* Build a simple array into which we will build options. */
46  $optgrps = array();
47  $optvals = array();
48 
49  /******************************************************/
50  /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
51  /******************************************************/
52 
53  /*** Load the General Options into the array ***/
54  $optgrps[SMOPT_GRP_SPCFOLDER] = _("Special Folder Options");
55  $optvals[SMOPT_GRP_SPCFOLDER] = array();
56 
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
65  );
66  }
67 
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'
77  );
78 
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'
88  );
89 
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'
99  );
100 
101  /*** Load the General Options into the array ***/
102  $optgrps[SMOPT_GRP_FOLDERLIST] = _("Folder List Options");
103  $optvals[SMOPT_GRP_FOLDERLIST] = array();
104 
105  $optvals[SMOPT_GRP_FOLDERLIST][] = array(
106  'name' => 'location_of_bar',
107  'caption' => _("Location of Folder List"),
108  'type' => SMOPT_TYPE_STRLIST,
109  'refresh' => SMOPT_REFRESH_ALL,
110  'posvals' => array(SMPREF_LOC_LEFT => _("Left"),
111  SMPREF_LOC_RIGHT => _("Right"))
112  );
113 
114  $left_size_values = array();
115  for ($lsv = 100; $lsv <= 300; $lsv += 10) {
116  $left_size_values[$lsv] = "$lsv " . _("pixels");
117  }
118  $optvals[SMOPT_GRP_FOLDERLIST][] = array(
119  'name' => 'left_size',
120  'caption' => _("Width of Folder List"),
121  'type' => SMOPT_TYPE_STRLIST,
122  'refresh' => SMOPT_REFRESH_ALL,
123  'posvals' => $left_size_values
124  );
125 
126  $minute_str = _("Minutes");
127  $left_refresh_values = array(SMPREF_NONE => _("Never"));
128  foreach (array(30,60,120,180,300,600,1200) as $lr_val) {
129  if ($lr_val < 60) {
130  $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds");
131  } else if ($lr_val == 60) {
132  $left_refresh_values[$lr_val] = "1 " . _("Minute");
133  } else {
134  $left_refresh_values[$lr_val] = ($lr_val/60) . " $minute_str";
135  }
136  }
137  $optvals[SMOPT_GRP_FOLDERLIST][] = array(
138  'name' => 'left_refresh',
139  'caption' => _("Auto Refresh Folder List"),
140  'type' => SMOPT_TYPE_STRLIST,
141  'refresh' => SMOPT_REFRESH_FOLDERLIST,
142  'posvals' => $left_refresh_values
143  );
144 
145  $optvals[SMOPT_GRP_FOLDERLIST][] = array(
146  'name' => 'unseen_notify',
147  'caption' => _("Enable Unread Message Notification"),
148  'type' => SMOPT_TYPE_STRLIST,
149  'refresh' => SMOPT_REFRESH_FOLDERLIST,
150  'posvals' => array(SMPREF_UNSEEN_NONE => _("No Notification"),
151  SMPREF_UNSEEN_INBOX => _("Only INBOX"),
152  SMPREF_UNSEEN_ALL => _("All Folders"))
153  );
154 
155  $optvals[SMOPT_GRP_FOLDERLIST][] = array(
156  'name' => 'unseen_type',
157  'caption' => _("Unread Message Notification Type"),
158  'type' => SMOPT_TYPE_STRLIST,
159  'refresh' => SMOPT_REFRESH_FOLDERLIST,
160  'posvals' => array(SMPREF_UNSEEN_ONLY => _("Only Unseen"),
161  SMPREF_UNSEEN_TOTAL => _("Unseen and Total"))
162  );
163 
164  $optvals[SMOPT_GRP_FOLDERLIST][] = array(
165  'name' => 'collapse_folders',
166  'caption' => _("Enable Collapsable Folders"),
167  'type' => SMOPT_TYPE_BOOLEAN,
168  'refresh' => SMOPT_REFRESH_FOLDERLIST
169  );
170 
171  $optvals[SMOPT_GRP_FOLDERLIST][] = array(
172  'name' => 'unseen_cum',
173  'caption' => _("Enable Cumulative Unread Message Notification"),
174  'type' => SMOPT_TYPE_BOOLEAN,
175  'refresh' => SMOPT_REFRESH_FOLDERLIST
176  );
177 
178 
179  $optvals[SMOPT_GRP_FOLDERLIST][] = array(
180  'name' => 'date_format',
181  'caption' => _("Show Clock on Folders Panel"),
182  'type' => SMOPT_TYPE_STRLIST,
183  'refresh' => SMOPT_REFRESH_FOLDERLIST,
184  'posvals' => array( '0' => _("International date and time"),
185  '1' => _("American date and time"),
186  '2' => _("European date and time"),
187  '3' => _("Show weekday and time"),
188  '4' => _("Show time with seconds"),
189  '5' => _("Show time"),
190  '6' => _("No Clock")),
191  );
192 
193  $optvals[SMOPT_GRP_FOLDERLIST][] = array(
194  'name' => 'hour_format',
195  'caption' => _("Hour Format"),
196  'type' => SMOPT_TYPE_STRLIST,
197  'refresh' => SMOPT_REFRESH_FOLDERLIST,
198  'posvals' => array(SMPREF_TIME_12HR => _("12-hour clock"),
199  SMPREF_TIME_24HR => _("24-hour clock"))
200  );
201 
202  $optvals[SMOPT_GRP_FOLDERLIST][] = array(
203  'name' => 'search_memory',
204  'caption' => _("Memory Search"),
205  'type' => SMOPT_TYPE_STRLIST,
206  'refresh' => SMOPT_REFRESH_NONE,
207  'posvals' => array( 0 => _("Disabled"),
208  1 => '1',
209  2 => '2',
210  3 => '3',
211  4 => '4',
212  5 => '5',
213  6 => '6',
214  7 => '7',
215  8 => '8',
216  9 => '9')
217  );
218 
219 
220  /*** Load the General Options into the array ***/
221  $optgrps[SMOPT_GRP_FOLDERSELECT] = _("Folder Selection Options");
222  $optvals[SMOPT_GRP_FOLDERSELECT] = array();
223 
225  $optvals[SMOPT_GRP_FOLDERSELECT][] = array(
226  'name' => 'mailbox_select_style',
227  'caption' => _("Selection List Style"),
228  'type' => SMOPT_TYPE_STRLIST,
229  'refresh' => SMOPT_REFRESH_NONE,
230  'posvals' => array( 0 => _("Long:") . ' "' . _("Folder") . $delim . _("Subfolder") . '"',
231  1 => _("Indented:") . ' "&nbsp;&nbsp;&nbsp;&nbsp;' . _("Subfolder") . '"',
232  2 => _("Delimited:") . ' ".&nbsp;' . _("Subfolder") . '"'),
233  'htmlencoded' => true
234  );
235 
236  /* Assemble all this together and return it as our result. */
237  $result = array(
238  'grps' => $optgrps,
239  'vals' => $optvals
240  );
242  return ($result);
243 }
244 
245 /******************************************************************/
247 /******************************************************************/
248 
254 function save_option_trash_folder($option) {
255  global $data_dir, $username;
256 
257  if (strtolower($option->new_value)=='inbox') {
258  // make sure that it is not INBOX
259  error_option_save(_("You can't select INBOX as Trash folder."));
260  } else {
261  /* Set move to trash on or off. */
262  $trash_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
263  setPref($data_dir, $username, 'move_to_trash', $trash_on);
264 
265  /* Now just save the option as normal. */
266  save_option($option);
267  }
268 }
269 
275 function save_option_sent_folder($option) {
276  global $data_dir, $username;
277 
278  if (strtolower($option->new_value)=='inbox') {
279  // make sure that it is not INBOX
280  error_option_save(_("You can't select INBOX as Sent folder."));
281  } else {
282  /* Set move to sent on or off. */
283  $sent_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
284  setPref($data_dir, $username, 'move_to_sent', $sent_on);
285 
286  /* Now just save the option as normal. */
287  save_option($option);
288  }
289 }
290 
296 function save_option_draft_folder($option) {
297  global $data_dir, $username;
298 
299  if (strtolower($option->new_value)=='inbox') {
300  // make sure that it is not INBOX
301  error_option_save(_("You can't select INBOX as Draft folder."));
302  } else {
303  /* Set move to draft on or off. */
304  $draft_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
305  setPref($data_dir, $username, 'save_as_draft', $draft_on);
306 
307  /* Now just save the option as normal. */
308  save_option($option);
309  }
310 }
311 
$imapConnection
$imapConnection
Definition: message_details_bottom.php:74
$imapServerAddress
$imapServerAddress
Definition: config_default.php:202
sqimap_login
sqimap_login($username, $password, $imap_server_address, $imap_port, $hide)
Definition: imap_general.php:481
$data_dir
$data_dir
Definition: config_default.php:499
save_option_trash_folder
save_option_trash_folder($option)
Definition: folder.php:254
setPref
setPref($data_dir, $username, $string, $set_to)
Definition: db_prefs.php:352
SMOPT_REFRESH_FOLDERLIST
const SMOPT_REFRESH_FOLDERLIST
Definition: options.php:45
SMPREF_UNSEEN_NONE
const SMPREF_UNSEEN_NONE
Definition: constants.php:39
$username
global $username
Definition: validate.php:55
$show_prefix_option
$show_prefix_option
Definition: config_default.php:352
SMPREF_UNSEEN_ONLY
const SMPREF_UNSEEN_ONLY
Definition: constants.php:44
save_option_draft_folder
save_option_draft_folder($option)
Definition: folder.php:296
$boxes
$boxes
Definition: empty_trash.php:49
SMPREF_LOC_LEFT
const SMPREF_LOC_LEFT
Definition: constants.php:35
error_option_save
error_option_save($message)
Definition: display_messages.php:165
sqimap_logout
sqimap_logout($imap_stream)
Definition: imap_general.php:639
SMPREF_UNSEEN_ALL
const SMPREF_UNSEEN_ALL
Definition: constants.php:41
SMOPT_REFRESH_ALL
const SMOPT_REFRESH_ALL
Definition: options.php:46
SMPREF_NONE
const SMPREF_NONE
Definition: constants.php:29
$folder_prefix
$folder_prefix
Definition: load_prefs.php:103
SMOPT_TYPE_STRING
const SMOPT_TYPE_STRING
Definition: options.php:20
SMPREF_TIME_24HR
const SMPREF_TIME_24HR
Definition: constants.php:48
SMPREF_UNSEEN_TOTAL
const SMPREF_UNSEEN_TOTAL
Definition: constants.php:45
SMPREF_OFF
const SMPREF_OFF
Definition: constants.php:26
$left_size_values
$left_size_values
Definition: defines.php:45
SM_PATH
const SM_PATH
Definition: decrypt_headers.php:16
SMOPT_GRP_SPCFOLDER
const SMOPT_GRP_SPCFOLDER
Definition: folder.php:19
_
_($str)
Definition: gettext.php:160
SMPREF_UNSEEN_INBOX
const SMPREF_UNSEEN_INBOX
Definition: constants.php:40
SMOPT_REFRESH_NONE
const SMOPT_REFRESH_NONE
Definition: options.php:44
SMOPT_GRP_FOLDERSELECT
const SMOPT_GRP_FOLDERSELECT
Definition: folder.php:21
SMOPT_TYPE_STRLIST
const SMOPT_TYPE_STRLIST
Definition: options.php:21
SMOPT_SIZE_LARGE
const SMOPT_SIZE_LARGE
Definition: options.php:52
$imapPort
$imapPort
Definition: config_default.php:210
save_option_sent_folder
save_option_sent_folder($option)
Definition: folder.php:275
SMOPT_GRP_FOLDERLIST
const SMOPT_GRP_FOLDERLIST
Definition: folder.php:20
SMOPT_TYPE_BOOLEAN
const SMOPT_TYPE_BOOLEAN
Definition: options.php:25
SMPREF_TIME_12HR
const SMPREF_TIME_12HR
Definition: constants.php:49
save_option
save_option($option)
Definition: options.php:847
SMOPT_TYPE_FLDRLIST
const SMOPT_TYPE_FLDRLIST
Definition: options.php:28
SMPREF_ON
const SMPREF_ON
Definition: constants.php:28
sqimap_get_delimiter
sqimap_get_delimiter($imap_stream=false)
Definition: imap_general.php:681
$default_folder_prefix
$default_folder_prefix
Definition: config_default.php:342
sqimap_mailbox_list
sqimap_mailbox_list($imap_stream, $force=false)
Definition: imap_mailbox.php:597
load_optpage_data_folder
load_optpage_data_folder()
Definition: folder.php:36
SMPREF_LOC_RIGHT
const SMPREF_LOC_RIGHT
Definition: constants.php:36