$mailbox = $regs[2];
}
- $unseen = 0;
-
- if (($unseen_notify == 2 && $real_box == 'INBOX') ||
- $unseen_notify == 3) {
- $unseen = sqimap_unseen_messages($imapConnection, $real_box);
- if ($unseen_type == 1 && $unseen > 0) {
- $unseen_string = "($unseen)";
- $unseen_found = TRUE;
- } else if ($unseen_type == 2) {
- $numMessages = sqimap_get_num_messages($imapConnection, $real_box);
- $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
- $unseen_found = TRUE;
- }
- }
-
- $special_color = ($use_special_folder_color && isSpecialMailbox( $real_box ) );
+ list($unseen_string, $unseen) = create_unseen_string($real_box, $box_array, $imapConnection);
+ $special_color = ($use_special_folder_color && isSpecialMailbox($real_box));
/* Start off with a blank line. */
$line = '';
if ($unseen > 0) { $line .= "</B>"; }
/* Print unseen information. */
- if (isset($unseen_found) && $unseen_found) {
+ if ($unseen_string != '') {
$line .= " <SMALL>$unseen_string</SMALL>";
}
* currently appropriate.
*/
function create_collapse_link($boxnum) {
- global $boxes;
+ global $boxes, $imapConnection, $unseen_notify, $color;
$mailbox = urlencode($boxes[$boxnum]['unformatted']);
-
+
/* Create the link for this collapse link. */
$link = '<a target="left" style="text-decoration:none" ' .
'href="left_main.php?';
return ($link);
}
+/**
+ * create_unseen_string:
+ *
+ * Create unseen and total message count for both this folder and
+ * it's subfolders.
+ *
+ * @param string $boxName name of the current mailbox
+ * @param array $boxArray array for the current mailbox
+ * @param $imapConnection current imap connection in use
+ * @return array[0] unseen message string (for display)
+ * @return array[1] unseen message count
+ */
+function create_unseen_string($boxName, $boxArray, $imapConnection) {
+ global $boxes, $unseen_type, $color;
+
+ /* Initialize the return value. */
+ $result = array();
+
+ /* Initialize the counts for this folder. */
+ $boxUnseenCount = 0;
+ $boxMessageCount = 0;
+ $totalUnseenCount = 0;
+ $totalMessageCount = 0;
+
+ /* Collect the counts for this box alone. */
+ $boxUnseenCount = sqimap_unseen_messages($imapConnection, $boxName);
+ if ($unseen_type == 2) {
+ $boxMessageCount = sqimap_get_num_messages($imapConnection, $boxName);
+ }
+
+ if ($boxArray['collapse'] == SM_BOX_COLLAPSED) {
+ /* Collect the counts for this boxes subfolders. */
+ $curBoxLength = strlen($boxName);
+ $boxCount = count($boxes);
+ for ($i = 0; $i < $boxCount; ++$i) {
+ /* Initialize the counts for this subfolder. */
+ $subUnseenCount = 0;
+ $subMessageCount = 0;
+
+ /* Collect the counts for this subfolder. */
+ if (($boxName != $boxes[$i]['unformatted'])
+ && (substr($boxes[$i]['unformatted'], 0, $curBoxLength) == $boxName)
+ && !in_array('noselect', $boxes[$i]['flags'])) {
+ $subUnseenCount = sqimap_unseen_messages($imapConnection, $boxes[$i]['unformatted']);
+ if ($unseen_type == 2) {
+ $subMessageCount = sqimap_get_num_messages($imapConnection, $boxes[$i]['unformatted']);
+ }
+ }
+
+ /* Add the counts for this subfolder to the total. */
+ $totalUnseenCount += $subUnseenCount;
+ $totalMessageCount += $subMessageCount;
+ }
+ }
+
+ /* And create the magic unseen count string. */
+ /* Really a lot more then just the unseen count. */
+ if (($unseen_type == 1) && ($boxUnseenCount > 0)) {
+ if ($totalUnseenCount == 0) {
+ $result[0] = "($boxUnseenCount)";
+ } else {
+ $result[0] = "($boxUnseenCount:$totalUnseenCount)";
+ }
+ } else if ($unseen_type == 2) {
+ if ($totalMessageCount == 0) {
+ $result[0] = "($boxUnseenCount/$boxMessageCount)";
+ } else {
+ $result[0] = "($boxUnseenCount/$boxMessageCount"
+ . ' : '
+ . "$totalUnseenCount/$totalMessageCount)";
+ }
+ $result[0] = "<font color=\"$color[11]\">$result[0]</font>";
+ }
+
+ /* Decide on an unseen count to return to the outside world. */
+ $result[1] = $boxUnseenCount;
+ if ($boxArray['collapse'] == SM_BOX_COLLAPSED) {
+ $result[1] += $totalUnseenCount;
+ }
+
+ /* Return our happy result. */
+ return ($result);
+}
+
/**
* This simple function checks if a box is another box's parent.
*/
echo "\n<BODY BGCOLOR=\"$color[3]\" TEXT=\"$color[6]\" LINK=\"$color[6]\" VLINK=\"$color[6]\" ALINK=\"$color[6]\">\n";
do_hook('left_main_before');
-if ($advanced_tree && $advanced_tree_frame_ctrl) {
+if ($advanced_tree) {
/* nice future feature, needs layout !! volunteers? */
$right_pos = $left_size - 20;
echo '<div style="position:absolute;top:0;border=solid;border-width:0.1em;border-color:blue;"><div ID="hidef" style="width=20;font-size:12"><A HREF="javascript:hideframe(true)"><b><<</b></a></div>';