-function formatMailboxName($imapConnection, $box_array) {
-
- global $trash_folder, $color, $move_to_trash,
- $unseen_notify, $unseen_type, $use_special_folder_color;
- $real_box = $box_array['unformatted'];
- $mailbox = str_replace(' ','',$box_array['formatted']);
- $mailboxURL = urlencode($real_box);
-
- /* Strip down the mailbox name. */
- if (ereg("^( *)([^ ]*)$", $mailbox, $regs)) {
- $mailbox = $regs[2];
- }
- $unseen = 0;
- $status = array('','');
- if (($unseen_notify == 2 && $real_box == 'INBOX') ||
- $unseen_notify == 3) {
- $tmp_status = create_unseen_string($real_box, $box_array, $imapConnection, $unseen_type );
- if ($status !== false) {
- $status = $tmp_status;
- }
- }
- list($unseen_string, $unseen) = $status;
- $special_color = ($use_special_folder_color && isSpecialMailbox($real_box));
-
- /* Start off with a blank line. */
- $line = '';
-
- /* If there are unseen message, bold the line. */
- if ($unseen > 0) { $line .= '<b>'; }
-
- /* Create the link for this folder. */
- if ($status !== false) {
- $line .= '<a href="right_main.php?PG_SHOWALL=0&startMessage=1&mailbox='.
- $mailboxURL.'" target="right" style="text-decoration:none">';
- }
- if ($special_color) {
- $line .= "<font color=\"$color[11]\">";
- }
- if ( $mailbox == 'INBOX' ) {
- $line .= _("INBOX");
- } else {
- $line .= str_replace(array(' ','<','>'),array(' ','<','>'),$mailbox);
- }
- if ($special_color == TRUE)
- $line .= '</font>';
- if ($status !== false) {
- $line .= '</a>';
- }
-
- /* If there are unseen message, close bolding. */
- if ($unseen > 0) { $line .= "</b>"; }
-
- /* Print unseen information. */
- if ($unseen_string != '') {
- $line .= " <small>$unseen_string</small>";
- }
-
- /* If it's the trash folder, show a purge link when needed */
- if (($move_to_trash) && ($real_box == $trash_folder)) {
- if (! isset($numMessages)) {
- $numMessages = sqimap_get_num_messages($imapConnection, $real_box);
- }
-
- if (($numMessages > 0) or ($box_array['parent'] == 1)) {
- $urlMailbox = urlencode($real_box);
- $line .= "\n<small>\n" .
- ' [<a href="empty_trash.php">'._("Purge").'</a>]' .
- '</small>';
- }
- }
-
-
- // let plugins fiddle with end of line
- $line .= concat_hook_function('left_main_after_each_folder',
- array(isset($numMessages) ? $numMessages : '', $real_box, $imapConnection));
-
-
- /* Return the final product. */
- return ($line);
-}
-
-/**
- * Recursive function that computes the collapsed status and parent
- * (or not parent) status of this box, and the visiblity and collapsed
- * status and parent (or not parent) status for all children boxes.
- */
-function compute_folder_children(&$parbox, $boxcount) {
- global $boxes, $data_dir, $username, $collapse_folders;
- $nextbox = $parbox + 1;
-
- /* Retreive the name for the parent box. */
- $parbox_name = $boxes[$parbox]['unformatted'];
-
- /* 'Initialize' this parent box to childless. */
- $boxes[$parbox]['parent'] = FALSE;
-
- /* Compute the collapse status for this box. */
- if( isset($collapse_folders) && $collapse_folders ) {
- $collapse = getPref($data_dir, $username, 'collapse_folder_' . $parbox_name);
- $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse);
- } else {
- $collapse = SM_BOX_UNCOLLAPSED;
- }
- $boxes[$parbox]['collapse'] = $collapse;
-
- /* Otherwise, get the name of the next box. */
- if (isset($boxes[$nextbox]['unformatted'])) {
- $nextbox_name = $boxes[$nextbox]['unformatted'];
- } else {
- $nextbox_name = '';
- }
-
- /* Compute any children boxes for this box. */
- while (($nextbox < $boxcount) &&
- (is_parent_box($boxes[$nextbox]['unformatted'], $parbox_name))) {
-
- /* Note that this 'parent' box has at least one child. */
- $boxes[$parbox]['parent'] = TRUE;
-
- /* Compute the visiblity of this box. */
- $boxes[$nextbox]['visible'] = ($boxes[$parbox]['visible'] &&
- ($boxes[$parbox]['collapse'] != SM_BOX_COLLAPSED));
-
- /* Compute the visibility of any child boxes. */
- compute_folder_children($nextbox, $boxcount);
- }
-
- /* Set the parent box to the current next box. */
- $parbox = $nextbox;
-}
-
-/**
- * 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, $unseen_notify, $color, $use_icons, $icon_theme;
- $mailbox = urlencode($boxes[$boxnum]['unformatted']);
-
- /* Create the link for this collapse link. */
- $link = '<a target="left" style="text-decoration:none" ' .
- 'href="left_main.php?';
- if ($boxes[$boxnum]['collapse'] == SM_BOX_COLLAPSED) {
- if ($use_icons && $icon_theme != 'none') {
- $link .= "unfold=$mailbox\"><img src=\"" . SM_PATH . 'images/plus.png" border="0" height="7" width="7" />';
- } else {
- $link .= "unfold=$mailbox\">+";
- }
- } else {
- if ($use_icons && $icon_theme != 'none') {
- $link .= "fold=$mailbox\"><img src=\"" . SM_PATH . 'images/minus.png" border="0" height="7" width="7" />';
- } else {
- $link .= "fold=$mailbox\">-";
- }
- }
- $link .= '</a>';
-
- /* Return the finished product. */
- return ($link);
-}