put Tyler's collapsable folder listing back in
[squirrelmail.git] / src / left_main.php
index 86b7385b566840dcb891f703e835eeadc2266625..0adbd3a7cfc141adc4420c7f31ae7b018603be10 100644 (file)
 
    if(!isset($username)) {
       set_up_language($squirrelmail_language, true);
-         include ("../themes/default_theme.php");
-         printf('<html><BODY TEXT="%s" BGCOLOR="%s" LINK="%s" VLINK="%s" ALINK="%s">',
-                         $color[8], $color[4], $color[7], $color[7], $color[7]);
-         echo "</body></html>";
+          include ("../themes/default_theme.php");
+          printf('<html><BODY TEXT="%s" BGCOLOR="%s" LINK="%s" VLINK="%s" ALINK="%s">',
+                          $color[8], $color[4], $color[7], $color[7], $color[7]);
+          echo "</body></html>";
       exit;
    }
 
@@ -61,7 +61,7 @@
       
       if (($unseen_notify == 2 && $real_box == "INBOX") ||
           $unseen_notify == 3) {
-        $unseen = sqimap_unseen_messages($imapConnection, $numUnseen, $real_box);
+         $unseen = sqimap_unseen_messages($imapConnection, $numUnseen, $real_box);
          if ($unseen_type == 1 && $unseen > 0) {
             $unseen_string = "($unseen)";
             $unseen_found = true;
       
       $special_color = false;
       if ((strtolower($real_box) == "inbox") ||
-         (($real_box == $trash_folder) && ($move_to_trash)) ||
-         (($real_box == $sent_folder) && ($move_to_sent)))
-        $special_color = true;
-        
+          (($real_box == $trash_folder) && ($move_to_trash)) ||
+          (($real_box == $sent_folder) && ($move_to_sent)))
+         $special_color = true;
+         
       $spaces = '';
       $line = "<NOBR>";
-      if (ereg("^( *)([^ ]*)$", $mailbox, $regs))
-      {
+      if (ereg("^( *)([^ ]*)$", $mailbox, $regs)) {
           $spaces = $regs[1];
-         $mailbox = $regs[2];
+          $mailbox = $regs[2];
       }
       
       if ($unseen > 0)
           $line .= "<B>";
       $line .= str_replace(' ', '&nbsp;', $spaces);
       
-      if ($collapse_folders)
-      {
+      if ($collapse_folders) {
          if (isset($box_array['parent']))
-           $line .= FoldLink($box_array['unformatted'], $box_array['parent']);
+            $line .= FoldLink($box_array['unformatted'], $box_array['parent']);
          else
             $line .= '<tt>&nbsp;</tt>&nbsp;';
       }
-         
+          
       $line .= "<a href=\"right_main.php?sort=0&startMessage=1&mailbox=$mailboxURL\" target=\"right\" style=\"text-decoration:none\">";
       if ($special_color == true)
          $line .= "<FONT COLOR=\"$color[11]\">";
    echo "</A>)</small></CENTER><BR>";
    $delimeter = sqimap_get_delimiter($imapConnection);
 
-   if ($collapse_folders)
-   {
+   if (isset($collapse_folders) && $collapse_folders) {
       if (isset($fold))
          setPref($data_dir, $username, 'collapse_folder_' . $fold, 1);
       if (isset($unfold))
          setPref($data_dir, $username, 'collapse_folder_' . $unfold, 0);
       $IAmAParent = array();
-      for ($i = 0; $i < count($boxes); $i ++)
-      {
+      for ($i = 0; $i < count($boxes); $i ++) {
           $parts = explode($delimeter, $boxes[$i]['unformatted']);
-         $box_name = array_pop($parts);
-         $box_parent = implode($delimeter, $parts);
-         $hidden = 0;
-         if (isset($box_parent))
-         {
-             $hidden = getPref($data_dir, $username, 
-                 'collapse_folder_' . $box_parent);
-             $IAmAParent[$box_parent] = $hidden;
-         }
-         $boxes[$i]['folded'] = $hidden;
+          $box_name = array_pop($parts);
+          $box_parent = implode($delimeter, $parts);
+          $hidden = 0;
+          if (isset($box_parent)) {
+              $hidden = getPref($data_dir, $username, 
+                  'collapse_folder_' . $box_parent);
+              $IAmAParent[$box_parent] = $hidden;
+          }
+          $boxes[$i]['folded'] = $hidden;
       }
    }
 
          $line = "";
          $mailbox = $boxes[$i]["formatted"];
 
-         if ($collapse_folders && 
-            isset($IAmAParent[$boxes[$i]['unformatted']]))
-         {
-           $boxes[$i]['parent'] = $IAmAParent[$boxes[$i]['unformatted']];
+         if (isset($collapse_folders) && $collapse_folders && isset($IAmAParent[$boxes[$i]['unformatted']])) {
+            $boxes[$i]['parent'] = $IAmAParent[$boxes[$i]['unformatted']];
          }
 
          if (in_array('noselect', $boxes[$i]['flags'])) {
             $line .= "<FONT COLOR=\"$color[10]\">";
-           if (ereg("^( *)([^ ]*)$", $mailbox, $regs))
-           {
-               $line .= str_replace(' ', '&nbsp;', $regs[1]);
-               if (isset($boxes[$i]['parent']))
-                   $line .= FoldLink($boxes[$i]['unformatted'], 
-                       $boxes[$i]['parent']);
-               else
-                   $line .= '<tt>&nbsp;</tt>&nbsp;';
-               $line .= str_replace(' ', '&nbsp;', $regs[2]);
-           }
+            if (ereg("^( *)([^ ]*)$", $mailbox, $regs)) {
+                $line .= str_replace(' ', '&nbsp;', $regs[1]);
+                if (isset($boxes[$i]['parent']))
+                    $line .= FoldLink($boxes[$i]['unformatted'], 
+                        $boxes[$i]['parent']);
+                elseif ($collapse_folders)
+                    $line .= '<tt>&nbsp;</tt>&nbsp;';
+                $line .= str_replace(' ', '&nbsp;', $regs[2]);
+            }
             $line .= '</FONT>';
          } else {
             $line .= formatMailboxName($imapConnection, $boxes[$i], $delimeter);
    sqimap_logout($imapConnection);
    do_hook("left_main_after");
 
-
-
-   function FoldLink($mailbox, $folded)
-   {
+   function FoldLink($mailbox, $folded) {
        $mailbox = urlencode($mailbox);
        echo '<tt><a target="left" style="text-decoration:none" ';
        echo 'href="left_main.php?';