Removed kind of insane check. The check mailbox is subscribed call retrieved
[squirrelmail.git] / functions / imap_mailbox.php
index 538bb189d5b1a76e0182ca321e3ba065a7bc388c..41ea2b761d1e45646d57d5739e702dd8d916882b 100755 (executable)
@@ -8,8 +8,9 @@
  *
  * This impliments all functions that manipulate mailboxes
  *
- * $Id$
+ * @version $Id$
  * @package squirrelmail
+ * @subpackage imap
  */
 
 /** UTF7 support */
@@ -262,6 +263,7 @@ function sqimap_mailbox_expunge_dmn($message_id)
            $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) {
@@ -273,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!
@@ -296,7 +301,7 @@ function sqimap_mailbox_expunge_dmn($message_id)
     } else {
         $server_sort_array = sqimap_get_php_sort_order($imapConnection, $mbx_response);
     }
-
+    return $cnt;
 }
 
 /**
@@ -315,8 +320,6 @@ function sqimap_mailbox_exists ($imap_stream, $mailbox) {
  * Selects a mailbox
  */
 function sqimap_mailbox_select ($imap_stream, $mailbox) {
-    global $auto_expunge;
-
     if ($mailbox == 'None') {
         return;
     }
@@ -343,9 +346,6 @@ function sqimap_mailbox_select ($imap_stream, $mailbox) {
         $result['RIGHTS']=$regs[1];
     }
 
-    if ($auto_expunge) {
-        $tmp = sqimap_run_command($imap_stream, 'EXPUNGE', false, $a, $b);
-    }
     return $result;
 }
 
@@ -367,10 +367,10 @@ function sqimap_mailbox_create ($imap_stream, $mailbox, $type) {
 /**
  * Subscribes to an existing folder.
  */
-function sqimap_subscribe ($imap_stream, $mailbox) {
+function sqimap_subscribe ($imap_stream, $mailbox,$debug=true) {
     $read_ary = sqimap_run_command($imap_stream, 'SUBSCRIBE ' .
                                    sqimap_encode_mailbox_name($mailbox),
-                                   true, $response, $message);
+                                   $debug, $response, $message);
 }
 
 /**
@@ -609,6 +609,7 @@ function sqimap_mailbox_option_list($imap_stream, $show_selected = 0, $folder_sk
  * See comment on sqimap_mailbox_parse() for info about the returned array.
  */
 function sqimap_mailbox_list($imap_stream) {
+    echo "TEST<BR>";
     global $default_folder_prefix;
 
     if (!isset($boxesnew)) {