X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fleft_main.php;h=ee283722d0681cd3110d6edd9ed6430e1619cea6;hb=2d896bbf3b402d11c0be75a1a87b5705411efe87;hp=9d18c55126b780cfc2bc2402343b084b5517e3e9;hpb=8cd3f6dae1b23eeb8656604cf759d28663601e93;p=squirrelmail.git diff --git a/src/left_main.php b/src/left_main.php index 9d18c551..ee283722 100644 --- a/src/left_main.php +++ b/src/left_main.php @@ -1,338 +1,1119 @@ 0) { - $unseen_string = "($unseen)"; - $unseen_found = true; - } else if ($unseen_type == 2) { - $numMessages = sqimap_get_num_messages($imapConnection, $real_box); - $unseen_string = "($unseen/$numMessages)"; - $unseen_found = true; - } - } - - $special_color = false; - if ($use_special_folder_color) { - if ((strtolower($real_box) == 'inbox') - || (($real_box == $trash_folder) && ($move_to_trash)) - || (($real_box == $sent_folder) && ($move_to_sent)) - || (($real_box == $draft_folder) && ($save_as_draft))) { - $special_color = true; - } - } - - /* Start off with a blank line. */ - $line = ''; - - /* If there are unseen message, bold the line. */ - if ($unseen > 0) { $line .= ''; } - - /* Crate the link for this folder. */ - $line .= ""; - if ($special_color == true) - $line .= ""; - $line .= str_replace(' ',' ',$mailbox); - if ($special_color == true) - $line .= ""; - $line .= ''; - - /* If there are unseen message, close bolding. */ - if ($unseen > 0) { $line .= ""; } - - /* Print unseen information. */ - if (isset($unseen_found) && $unseen_found) { - $line .= " $unseen_string"; - } +/* SquirrelMail required files. */ +require_once(SM_PATH . 'include/validate.php'); +require_once(SM_PATH . 'functions/imap.php'); +require_once(SM_PATH . 'functions/plugin.php'); +require_once(SM_PATH . 'functions/page_header.php'); +require_once(SM_PATH . 'functions/html.php'); +require_once(SM_PATH . 'functions/date.php'); + +/* These constants are used for folder stuff. */ +define('SM_BOX_UNCOLLAPSED', 0); +define('SM_BOX_COLLAPSED', 1); + +/* --------------------- FUNCTIONS ------------------------- */ + +function formatMailboxName($imapConnection, $box_array) { - if (($move_to_trash == true) && ($real_box == $trash_folder)) { - if (! isset($numMessages)) { + global $folder_prefix, $trash_folder, $sent_folder, + $color, $move_to_sent, $move_to_trash, + $unseen_notify, $unseen_type, $collapse_folders, + $draft_folder, $save_as_draft, + $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 .= ''; } + + /* Create the link for this folder. */ + if ($status !== false) { + $line .= ''; + } + if ($special_color) { + $line .= ""; + } + if ( $mailbox == 'INBOX' ) { + $line .= _("INBOX"); + } else { + $line .= str_replace(' ',' ',$mailbox); + } + if ($special_color == TRUE) + $line .= ''; + if ($status !== false) { + $line .= ''; + } + + /* If there are unseen message, close bolding. */ + if ($unseen > 0) { $line .= ""; } + + /* Print unseen information. */ + if ($unseen_string != '') { + $line .= " $unseen_string"; + } + + /* 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) { + if (($numMessages > 0) or ($box_array['parent'] == 1)) { $urlMailbox = urlencode($real_box); - $line .= "\n\n"; - $line .= " ("._("purge").")"; - $line .= "\n\n"; - } - } + $line .= "\n\n" . + " ("._("purge").")" . + ""; + } + } - /* Return the final product. */ - return ($line); - } - /**********************************/ - /* END OF FUNCTION - BACK TO MAIN */ - /**********************************/ + // 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']; - if (isset($left_refresh) && ($left_refresh != 'None') && ($left_refresh != '')) { - echo "\n"; - echo "\n"; - echo "\n"; + /* '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; } - - echo "\n
\n"; + $boxes[$parbox]['collapse'] = $collapse; - do_hook("left_main_before"); + /* Otherwise, get the name of the next box. */ + if (isset($boxes[$nextbox]['unformatted'])) { + $nextbox_name = $boxes[$nextbox]['unformatted']; + } else { + $nextbox_name = ''; + } - $boxes = sqimap_mailbox_list($imapConnection); + /* Compute any children boxes for this box. */ + while (($nextbox < $boxcount) && + (is_parent_box($boxes[$nextbox]['unformatted'], $parbox_name))) { - echo '