X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fimap_mailbox.php;h=7fc6889d4ae33551bd2d2af079a0a6a8dede6c5c;hb=1190197c9e46beaf1fc6ad39260a73b68f4f6308;hp=f8243c5e56e7f4d7e80658059878ef238fdb475a;hpb=7980d56953a6e590191fb29ca2efd04545a2f8cb;p=squirrelmail.git diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index f8243c5e..7fc6889d 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -11,27 +11,48 @@ * $Id$ */ +function isBoxBelow( $box2, $box1 ) { + + global $delimiter, $folder_prefix, $imap_server_type; + + if ( $imap_server_type == 'uw' ) { + $boxs = $box2; + $i = strpos( $box1, $delimiter, strlen( $folder_prefix ) ); + if ( $i === FALSE ) { + $i = strlen( $box2 ); + } + } else { + $boxs = $box2 . $delimiter; + // Skip next second delimiter + $i = strpos( $box1, $delimiter ); + $i = strpos( $box1, $delimiter, $i + 1 ); + if ( $i === FALSE ) { + $i = strlen( $box2 ); + } else { + $i++; + } + } + + return( substr( $box1, 0, $i ) == substr( $boxs, 0, $i ) ); + +} + /* Defines Special Mail Boxes */ - function isSpecialMailbox( $box ) { global $trash_folder, $sent_folder, $draft_folder, - $move_to_trash, $move_to_sent, $save_as_draft, - $delimiter, $folder_prefix; + $move_to_trash, $move_to_sent, $save_as_draft; - if ( $move_to_sent ) { - $i = strpos( $sent_folder, $delimiter, strlen( $folder_prefix ) ); - } - $ret = ( (strtolower($box) == 'inbox') || - ($box == $trash_folder && - $move_to_trash) || - ( substr( $sent_folder, 0, max( $i, strlen( $box ) ) ) == $box && - $move_to_sent) || - ($box == $draft_folder && - $save_as_draft) ); + ( $move_to_trash && isBoxBelow( $box, $trash_folder ) ) || + ( $move_to_sent && isBoxBelow( $box, $sent_folder )) || + ($save_as_draft && $box == $draft_folder ) ); + + if ( !$ret ) { + $ret = do_hook_function( 'special_mailbox', $box ); + } return( $ret ); @@ -64,14 +85,14 @@ function sqimap_mailbox_exists ($imap_stream, $mailbox) ** Selects a mailbox ******************************************************************************/ function sqimap_mailbox_select ($imap_stream, $mailbox, - $hide=TRUE, $recent=false) + $hide=TRUE, $recent=false, $extrainfo=false) { global $auto_expunge; - + if ( $mailbox == 'None' ) { return; } - + $read = sqimap_run_command($imap_stream, "SELECT \"$mailbox\"", TRUE, $response, $message); if ($recent) { @@ -81,17 +102,42 @@ function sqimap_mailbox_select ($imap_stream, $mailbox, } } return $r[1]; - } - if ($auto_expunge) { - $tmp = sqimap_run_command($imap_stream, 'EXPUNGE', + } else { + if ($auto_expunge) { + $tmp = sqimap_run_command($imap_stream, 'EXPUNGE', false, $a, $b); + } + if (isset( $extrainfo ) && $extrainfo) { + $result = array(); + for ($i=0; $i