/**
** 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");
include("../functions/mailbox.php");
function formatMailboxName($imapConnection, $mailbox, $delimeter, $color) {
require ("../config/config.php");
$mailboxURL = urlencode($mailbox);
selectMailbox($imapConnection, $mailbox, $numNessages);
$unseen = unseenMessages($imapConnection, $numUnseen);
echo "";
if ($unseen)
$line .= "";
$special_color = false;
for ($i = 0; $i < count($special_folders); $i++) {
if (($special_folders[$i] == $mailbox) && ($use_special_folder_color == true))
$special_color = true;
}
if ($special_color == true) {
$line .= "";
$line .= readShortMailboxName($mailbox, $delimeter);
$line .= "";
} else {
$line .= "";
$line .= readShortMailboxName($mailbox, $delimeter);
$line .= "";
}
if ($unseen)
$line .= "";
if ($numUnseen > 0) {
$line .= " ($numUnseen)";
}
if (($move_to_trash == true) && (trim($mailbox) == $trash_folder)) {
$urlMailbox = urlencode($mailbox);
$line .= "";
$line .= " (empty)";
$line .= "\n";
}
echo "";
return $line;
}
// open a connection on the imap port (143)
$imapConnection = loginToImapServer($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");
echo "
";
echo "";
getFolderList($imapConnection, $boxes);
echo "";
echo "Folders
";
echo "(refresh folder list)
";
echo "\n";
$delimeter = findMailboxDelimeter($imapConnection);
for ($i = 0;$i < count($boxes); $i++) {
$mailbox = $boxes[$i]["UNFORMATTED"];
$boxFlags = getMailboxFlags($boxes[$i]["RAW"]);
$boxCount = countCharInString($mailbox, $delimeter);
$line = "";
// indent the correct number of spaces.
for ($j = 0;$j < $boxCount;$j++)
$line .= " ";
if (trim($boxFlags[0]) != "") {
$noselect = false;
for ($h = 0; $h < count($boxFlags); $h++) {
if (strtolower($boxFlags[$h]) == "noselect")
$noselect = true;
}
if ($noselect == true) {
$line .= "";
$line .= readShortMailboxName($mailbox, $delimeter);
$line .= "";
} else {
$line .= formatMailboxName($imapConnection, $mailbox, $delimeter, $color);
}
} else {
$line .= formatMailboxName($imapConnection, $mailbox, $delimeter, $color);
}
echo "$line
";
}
echo "";
fclose($imapConnection);
?>