浏览代码

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.

tokul 19 年之前
父节点
当前提交
f5f9bc8e67
共有 5 个文件被更改,包括 44 次插入28 次删除
  1. 7 0
      ChangeLog
  2. 2 10
      functions/folder_manip.php
  3. 22 8
      functions/imap_mailbox.php
  4. 12 0
      src/configtest.php
  5. 1 10
      src/folders.php

+ 7 - 0
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)
 --------------------------------------

+ 2 - 10
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']);

+ 22 - 8
functions/imap_mailbox.php

@@ -220,12 +220,17 @@ function isBoxBelow( $subbox, $parentbox ) {
  * Since 1.2.5 function includes special_mailbox hook.<br>
  * 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)) );
 }
 
 /**

+ 12 - 0
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);

+ 1 - 10
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'];
     }