two more subpackage blocks
[squirrelmail.git] / functions / imap_mailbox.php
index a5a6277c7c6a2b28f3d18e021c3e27bcac0af244..6f798dbbfef3dec88e7e49c5c610b1b94aafc39b 100755 (executable)
@@ -8,8 +8,9 @@
  *
  * This impliments all functions that manipulate mailboxes
  *
- * $Id$
+ * @version $Id$
  * @package squirrelmail
+ * @subpackage imap
  */
 
 /** UTF7 support */
@@ -224,13 +225,12 @@ function isDraftMailbox($box) {
  * Expunges a mailbox, ie. delete all contents.
  */
 function sqimap_mailbox_expunge ($imap_stream, $mailbox, $handle_errors = true, $id='') {
-    global $uid_support;
     if ($id) {
         if (is_array($id)) {
             $id = sqimap_message_list_squisher($id);
         }
         $id = ' '.$id;
-        $uid = $uid_support;
+       $uid = TRUE;
     } else {
         $uid = false;
     }
@@ -260,9 +260,10 @@ function sqimap_mailbox_expunge ($imap_stream, $mailbox, $handle_errors = true,
 function sqimap_mailbox_expunge_dmn($message_id)
 {
     global $msgs, $msort, $sort, $imapConnection, 
-           $mailbox, $uid_support, $mbx_response, $auto_expunge, 
+           $mailbox, $mbx_response, $auto_expunge, 
            $sort, $allow_server_sort, $thread_sort_messages, $allow_thread_sort,
            $username, $data_dir;
+    $cnt = 0;
 
     // Got to grab this out of prefs, since it isn't saved from mailbox_view.php
     if ($allow_thread_sort) {
@@ -274,18 +275,21 @@ function sqimap_mailbox_expunge_dmn($message_id)
             break;   
         }
     }
+    
+    if ( isset($msgs) ) {
+        unset($msgs[$i]);
+        $msgs = array_values($msgs);
+        sqsession_register($msgs, 'msgs');
+    }
 
-    unset($msgs[$i]);
-    unset($msort[$i]);
-
-    $msgs = array_values($msgs);
-    $msort = array_values($msort);
-
-    sqsession_register($msgs, 'msgs');
-    sqsession_register($msort, 'msort');
+    if ( isset($msort) ) {
+        unset($msort[$i]);
+        $msort = array_values($msort);
+        sqsession_register($msort, 'msort');
+    }
 
     if ($auto_expunge) {
-         sqimap_mailbox_expunge($imapConnection, $mailbox, true);
+         $cnt = sqimap_mailbox_expunge($imapConnection, $mailbox, true);
     }
 
     // And after all that mucking around, update the sort list!
@@ -294,10 +298,10 @@ function sqimap_mailbox_expunge_dmn($message_id)
         $server_sort_array = get_thread_sort($imapConnection);
     } elseif ( $allow_server_sort ) {
         $server_sort_array = sqimap_get_sort_order($imapConnection, $sort, $mbx_response);
-    } elseif ( $uid_support ) {
+    } else {
         $server_sort_array = sqimap_get_php_sort_order($imapConnection, $mbx_response);
     }
-
+    return $cnt;
 }
 
 /**
@@ -823,6 +827,9 @@ function sqimap_mailbox_tree($imap_stream) {
                     // remove the result and request it again  with a list
                     // response at a later stage.
                     unset($lsub_ary[$i]);
+                    // re-index the array otherwise the addition of the LIST 
+                    // response will fail in PHP 4.1.2 and probably other older versions
+                    $lsub_ary = array_values($lsub_ary);
                 }
                 break;
             }