From d87fc29fee9e629fad49d956a449ae647c0bc142 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Wed, 11 Jun 2008 15:26:08 -0400
Subject: [PATCH] - don't call expunge and don't remove message row after message move   if flag_for_deletion is set to true (#1485002)

---
 CHANGELOG                      |    5 +++++
 program/include/rcube_imap.php |   10 +++++++---
 program/js/app.js              |   25 ++++++++++++++++++++-----
 3 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 63bf46c..caa6760 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,11 @@
 CHANGELOG RoundCube Webmail
 ---------------------------
 
+2008/06/11 (alec)
+----------
+- Don't call expunge and don't remove message row after message move 
+  if flag_for_deletion is set to true (#1485002)
+
 2008/06/08 (alec)
 ----------
 - Added option to disable autocompletion from selected LDAP address books (#1484922)
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 9d8f6d3..7f3fd9a 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -1419,9 +1419,13 @@
     // send expunge command in order to have the moved message
     // really deleted from the source mailbox
     if ($moved) {
-      $this->_expunge($from_mbox, FALSE);
-      $this->_clear_messagecount($from_mbox);
-      $this->_clear_messagecount($to_mbox);
+      // but only when flag_for_deletion is set to false
+      if (!rcmail::get_instance()->config->get('flag_for_deletion', false))
+        {
+        $this->_expunge($from_mbox, FALSE);
+        $this->_clear_messagecount($from_mbox);
+        $this->_clear_messagecount($to_mbox);
+        }
     }
     // moving failed
     else if (rcmail::get_instance()->config->get('delete_always', false)) {
diff --git a/program/js/app.js b/program/js/app.js
index 71545e8..96c9ec3 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -1397,13 +1397,13 @@
       lock = true;
       this.set_busy(true, 'movingmessage');
       }
-    else
+    else if (!this.env.flag_for_deletion)
       this.show_contentframe(false);
 
     // Hide message command buttons until a message is selected
     this.enable_command('reply', 'reply-all', 'forward', 'delete', 'mark', 'print', false);
 
-    this._with_selected_messages('moveto', lock, add_url);
+    this._with_selected_messages('moveto', lock, add_url, (this.env.flag_for_deletion ? false : true));
     };
 
   // delete selected messages from the current mailbox
@@ -1453,12 +1453,12 @@
       return;
       
     this.show_contentframe(false);
-    this._with_selected_messages('delete', false, '&_from='+(this.env.action ? this.env.action : ''));
+    this._with_selected_messages('delete', false, '&_from='+(this.env.action ? this.env.action : ''), true);
     };
 
   // Send a specifc request with UIDs of all selected messages
   // @private
-  this._with_selected_messages = function(action, lock, add_url)
+  this._with_selected_messages = function(action, lock, add_url, remove)
     {
     var a_uids = new Array();
 
@@ -1467,13 +1467,28 @@
     else
       {
       var selection = this.message_list.get_selection();
+      var rows = this.message_list.rows;
       var id;
       for (var n=0; n<selection.length; n++)
         {
         id = selection[n];
         a_uids[a_uids.length] = id;
 
-        this.message_list.remove_row(id, (n == selection.length-1));
+	if (remove)
+          this.message_list.remove_row(id, (n == selection.length-1));
+        else
+	  {
+	  rows[id].deleted = true;
+        
+          if (rows[id].classname.indexOf('deleted')<0)
+	    {
+            rows[id].classname += ' deleted';
+            this.set_classname(rows[id].obj, 'deleted', true);
+            }
+        
+	  if (rows[id].icon && this.env.deletedicon)
+            rows[id].icon.src = this.env.deletedicon;
+	  }
         }
       }
     

--
Gitblit v1.9.1