Added images used for $advanced_tree=true in src/left_main.php
[squirrelmail.git] / src / left_main.php
index 042abd0f03160def403030e0755562d92cd763a5..b986093ccaf4706aa89851fd8d79ee4e6ee56e8c 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));
         }
     }
 
@@ -175,6 +178,10 @@ function create_collapse_link($boxnum) {
     }
     $link .= '</a>';
 
+    $hooklink = do_hook_function('create_collapse_link',$link);
+    if ($hooklink != '')
+        $link = $hooklink;
+
     /* Return the finished product. */
     return ($link);
 }
@@ -285,6 +292,7 @@ function listBoxes ($boxes, $j=0 ) {
     $collapse = false;
     $unseen_type = 1;
     $unseen_notify = 0;
+    $unseen = 0;
 
     /* Get unseen/total display prefs */
     $unseen_type = getPref( $data_dir , $username , 'unseen_type' );
@@ -292,37 +300,48 @@ 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) {
-            $unseen = $boxes->unseen;
-            $unseen_string = "($unseen)";
-            if ($unseen>0) {
-                $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;
+        /* Only need to display info when option is set */
+        if (isset($unseen_notify) && ($unseen_notify > 1)) {
+                    
+            if ($boxes->unseen !== false) {
+                $unseen = $boxes->unseen; 
+            } else {        
+                $unseen = 0;
+            }   
+        
+            /* 
+                Should only display unseen info if the folder is inbox
+                or you set the option for all folders
+            */
+
+            if ((strtolower($mailbox) == 'inbox') || ($unseen_notify == 3)) {
+                $unseen_string = $unseen;
+                        
+
+                /* If users requests, display message count too */
+                if (isset($unseen_type) && ($unseen_type == 2)) {
+                    $numMessages = $boxes->total;
+                    $unseen_string .= '/' . $numMessages;
+                }       
                 
-                if ($unseen_type > 1) {
-                    $unseen_string .= '/' . $boxes->total;
+                $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>";
+            
+                /*
+                    Finally allow the script to display the values by setting a boolean.
+                    This can only occur if the unseen count is great than 0 (if you have
+                    unseen count only), or you have the message count too.
+                */
+                if (($unseen > 0) || (isset($unseen_type) && ($unseen_type ==2))) {
+                    $unseen_found = true;
                 }
-
-                $unseen_string .= ')';
-
-                $unseen_string = $unseen_before . $unseen_string . $unseen_after;
-            }
-
-        } else {
-            $unseen = 0;
+        
+            }   
+        
         }
 
         if (isset($boxes->mbxs[0]) && $collapse_folders) {
@@ -331,37 +350,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>';
                 }
@@ -374,7 +386,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>';
                 }
@@ -398,10 +410,12 @@ function listBoxes ($boxes, $j=0 ) {
             $fontend = "</font>";
         }
         $end .= '</nobr>';
+
         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);
@@ -420,21 +434,51 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) {
     $pre = '';
     $end = '';
     $collapse = false;
+    $unseen_found = false;
+    $unseen = 0;
 
     if ($boxes) {
     $mailbox = $boxes->mailboxname_full;
     $mailboxURL = urlencode($mailbox);
 
-    /* get unseen/total messages information */
-        if ($boxes->unseen) {
-        $unseen = $boxes->unseen;
-            $unseen_string = "($unseen)";
-        if ($unseen>0) $unseen_found = TRUE;
-            if ($boxes->total) {
-        $numMessages = $boxes->total;
-            $unseen_string = "<font color=\"$color[11]\">($unseen/$numMessages)</font>";
+    /* Only need to display info when option is set */
+    if (isset($unseen_notify) && ($unseen_notify > 1)) {
+
+        if ($boxes->unseen !== false) {
+            $unseen = $boxes->unseen;
+        } else {
+            $unseen = 0;
         }
-    } else $unseen = 0;
+
+        /* 
+            Should only display unseen info if the folder is inbox
+            or you set the option for all folders
+        */
+
+        if ((strtolower($mailbox) == 'inbox') || ($unseen_notify == 3)) {
+            $unseen_string = $unseen;
+
+
+            /* If users requests, display message count too */
+            if (isset($unseen_type) && ($unseen_type == 2)) {
+                $numMessages = $boxes->total;
+                $unseen_string .= '/' . $numMessages;
+            }
+
+            $unseen_string = "<font color=\"$color[11]\">($unseen_string)</font>";
+
+            /*
+                Finally allow the script to display the values by setting a boolean.
+                This can only occur if the unseen count is great than 0 (if you have
+                unseen count only), or you have the message count too.
+            */
+            if (($unseen > 0) || (isset($unseen_type) && ($unseen_type ==2))) {
+                $unseen_found = true;
+            }
+        
+        }   
+        
+    }
 
     /* If there are unseen message, bold the line. */
     if ($unseen > 0) { $pre .= '<b>'; }
@@ -587,7 +631,7 @@ if (isset($left_refresh) && ($left_refresh != '') &&
  **/
 
 $advanced_tree = false; /* set this to true if you want to see a nicer mailboxtree */
-$oldway = false; /* default SM behaviour */
+$oldway = false;        /* default SM behaviour */
 
 if ($advanced_tree) {
 $xtra .= <<<ECHO
@@ -985,6 +1029,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 ... */