From ceb7ad3c6c336213e89b7144a025b752c29a2f6c Mon Sep 17 00:00:00 2001 From: tokul Date: Fri, 4 Aug 2006 09:17:43 +0000 Subject: [PATCH] don't tag subfolders of Drafts,Trash and Sent as special in folder management page. Allows rename and delete operations with subfolders. don't treat INBOX.Trash as special on Courier. Trash folder can have subfolders in courier. Only XMAGICTRASH extension can cause errors when trash folder is deleted. Courier does not document commands that allow to detect folder that is used as magic trash. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11466 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- ChangeLog | 7 +++++++ functions/folder_manip.php | 12 ++---------- functions/imap_mailbox.php | 30 ++++++++++++++++++++++-------- src/configtest.php | 12 ++++++++++++ src/folders.php | 11 +---------- 5 files changed, 44 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index d13d0bc4..4f148143 100644 --- a/ChangeLog +++ b/ChangeLog @@ -115,6 +115,13 @@ Version 1.5.2 - CVS sure the code only sets those variables that are needed in compose and are not already set. Thanks James Bercegay from GulfTech for pointing this out. + - Subfolders of system folders are not tagged as special in folder + management page in order to allow rename and delete operations with + subfolders (#1460011). + - Trash subfolders are allowed in courier. INBOX.Trash is not treated + as special on Courier, unless some SquirrelMail configuration options + mark this folder as special (#1354393). Configtest utility should + display warning, if Courier IMAP XMAGICTRASH extension is detected. Version 1.5.1 (branched on 2006-02-12) -------------------------------------- diff --git a/functions/folder_manip.php b/functions/folder_manip.php index e15ab617..e186ec5a 100644 --- a/functions/folder_manip.php +++ b/functions/folder_manip.php @@ -220,18 +220,10 @@ function folders_delete_do ($imapConnection, $delimiter, $folder_name) /** lets see if we CAN move folders to the trash.. otherwise, ** just delete them **/ - - /* Courier IMAP doesn't like subfolders of Trash - * If global options say we can't move it into Trash - * If it's already a subfolder of trash, we'll have to delete it */ - if (strtolower($imap_server_type) == 'courier' || - (isset($delete_folder) && $delete_folder) || - eregi('^'.$trash_folder.'.+', $folder_name) ) - { + if ($delete_folder || eregi('^'.$trash_folder.'.+', $folder_name) ) { $can_move_to_trash = FALSE; - } + } else { /* Otherwise, check if trash folder exits and support sub-folders */ - else { foreach($boxes as $box) { if ($box['unformatted'] == $trash_folder) { $can_move_to_trash = !in_array('noinferiors', $box['flags']); diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index d8eecb28..e9f9d6a4 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -220,12 +220,17 @@ function isBoxBelow( $subbox, $parentbox ) { * Since 1.2.5 function includes special_mailbox hook.
* Since 1.4.3 hook supports more than one plugin. * @param string $box mailbox name + * @param boolean $include_subs (since 1.5.2) if true, subfolders of system + * folders are special. if false, subfolders are not special mailboxes + * unless they are tagged as special in 'special_mailbox' hook. * @return boolean * @since 1.2.3 */ -function isSpecialMailbox( $box ) { +function isSpecialMailbox($box,$include_subs=true) { $ret = ( (strtolower($box) == 'inbox') || - isTrashMailbox($box) || isSentMailbox($box) || isDraftMailbox($box) ); + isTrashMailbox($box,$include_subs) || + isSentMailbox($box,$include_subs) || + isDraftMailbox($box,$include_subs) ); if ( !$ret ) { $ret = boolean_hook_function('special_mailbox',$box,1); @@ -236,37 +241,46 @@ function isSpecialMailbox( $box ) { /** * Detects if mailbox is a Trash folder or subfolder of Trash * @param string $box mailbox name + * @param boolean $include_subs (since 1.5.2) if true, subfolders of system + * folders are special. if false, subfolders are not special mailboxes. * @return bool whether this is a Trash folder * @since 1.4.0 */ -function isTrashMailbox ($box) { +function isTrashMailbox ($box,$include_subs=true) { global $trash_folder, $move_to_trash; return $move_to_trash && $trash_folder && - ( $box == $trash_folder || isBoxBelow($box, $trash_folder) ); + ( $box == $trash_folder || + ($include_subs && isBoxBelow($box, $trash_folder)) ); } /** * Detects if mailbox is a Sent folder or subfolder of Sent * @param string $box mailbox name + * @param boolean $include_subs (since 1.5.2) if true, subfolders of system + * folders are special. if false, subfolders are not special mailboxes. * @return bool whether this is a Sent folder * @since 1.4.0 */ -function isSentMailbox($box) { +function isSentMailbox($box,$include_subs=true) { global $sent_folder, $move_to_sent; return $move_to_sent && $sent_folder && - ( $box == $sent_folder || isBoxBelow($box, $sent_folder) ); + ( $box == $sent_folder || + ($include_subs && isBoxBelow($box, $sent_folder)) ); } /** * Detects if mailbox is a Drafts folder or subfolder of Drafts * @param string $box mailbox name + * @param boolean $include_subs (since 1.5.2) if true, subfolders of system + * folders are special. if false, subfolders are not special mailboxes. * @return bool whether this is a Draft folder * @since 1.4.0 */ -function isDraftMailbox($box) { +function isDraftMailbox($box,$include_subs=true) { global $draft_folder, $save_as_draft; return $save_as_draft && - ( $box == $draft_folder || isBoxBelow($box, $draft_folder) ); + ( $box == $draft_folder || + ($include_subs && isBoxBelow($box, $draft_folder)) ); } /** diff --git a/src/configtest.php b/src/configtest.php index 0d5a0cc2..95c60658 100644 --- a/src/configtest.php +++ b/src/configtest.php @@ -504,6 +504,18 @@ if($imap_auth_mech == 'login' && stristr($capline, 'LOGINDISABLED') !== FALSE) { 'in the SquirrelMail configuration.', FALSE); } +if (stristr($capline, 'XMAGICTRASH') !== false) { + $magic_trash = 'It looks like IMAP_MOVE_EXPUNGE_TO_TRASH option is turned on ' + .'in your Courier IMAP configuration. Courier does not provide tools that ' + .'allow to detect folder used for Trash or commands are not documented. ' + .'SquirrelMail can\'t detect special trash folder. SquirrelMail manages ' + .'all message deletion or move operations internally and ' + .'IMAP_MOVE_EXPUNGE_TO_TRASH option can cause errors in message and ' + .'folder management operations. Please turn off IMAP_MOVE_EXPUNGE_TO_TRASH ' + .'option in Courier imapd configuration.'; + do_err($magic_trash,false); +} + /** OK, close connection */ fputs($stream, "A004 LOGOUT\r\n"); fclose($stream); diff --git a/src/folders.php b/src/folders.php index c4568af7..559a284e 100644 --- a/src/folders.php +++ b/src/folders.php @@ -104,15 +104,6 @@ $server_type = strtolower($imap_server_type); // Special handling for courier if ( $server_type == 'courier' ) { - /** - * If we use courier, we should hide system trash folder - * FIXME: (tokul) Who says that courier does not allow storing folders in - * INBOX.Trash or inbox.trash? Can't reproduce it 3.0.8. This entry is - * useless, because in_array() check is case sensitive and INBOX is in - * upper case. - */ - array_push($skip_folders, 'inbox.trash'); - if ( $default_folder_prefix == 'INBOX.' ) { // We don't need INBOX, since it is top folder array_push($skip_folders, 'INBOX'); @@ -140,7 +131,7 @@ $mbx_option_list .= sqimap_mailbox_option_list($imapConnection, $show_selected, /** count special folders **/ foreach ($boxes as $index => $aBoxData) { - if (isSpecialMailbox($aBoxData['unformatted']) && + if (isSpecialMailbox($aBoxData['unformatted'],false) && ! in_array($aBoxData['unformatted'],$skip_folders)) { $skip_folders[] = $aBoxData['unformatted']; } -- 2.25.1