X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fleft_main.php;h=b65d839332e077dcb4c2dec64d240b12ffb592d7;hb=8e7241121f714d9a08e1c8900d4ca274a7b22a9c;hp=ef74259e910af2c08ec5db80ea0bb2904a4f120f;hpb=1053f1e5c27e2fc3f3cacba2e24ecd1518927146;p=squirrelmail.git diff --git a/src/left_main.php b/src/left_main.php index ef74259e..b65d8393 100644 --- a/src/left_main.php +++ b/src/left_main.php @@ -3,7 +3,7 @@ /** * left_main.php * - * Copyright (c) 1999-2002 The SquirrelMail Project Team + * Copyright (c) 1999-2003 The SquirrelMail Project Team * Licensed under the GNU GPL. For full terms see the file COPYING. * * This is the code for the left bar. The left bar shows the folders @@ -12,12 +12,15 @@ * $Id$ */ -require_once('../src/validate.php'); -require_once('../functions/array.php'); -require_once('../functions/imap.php'); -require_once('../functions/plugin.php'); -require_once('../functions/page_header.php'); -require_once('../functions/html.php'); +/* Path for SquirrelMail required files. */ +define('SM_PATH','../'); + +/* 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'); /* These constants are used for folder stuff. */ define('SM_BOX_UNCOLLAPSED', 0); @@ -32,7 +35,6 @@ function formatMailboxName($imapConnection, $box_array) { $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); @@ -41,23 +43,17 @@ function formatMailboxName($imapConnection, $box_array) { if (ereg("^( *)([^ ]*)$", $mailbox, $regs)) { $mailbox = $regs[2]; } - $unseen = 0; - + $status = array('',''); if (($unseen_notify == 2 && $real_box == 'INBOX') || $unseen_notify == 3) { - $unseen = sqimap_unseen_messages($imapConnection, $real_box); - if ($unseen_type == 1 && $unseen > 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; - } + $tmp_status = create_unseen_string($real_box, $box_array, $imapConnection, $unseen_type ); + if ($status !== false) { + $status = $tmp_status; + } } - - $special_color = ($use_special_folder_color && isSpecialMailbox( $real_box ) ); + list($unseen_string, $unseen) = $status; + $special_color = ($use_special_folder_color && isSpecialMailbox($real_box)); /* Start off with a blank line. */ $line = ''; @@ -66,9 +62,10 @@ function formatMailboxName($imapConnection, $box_array) { if ($unseen > 0) { $line .= ''; } /* Create the link for this folder. */ - $line .= ''; - + if ($status !== false) { + $line .= ''; + } if ($special_color) { $line .= ""; } @@ -79,22 +76,25 @@ function formatMailboxName($imapConnection, $box_array) { } if ($special_color == TRUE) $line .= ''; - $line .= ''; + if ($status !== false) { + $line .= ''; + } /* If there are unseen message, close bolding. */ if ($unseen > 0) { $line .= ""; } /* Print unseen information. */ - if (isset($unseen_found) && $unseen_found) { + 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" . "  ("._("purge").")" . @@ -162,9 +162,9 @@ function compute_folder_children(&$parbox, $boxcount) { * currently appropriate. */ function create_collapse_link($boxnum) { - global $boxes; + global $boxes, $imapConnection, $unseen_notify, $color; $mailbox = urlencode($boxes[$boxnum]['unformatted']); - + /* Create the link for this collapse link. */ $link = '$result[0]"; + } + + /* Set the unseen count to return to the outside world. */ + $result[1] = $boxUnseenCount; + + /* Return our happy result. */ + return ($result); +} + /** * This simple function checks if a box is another box's parent. */ @@ -205,7 +287,7 @@ function listBoxes ($boxes, $j=0 ) { $mailbox = $boxes->mailboxname_full; $leader = ''; for ($k = 0; $k < $j; $k++) { - $leader.= '   '; + $leader.= '   '; } $mailboxURL = urlencode($mailbox); @@ -228,14 +310,14 @@ function listBoxes ($boxes, $j=0 ) { $link = '$leader + "; + $link .= "unfold=$mailboxURL\">$leader + "; } else { - $link .= "fold=$mailboxURL\">$leader - "; + $link .= "fold=$mailboxURL\">$leader - "; } $link .= ''; $pre .= $link; } else { - $pre.= $leader . '   '; + $pre.= $leader . '   '; } @@ -244,39 +326,40 @@ function listBoxes ($boxes, $j=0 ) { if (($move_to_trash) && ($mailbox == $trash_folder)) { if (! isset($numMessages)) { - $numMessages = sqimap_get_num_messages($imapConnection, $mailbox); + $status = sqimap_status_messages($imapConnection, $mailbox); + $numMessages = $status['MESSAGES']; } if ($numMessages > 0) { $urlMailbox = urlencode($mailbox); $pre .= "\n\n" . - "  ("._("purge").")" . + "  ("._("purge").")" . ""; } } else { if (!$boxes->is_noselect) { - $pre .= ""; + $pre .= ""; $end .= ''; } } /* If there are unseen message, close bolding. */ - if ($unseen > 0) { $end .= ""; } + if ($unseen > 0) { $end .= ""; } /* Print unseen information. */ if (isset($unseen_found) && $unseen_found) { - $end .= " $unseen_string"; + $end .= " $unseen_string"; } $font = ''; $fontend = ''; if ($boxes->is_special) { - $font = ""; - $fontend = ""; + $font = ""; + $fontend = ""; } if (!$boxes->is_root) { - echo "" . $pre .$font. $boxes->mailboxname_sub .$fontend . $end. '
'; + echo "" . $pre .$font. $boxes->mailboxname_sub .$fontend . $end. '
'; $j++; } if (!$collapse || $boxes->is_root) { @@ -315,16 +398,16 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) { } else $unseen = 0; /* If there are unseen message, bold the line. */ - if ($unseen > 0) { $pre .= ''; } + if ($unseen > 0) { $pre .= ''; } /* color special boxes */ if ($boxes->is_special) { - $pre .= ""; - $end .= ""; + $pre .= ""; + $end .= ''; } /* If there are unseen message, close bolding. */ - if ($unseen > 0) { $end .= ""; } + if ($unseen > 0) { $end .= ''; } /* Print unseen information. */ if (isset($unseen_found) && $unseen_found) { @@ -338,12 +421,12 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) { if ($numMessages > 0) { $urlMailbox = urlencode($mailbox); $pre .= "\n\n" . - "  ("._("purge").")" . + "  ("._("purge").")" . ""; } } else { if (!$boxes->is_noselect) { /* \Noselect boxes can't be selected */ - $pre .= ""; + $pre .= ""; $end .= ''; } } @@ -359,7 +442,7 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) { } else if ($boxes->is_draft) { $folder_img = '../images/draft.gif'; } else $folder_img = '../images/folder.gif'; - $folder_img = '  '; + $folder_img = '  '; } else $folder_img = ''; if (!isset($boxes->mbxs[0])) { echo ' ' . html_tag( 'div', @@ -383,9 +466,9 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) { $collapse = ($collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse); } if ($collapse) { - $link = ''." "; + $link = ''." "; } else { - $link = ''.""; + $link = ''.""; } $collapse_link = $link; } else $collapse_link=''; @@ -393,13 +476,13 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) { $collapse_link . $pre . $folder_img . ' '. $boxes->mailboxname_sub . $end , 'left', '', 'class="mbx_par" id="' .$j. 'P"' ) . "\n"; - echo ' '."\n"; + echo ' '."\n"; } } if ($collapse) { - $visible = ' STYLE="display:none;"'; + $visible = ' style="display:none;"'; } else { - $visible = ' STYLE="display:block;"'; + $visible = ' style="display:block;"'; } if (isset($boxes->mbxs[0]) && !$boxes->is_root) /* mailbox contains childs */ @@ -421,7 +504,17 @@ function ListAdvancedBoxes ($boxes, $mbx, $j='ID.0000' ) { /* -------------------- MAIN ------------------------ */ -global $delimiter, $default_folder_prefix, $left_size; +$key = $_COOKIE['key']; +$onetimepad = $_SESSION['onetimepad']; +$username = $_SESSION['username']; +$delimiter = $_SESSION['delimiter']; + +if (isset($_GET['fold'])) { + $fold = $_GET['fold']; +} +if (isset($_GET['unfold'])) { + $unfold = $_GET['unfold']; +} // open a connection on the imap port (143) $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); // the 10 is to hide the output @@ -430,10 +523,10 @@ $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 1 * Using stristr since older preferences may contain "None" and "none". */ if (isset($left_refresh) && ($left_refresh != '') && - !stristr($left_refresh, "none")){ - $xtra = "\n\n" . - "\n". - "\n"; + !stristr($left_refresh, 'none')){ + $xtra = "\n\n" . + "\n". + "\n"; } else { $xtra = ''; } @@ -618,7 +711,7 @@ ECHO; $xtra .= << + + ECHO; @@ -716,26 +809,26 @@ if ($auto_create_special && !isset($auto_create_done)) { /* Let the world know that autocreation is complete! Hurrah! */ $auto_create_done = TRUE; - session_register('auto_create_done'); + sqsession_register($auto_create_done, 'auto_create_done'); } -echo "\n\n"; +echo "\n\n"; do_hook('left_main_before'); if ($advanced_tree) { /* nice future feature, needs layout !! volunteers? */ $right_pos = $left_size - 20; echo '
'; - echo ''; - echo ''; - echo '
'; - echo '


'; + echo ''; + echo ''; + echo '
'; + echo '


'; } -echo "\n\n" . html_tag( 'table', '', '', '', 'border="0" cellspacing="0" cellpadding="0" width="100%"' ) . +echo "\n\n" . html_tag( 'table', '', 'left', '', 'border="0" cellspacing="0" cellpadding="0" width="99%"' ) . html_tag( 'tr' ) . html_tag( 'td', '', 'left' ) . - '
'. _("Folders") . "
\n\n"; + '
'. _("Folders") . "
\n\n"; if ($date_format != 6) { /* First, display the clock. */ @@ -774,7 +867,7 @@ if ($date_format != 6) { /* Next, display the refresh button. */ echo '('. - _("refresh folder list") . ')

'; + _("refresh folder list") . ')

'; /* Lastly, display the folder list. */ if ( $collapse_folders ) { @@ -814,7 +907,7 @@ for ($i = 0; $i < count($boxes); $i++) { } else { $prefix = str_replace(' ',' ',$prefix); } - $line = "$prefix"; + $line = "$prefix"; /* Add the folder name and link. */ if (! isset($color[15])) { @@ -823,21 +916,21 @@ for ($i = 0; $i < count($boxes); $i++) { if (in_array('noselect', $boxes[$i]['flags'])) { if( isSpecialMailbox( $boxes[$i]['unformatted']) ) { - $line .= ""; + $line .= ""; } else { - $line .= ""; + $line .= ""; } if (ereg("^( *)([^ ]*)", $mailbox, $regs)) { $mailbox = str_replace(' ','',$mailbox); $line .= str_replace(' ', ' ', $mailbox); } - $line .= ''; + $line .= ''; } else { $line .= formatMailboxName($imapConnection, $boxes[$i]); } /* Put the final touches on our folder line. */ - $line .= "
\n"; + $line .= "
\n"; /* Output the line for this folder. */ echo $line; @@ -846,14 +939,14 @@ for ($i = 0; $i < count($boxes); $i++) { } else { /* expiremental code */ $boxes = sqimap_mailbox_tree($imapConnection); if (isset($advanced_tree) && $advanced_tree) { - echo '


'; - echo '
'."\n\n"; + echo '

'; + echo '
'."\n\n"; if (!isset($mbx)) $mbx=NULL; ListAdvancedBoxes($boxes, $mbx); echo '
'."\n"; - echo ''."\n"; + echo ''."\n"; } else { ListBoxes($boxes); }