/**
** left_main.php
**
** This is the code for the left bar. The left bar shows the folders
** available, and has cookie information.
**
**/
if(!isset($username)) {
echo "You need a valid user and password to access this page!";
exit;
}
?>
include("../config/config.php");
include("../functions/array.php");
include("../functions/strings.php");
include("../functions/imap.php");
function formatMailboxName($imapConnection, $mailbox, $real_box, $delimeter, $color, $move_to_trash) {
require ("../config/config.php");
$mailboxURL = urlencode($real_box);
sqimap_mailbox_select ($imapConnection, $real_box);
$unseen = sqimap_unseen_messages($imapConnection, $numUnseen);
echo "";
if ($unseen)
$line .= "";
$special_color = false;
for ($i = 0; $i < count($special_folders); $i++) {
if (($special_folders[$i] == $real_box) && ($use_special_folder_color == true))
$special_color = true;
}
if ($special_color == true) {
$line .= "";
$line .= replace_spaces($mailbox);
$line .= "";
} else {
$line .= "";
$line .= replace_spaces($mailbox);
$line .= "";
}
if ($unseen)
$line .= "";
if ($numUnseen > 0) {
$line .= " ($numUnseen)";
}
if (($move_to_trash == true) && (trim($real_box) == $trash_folder)) {
$urlMailbox = urlencode($real_box);
$line .= "";
$line .= " (empty me)";
$line .= "\n";
}
echo "";
return $line;
}
// open a connection on the imap port (143)
$imapConnection = sqimap_login($username, $key, $imapServerAddress, 10); // the 10 is to hide the output
/** If it was a successful login, lets load their preferences **/
include("../src/load_prefs.php");
if (isset($left_refresh) && ($left_refresh != "None") && ($left_refresh != "")) {
echo "";
echo "";
echo "";
}
echo "
";
echo "";
$boxes = sqimap_mailbox_list($imapConnection);
echo "";
echo _("Folders") . "
";
echo "(";
echo _("refresh folder list");
echo ")
";
echo "\n";
$delimeter = sqimap_get_delimiter($imapConnection);
for ($i = 0;$i < count($boxes); $i++) {
$line = "";
$mailbox = $boxes[$i]["formatted"];
if ($boxes[$i]["flags"]) {
$noselect = false;
for ($h = 0; $h < count($boxes[$i]["flags"]); $h++) {
if (strtolower($boxes[$i]["flags"][$h]) == "noselect")
$noselect = true;
}
if ($noselect == true) {
$line .= "";
$line .= replace_spaces(readShortMailboxName($mailbox, $delimeter));
$line .= "";
} else {
$line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $color, $move_to_trash);
}
} else {
$line .= formatMailboxName($imapConnection, $mailbox, $boxes[$i]["unformatted"], $delimeter, $color, $move_to_trash);
}
echo "$line
";
}
echo "";
fclose($imapConnection);
?>