Apparently my fix for hiding the unread count of 0 when in certain modes
[squirrelmail.git] / src / left_main.php
index aaa90f1cc571a92ca61f83d2cad1fb697550498a..cdb23354fdb8bc4cf53f1c3d9d241548b1f81f6e 100644 (file)
@@ -99,6 +99,9 @@ function formatMailboxName($imapConnection, $box_array) {
             $line .= "\n<small>\n" .
                     "&nbsp;&nbsp;(<A HREF=\"empty_trash.php\" style=\"text-decoration:none\">"._("purge")."</A>)" .
                     "</small>";
+        } else {
+          $line .= concat_hook_function('left_main_after_each_folder',
+                 array(isset($numMessages) ? $numMessages : '',$real_box,$imapConnection));
         }
     }
 
@@ -292,35 +295,27 @@ function listBoxes ($boxes, $j=0 ) {
 
     if (isset($boxes) && !empty($boxes)) {
         $mailbox = $boxes->mailboxname_full;
-        $leader = '';
-        for ($k = 0; $k < $j; $k++) {
-            $leader.= '&nbsp;&nbsp;&nbsp;';
-        }
+        $leader = '<tt>';
+        $leader .= str_repeat('&nbsp;&nbsp;',$j);
         $mailboxURL = urlencode($mailbox);
-
         /* get unseen/total messages information */
-        if ($boxes->unseen) {
+        if ($boxes->unseen !== false || $boxes->total !== false) {
             $unseen = $boxes->unseen;
-            $unseen_string = "($unseen)";
-            if ($unseen>0) {
+            if ($unseen>0 || $boxes->total>0) {
+                $unseen_string = "($unseen)";
                 $unseen_found = TRUE;
             }
-
             $unseen_before = '<font color="' . $color[11] . '">';
             $unseen_after = '</font>';
-
             if ((($unseen_notify == 2) && (strtolower($mailbox) == 'inbox')) || ($unseen_notify == 3)) {
                 $unseen_string = '(' . $unseen;
-                
+        
                 if ($unseen_type > 1) {
                     $unseen_string .= '/' . $boxes->total;
                 }
-
                 $unseen_string .= ')';
-
                 $unseen_string = $unseen_before . $unseen_string . $unseen_after;
             }
-
         } else {
             $unseen = 0;
         }
@@ -331,36 +326,30 @@ function listBoxes ($boxes, $j=0 ) {
 
             $link = '<a target="left" style="text-decoration:none" ' .'href="left_main.php?';
             if ($collapse) {
-                $link .= "unfold=$mailboxURL\">$leader +&nbsp;";
+                $link .= "unfold=$mailboxURL\">$leader+&nbsp;</tt>";
             } else {
-                $link .= "fold=$mailboxURL\">$leader -&nbsp;";
+                $link .= "fold=$mailboxURL\">$leader-&nbsp;</tt>";
             }
             $link .= '</a>';
             $pre .= $link;
         } else {
-            $pre.= $leader . '&nbsp;&nbsp;&nbsp;';
+            $pre.= $leader . '&nbsp;&nbsp;</tt>';
         }
 
         /* If there are unseen message, bold the line. */
-
         if (($move_to_trash) && ($mailbox == $trash_folder)) {
-            if (! isset($numMessages)) {
-                $status = sqimap_status_messages($imapConnection, $mailbox);
-                $numMessages = $status['MESSAGES'];
+            if (! isset($boxes->total)) {
+                $boxes->total = sqimap_status_messages($imapConnection, $mailbox);
             }
-
             if ($unseen > 0) {
                 $pre .= '<b>';
             }
-
             $pre .= "<a href=\"right_main.php?PG_SHOWALL=0&amp;sort=0;startMessage=1&amp;mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
-
             if ($unseen > 0) {
                 $end .= '</b>';
             }
-
             $end .= '</a>';
-            if ($numMessages > 0) {
+            if ($boxes->total > 0) {
                 if ($unseen > 0) {
                     $pre .= '<b>';
                 }
@@ -373,7 +362,7 @@ function listBoxes ($boxes, $j=0 ) {
                         "</small>";
             }
         } else {
-            if (!$boxes->is_noselect) {
+            if (!$boxes->is_noselect || strtolower($boxes->mailboxname_full)=="inbox") {
                 if ($unseen > 0) {
                     $pre .= '<b>';
                 }
@@ -386,7 +375,7 @@ function listBoxes ($boxes, $j=0 ) {
         }
 
         /* Print unseen information. */
-        if (isset($unseen_found) && $unseen_found) {
+        if (isset($unseen_found) && $unseen_found && ($unseen > 0)) {
             $end .= "&nbsp;<small>$unseen_string</small>";
         }
 
@@ -397,10 +386,12 @@ function listBoxes ($boxes, $j=0 ) {
             $fontend = "</font>";
         }
         $end .= '</nobr>';
-        
-        echo "" . $pre .$font. $boxes->mailboxname_sub .$fontend . $end. '<br />' . "\n";
-        $j++;
-        
+
+        if (!$boxes->is_root) {
+            echo "" . $pre .$font. $boxes->mailboxname_sub .$fontend . $end. '<br />' . "\n";
+            $j++;
+        }
+
         if (!$collapse || $boxes->is_root) {
             for ($i = 0; $i <count($boxes->mbxs); $i++) {
                 listBoxes($boxes->mbxs[$i],$j);
@@ -425,12 +416,14 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
     $mailboxURL = urlencode($mailbox);
 
     /* get unseen/total messages information */
-        if ($boxes->unseen) {
+    if ($boxes->unseen !== false) {
         $unseen = $boxes->unseen;
+        if ($unseen>0) {
+            $unseen_found = TRUE;
             $unseen_string = "($unseen)";
-        if ($unseen>0) $unseen_found = TRUE;
-            if ($boxes->total) {
-        $numMessages = $boxes->total;
+        }
+        if ($boxes->total) {
+            $numMessages = $boxes->total;
             $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
         }
     } else $unseen = 0;
@@ -448,7 +441,7 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
     if ($unseen > 0) { $end .= '</b>'; }
 
     /* Print unseen information. */
-    if (isset($unseen_found) && $unseen_found) {
+    if (isset($unseen_found) && $unseen_found && ($unseen > 0)) {
             $end .= "&nbsp;$unseen_string";
     }
 
@@ -984,6 +977,7 @@ for ($i = 0; $i < count($boxes); $i++) {
         echo '</div></small>'."\n";
         echo '</form>'."\n";
     } else {
+        //sqimap_get_status_mbx_tree($imap_stream,$boxes)    
         ListBoxes($boxes);
     }
 } /* if ($oldway) else ... */