Added function to update arrays etc for DMN.
authorebullient <ebullient@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 28 Jan 2004 05:17:13 +0000 (05:17 +0000)
committerebullient <ebullient@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 28 Jan 2004 05:17:13 +0000 (05:17 +0000)
plugin is officially integrated, even if I had to add a method I hated to do it.
so there.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@6452 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/imap_mailbox.php
src/read_body.php

index 950f4e563f9e0506926692c3dd0f5b54ca747d18..5749b29b7dd60e1c5668cc49518d19b95a1dc012 100755 (executable)
@@ -248,6 +248,58 @@ function sqimap_mailbox_expunge ($imap_stream, $mailbox, $handle_errors = true,
     return $cnt;
 }
 
+/**
+ * Expunge specified message, updated $msgs and $msort
+ * 
+ * Until Marc and I come up with a better way to maintain 
+ * these stupid arrays, we'll use this wrapper function to 
+ * remove the message with the matching UID .. the order
+ * won't be changed - the array element for the message
+ * will just be removed.
+ */
+function sqimap_mailbox_expunge_dmn($message_id)
+{
+    global $msgs, $msort, $sort, $imapConnection, 
+           $mailbox, $uid_support, $mbx_response, $auto_expunge, 
+           $sort, $allow_server_sort, $thread_sort_messages, $allow_thread_sort,
+           $username, $data_dir;
+
+    // Got to grab this out of prefs, since it isn't saved from mailbox_view.php
+    if ($allow_thread_sort) {
+        $thread_sort_messages = getPref($data_dir, $username, "thread_$mailbox",0); 
+    }
+
+    for ($i = 0; $i < count($msort); $i++) {
+        if ($msgs[$i]['ID'] == $message_id) {
+            break;   
+        }
+    }
+
+    unset($msgs[$i]);
+    unset($msort[$i]);
+
+    $msgs = array_values($msgs);
+    $msort = array_values($msort);
+
+    sqsession_register($msgs, 'msgs');
+    sqsession_register($msort, 'msort');
+
+    if ($auto_expunge) {
+         sqimap_mailbox_expunge($imapConnection, $mailbox, true);
+    }
+
+    // And after all that mucking around, update the sort list!
+    // Remind me why the hell we need those two arrays again?!
+    if ( $allow_thread_sort && $thread_sort_messages ) {
+        $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 ) {
+        $server_sort_array = sqimap_get_php_sort_order($imapConnection, $mbx_response);
+    }
+
+}
+
 /**
  * Checks whether or not the specified mailbox exists
  */
index a5b1052c3c324787e4591d9a4649fef744997eba..0b3aa5756968fe74ca4a7749d42217fac7265dbb 100644 (file)
@@ -778,7 +778,7 @@ if ( sqgetGlobalVar('startMessage', $temp) ) {
 }
 
 /* end of get globals */
-global $uid_support, $sqimap_capabilities, $auto_expunge, $lastTargetMailbox;
+global $uid_support, $sqimap_capabilities, $lastTargetMailbox;
 
 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
 $mbx_response   = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
@@ -788,11 +788,9 @@ $mbx_response   = sqimap_mailbox_select($imapConnection, $mailbox, false, false,
  * but only if delete_id was set
  */
 if ( sqgetGlobalVar('delete_id', $delete_id, SQ_GET) ) {
-//    sqimap_messages_delete($imapConnection, $delete_id, $delete_id, $mailbox);
+    sqimap_messages_delete($imapConnection, $delete_id, $delete_id, $mailbox);
 
-//    if ($auto_expunge) {
-//        sqimap_mailbox_expunge($imapConnection, $mailbox, true);
-//    }    
+    sqimap_mailbox_expunge_dmn($delete_id);
 }
 
 /**
@@ -802,17 +800,15 @@ if ( sqgetGlobalVar('delete_id', $delete_id, SQ_GET) ) {
 if ( sqgetGlobalVar('move_id', $move_id, SQ_POST) &&
      sqgetGlobalVar('targetMailbox', $targetMailbox, SQ_POST) ) {
     // Move message
-//    sqimap_messages_copy($imapConnection, $move_id, $move_id, $targetMailbox);
-//    sqimap_messages_flag($imapConnection, $move_id, $move_id, 'Deleted', true);
+    sqimap_messages_copy($imapConnection, $move_id, $move_id, $targetMailbox);
+    sqimap_messages_flag($imapConnection, $move_id, $move_id, 'Deleted', true);
 
-//    if ($auto_expunge) {
-//        sqimap_mailbox_expunge($imapConnection, $mailbox, true);
-//    }
+    sqimap_mailbox_expunge_dmn($move_id);
 
-//    if ($targetMailbox != $lastTargetMailbox) {
-//        $lastTargetMailbox = $targetMailbox;
-//        sqsession_register('lastTargetMailbox' , $lastTargetMailbox);
-//    }
+    if ($targetMailbox != $lastTargetMailbox) {
+        $lastTargetMailbox = $targetMailbox;
+        sqsession_register('lastTargetMailbox' , $lastTargetMailbox);
+    }
 }