phpDocumentor updates
[squirrelmail.git] / functions / imap_mailbox.php
index f2d733ee3c119381362f87dfb23e04bc66ae1ed7..128b27a1f2fa4c5d474a053e658f1af6e89c4e70 100755 (executable)
@@ -3,11 +3,10 @@
 /**
  * imap_mailbox.php
  *
- * Copyright (c) 1999-2005 The SquirrelMail Project Team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
- *
  * This implements all functions that manipulate mailboxes
  *
+ * @copyright © 1999-2005 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
  * @subpackage imap
@@ -431,16 +430,20 @@ function sqimap_unsubscribe ($imap_stream, $mailbox) {
 function sqimap_mailbox_delete ($imap_stream, $mailbox) {
     global $data_dir, $username;
     sqimap_unsubscribe ($imap_stream, $mailbox);
-    $read_ary = sqimap_run_command($imap_stream, 'DELETE ' .
-                                   sqimap_encode_mailbox_name($mailbox),
-                                   true, $response, $message);
-    if ($response !== 'OK') {
-        // subscribe again
-        sqimap_subscribe ($imap_stream, $mailbox);
-    } else {
-        do_hook_function('rename_or_delete_folder', $args = array($mailbox, 'delete', ''));
-        removePref($data_dir, $username, "thread_$mailbox");
-        removePref($data_dir, $username, "collapse_folder_$mailbox");
+
+    if (sqimap_mailbox_exists($imap_stream, $mailbox)) {
+
+        $read_ary = sqimap_run_command($imap_stream, 'DELETE ' .
+                                       sqimap_encode_mailbox_name($mailbox),
+                                       true, $response, $message);
+        if ($response !== 'OK') {
+            // subscribe again
+            sqimap_subscribe ($imap_stream, $mailbox);
+        } else {
+            do_hook_function('rename_or_delete_folder', $args = array($mailbox, 'delete', ''));
+            removePref($data_dir, $username, "thread_$mailbox");
+            removePref($data_dir, $username, "collapse_folder_$mailbox");
+        }
     }
 }
 
@@ -902,6 +905,8 @@ function sqimap_mailbox_tree($imap_stream) {
         $folder_prefix, $delimiter, $trash_folder, $move_to_trash,
         $imap_server_type, $show_only_subscribed_folders;
 
+    // TODO: implement mailbox tree caching. maybe store object in session?
+
     $noselect = false;
     $noinferiors = false;
 
@@ -922,7 +927,7 @@ function sqimap_mailbox_tree($imap_stream) {
     $has_inbox = false;
 
     for ($i = 0, $cnt = count($lsub_ary); $i < $cnt; $i++) {
-        if (preg_match("/^\*\s+$lsub_cmd.*\s\"?INBOX\"?[^(\/\.)].*$/i",$lsub_ary[$i])) {
+        if (preg_match("/^\*\s+$lsub_cmd.*\s\"?INBOX\"?\s*$/i",$lsub_ary[$i])) {
             $lsub_ary[$i] = strtoupper($lsub_ary[$i]);
             // in case of an unsubscribed inbox an imap server can
             // return the inbox in the lsub results with a \NoSelect