\n"; if ($seen == false) { echo " \n"; echo " $senderName\n"; echo "
$dateString
\n"; echo " $subject\n"; } else { echo " \n"; echo " $senderName\n"; echo "
$dateString
\n"; echo " $subject\n"; } echo "\n"; } /** ** This function loops through a group of messages in the mailbox and shows them **/ function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color) { include ("../config/config.php"); if ($numMessages >= 1) { for ($q = 0; $q < $numMessages; $q++) { sqimap_get_small_header ($imapConnection, $q+1, $f, $s, $d); $from[$q] = $f; $date[$q] = $d; $subject[$q] = $s; } $flags = sqimap_get_flags ($imapConnection, 1, $numMessages); } $j = 0; while ($j < $numMessages) { $date[$j] = ereg_replace(" ", " ", $date[$j]); $tmpdate = explode(" ", trim($date[$j])); $messages[$j]["TIME_STAMP"] = getTimeStamp($tmpdate); $messages[$j]["DATE_STRING"] = getDateString($messages[$j]["TIME_STAMP"]); $messages[$j]["ID"] = $j+1; $messages[$j]["FROM"] = decodeHeader($from[$j]); $messages[$j]["SUBJECT"] = decodeHeader($subject[$j]); $messages[$j]["FLAG_DELETED"] = false; $messages[$j]["FLAG_ANSWERED"] = false; $messages[$j]["FLAG_SEEN"] = false; $num = 0; while ($num < count($flags[$j])) { if ($flags[$j][$num] == "Deleted") { $messages[$j]["FLAG_DELETED"] = true; } else if ($flags[$j][$num] == "Answered") { $messages[$j]["FLAG_ANSWERED"] = true; } else if ($flags[$j][$num] == "Seen") { $messages[$j]["FLAG_SEEN"] = true; } $num++; } $j++; } /** Find and remove the ones that are deleted */ $i = 0; $j = 0; while ($j < $numMessages) { if ($messages[$j]["FLAG_DELETED"] == true) { $j++; continue; } $msgs[$i]["TIME_STAMP"] = $messages[$j]["TIME_STAMP"]; $msgs[$i]["DATE_STRING"] = $messages[$j]["DATE_STRING"]; $msgs[$i]["ID"] = $messages[$j]["ID"]; $msgs[$i]["FROM"] = $messages[$j]["FROM"]; $msgs[$i]["SUBJECT"] = $messages[$j]["SUBJECT"]; $msgs[$i]["FLAG_DELETED"] = $messages[$j]["FLAG_DELETED"]; $msgs[$i]["FLAG_ANSWERED"] = $messages[$j]["FLAG_ANSWERED"]; $msgs[$i]["FLAG_SEEN"] = $messages[$j]["FLAG_SEEN"]; $i++; $j++; } $numMessages = $i; // There's gotta be messages in the array for it to sort them. if ($numMessages > 0) { /** 0 = Date (up) 4 = Subject (up) ** 1 = Date (dn) 5 = Subject (dn) ** 2 = Name (up) ** 3 = Name (dn) **/ if ($sort == 0) $msgs = ary_sort($msgs, "TIME_STAMP", -1); else if ($sort == 1) $msgs = ary_sort($msgs, "TIME_STAMP", 1); else { $original = $msgs; $i = 0; while ($i < count($msgs)) { $msgs[$i]["FROM"] = strtolower($msgs[$i]["FROM"]); $msgs[$i]["SUBJECT"] = strtolower($msgs[$i]["SUBJECT"]); $i++; } if ($sort == 2) $msgs = ary_sort($msgs, "FROM", -1); else if ($sort == 3) $msgs = ary_sort($msgs, "FROM", 1); else if ($sort == 4) $msgs = ary_sort($msgs, "SUBJECT", -1); else if ($sort == 5) $msgs = ary_sort($msgs, "SUBJECT", 1); else $msgs = ary_sort($msgs, "TIME_STAMP", -1); $i = 0; while ($i < count($msgs)) { $j = 0; $loop = true; while ($j < count($original)) { if ($msgs[$i]["ID"] == $original[$j]["ID"]) { $msgs[$i]["FROM"] = $original[$j]["FROM"]; $msgs[$i]["SUBJECT"] = $original[$j]["SUBJECT"]; // exit out of this loop if we find the thing. $j = count($original) + 1; } $j++; } $i++; } } } if ($startMessage + 24 < $numMessages) { $endMessage = $startMessage + 24; } else { $endMessage = $numMessages; } $nextGroup = $startMessage + 25; $prevGroup = $startMessage - 25; $urlMailbox = urlencode($mailbox); /** This is the beginning of the message list table. It wraps around all messages */ echo ""; if ($startMessage < $endMessage) { echo "\n"; } else if ($startMessage == $endMessage) { echo "\"TD>"; echo "
". _("Viewing message ") ."$startMessage ($numMessages ". _("total") .")
\n"; echo "\n"; } echo "\n"; /** The delete and move options */ echo ""; echo "
"; echo "
". _("Viewing messages ") ."$startMessage". _(" to ") ."$endMessage ($numMessages total)
\n"; echo "
"; if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) { echo "". _("Previous") ."\n"; echo "". _("Next") ."\n"; } else if (($nextGroup > $numMessages) && ($prevGroup >= 0)) { echo "". _("Previous") ."\n"; echo "Next\n"; } else if (($nextGroup <= $numMessages) && ($prevGroup < 0)) { echo "Previous\n"; echo "". _("Next") ."\n"; } echo "
"; echo "\n\n\n
"; echo "\n"; echo " \n"; echo " \n"; echo " "; echo " \n"; echo "
\n"; echo " ". _("Move selected to:") .""; echo " "; echo " \n"; echo " \n"; echo "  ". _("checked messages") ."\n"; echo "
\n\n\n"; echo "
"; echo ""; echo ""; echo " "; /** FROM HEADER **/ echo " \n"; else if ($sort == 3) echo " \n"; else echo " \n"; /** DATE HEADER **/ echo " \n"; else if ($sort == 1) echo " \n"; else echo " \n"; /** SUBJECT HEADER **/ echo " \n"; else if ($sort == 5) echo " \n"; else echo " \n"; echo ""; // loop through and display the info for each message. $t = 0; // $t is used for the checkbox number if ($numMessages == 0) { // if there's no messages in this folder echo ""; } else if ($startMessage == $endMessage) { // if there's only one message in the box, handle it different. $i = $startMessage - 1; printMessageInfo($imapConnection, $t, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE_STRING"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"], $mailbox, $sort, $startMessage); } else { for ($i = $startMessage - 1;$i <= $endMessage - 1; $i++) { printMessageInfo($imapConnection, $t, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE_STRING"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"], $mailbox, $sort, $startMessage); $t++; } } echo "
 ". _("From") .""; if ($sort == 2) echo " ". _("Date") .""; if ($sort == 0) echo " ". _("Subject") ."\n"; if ($sort == 4) echo "

". _("THIS FOLDER IS EMPTY") ."
 
"; echo "
\n"; echo "\n"; echo ""; if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) { echo "" . _("Previous") . "\n"; echo "" . _("Next") . "\n"; } else if (($nextGroup > $numMessages) && ($prevGroup >= 0)) { echo "" . _("Previous") . "\n"; echo "" . _("Next") . "\n"; } else if (($nextGroup <= $numMessages) && ($prevGroup < 0)) { echo "Previous\n"; echo "" . _("Next") . "\n"; } echo ""; /** End of message-list table */ } ?>