+ /* Lastly, display the folder list. */
+ if (isset($collapse_folders) && $collapse_folders) {
+ /* If directed, collapse or uncollapse a folder. */
+ if (isset($fold)) {
+ setPref($data_dir, $username, 'collapse_folder_' . $fold, SM_BOX_COLLAPSED);
+ } else if (isset($unfold)) {
+ setPref($data_dir, $username, 'collapse_folder_' . $unfold, $SM_BOX_UNCOLLAPSED);
+ }
+ }
+
+ /* Prepare do do out collapsedness and visibility computation. */
+ $curbox = 0;
+ $boxcount = count($boxes);
+
+ /* Compute the collapsedness and visibility of each box. */
+ while ($curbox < $boxcount) {
+ $boxes[$curbox]['visible'] = true;
+ compute_folder_children($curbox, $boxcount);
+ }
+
+ for ($i = 0;$i < count($boxes); $i++) {
+ if ($boxes[$i]['visible'] == true) {
+ $mailbox = $boxes[$i]['formatted'];
+ $mblevel = substr_count($boxes[$i]['unformatted'], $delimeter) + 1;
+
+ /* Create the prefix for the folder name and link. */
+ $prefix = str_repeat(' ',$mblevel);
+ if (isset($collapse_folders) && $collapse_folders && $boxes[$i]['parent']) {
+ $prefix = str_replace(' ',' ',substr($prefix,0,strlen($prefix)-2));
+ $prefix .= create_collapse_link($i) . ' ';
+ } else {
+ $prefix = str_replace(' ',' ',$prefix);
+ }
+ $line = "<NOBR><TT>$prefix</TT>";
+
+ /* Add the folder name and link. */
+ if (in_array('noselect', $boxes[$i]['flags'])) {
+ $line .= "<FONT COLOR=\"$color[10]\">";
+ if (ereg("^( *)([^ ]*)", $mailbox, $regs)) {
+ $mailbox = str_replace(' ','',$mailbox);
+ $line .= str_replace(' ', ' ', $mailbox);
+ }
+ $line .= '</FONT>';
+ } else {
+ $line .= formatMailboxName($imapConnection, $boxes[$i], $delimeter);
+ }
+
+ /* Put the final touches on our folder line. */
+ $line .= "</NOBR><BR>\n";
+
+ /* Output the line for this folder. */
+ echo $line;
+ }
+ }
+ sqimap_logout($imapConnection);
+ do_hook("left_main_after");
+
+ /**
+ * Create the link for a parent folder that will allow that
+ * parent folder to either be collapsed or expaned, as is
+ * currently appropriate.
+ */
+ function create_collapse_link($boxnum) {
+ global $boxes;
+ $mailbox = urlencode($boxes[$boxnum]['unformatted']);
+
+ /* Create the link for this collapse link. */
+ $link = '<a target="left" style="text-decoration:none" ';
+ $link .= 'href="left_main.php?';
+ if ($boxes[$boxnum]['collapse'] == SM_BOX_COLLAPSED) {
+ $link .= "unfold=$mailbox\">+";
+ } else {
+ $link .= "fold=$mailbox\">-";
+ }
+ $link .= '</a>';
+
+ /* Return the finished product. */
+ return ($link);
+ }