From 9b3fdc25c171d2b2461af42224ea16ad6c032c49 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Fri, 19 Mar 2010 07:20:12 -0400
Subject: [PATCH] - Implemented messages copying using drag&drop + SHIFT (#1484086)

---
 program/include/rcube_imap.php |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 50 insertions(+), 7 deletions(-)

diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 1e3c09d..651ecd6 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -2202,6 +2202,13 @@
     $to_mbox = $this->mod_mailbox($to_mbox);
     $from_mbox = $from_mbox ? $this->mod_mailbox($from_mbox) : $this->mailbox;
 
+    // convert the list of uids to array
+    $a_uids = is_string($uids) ? explode(',', $uids) : (is_array($uids) ? $uids : NULL);
+
+    // exit if no message uids are specified
+    if (!is_array($a_uids) || empty($a_uids))
+      return false;
+
     // make sure mailbox exists
     if ($to_mbox != 'INBOX' && !$this->mailbox_exists($tbox))
       {
@@ -2210,13 +2217,6 @@
       else
         return false;
       }
-
-    // convert the list of uids to array
-    $a_uids = is_string($uids) ? explode(',', $uids) : (is_array($uids) ? $uids : NULL);
-
-    // exit if no message uids are specified
-    if (!is_array($a_uids) || empty($a_uids))
-      return false;
 
     // flag messages as read before moving them
     $config = rcmail::get_instance()->config;
@@ -2270,6 +2270,49 @@
 
 
   /**
+   * Copy a message from one mailbox to another
+   *
+   * @param string List of UIDs to copy, separated by comma
+   * @param string Target mailbox
+   * @param string Source mailbox
+   * @return boolean True on success, False on error
+   */
+  function copy_message($uids, $to_mbox, $from_mbox='')
+  {
+    $fbox = $from_mbox;
+    $tbox = $to_mbox;
+    $to_mbox = $this->mod_mailbox($to_mbox);
+    $from_mbox = $from_mbox ? $this->mod_mailbox($from_mbox) : $this->mailbox;
+
+    // convert the list of uids to array
+    $a_uids = is_string($uids) ? explode(',', $uids) : (is_array($uids) ? $uids : NULL);
+
+    // exit if no message uids are specified
+    if (!is_array($a_uids) || empty($a_uids))
+      return false;
+
+    // make sure mailbox exists
+    if ($to_mbox != 'INBOX' && !$this->mailbox_exists($tbox))
+      {
+      if (in_array($tbox, $this->default_folders))
+        $this->create_mailbox($tbox, true);
+      else
+        return false;
+      }
+
+    // copy messages
+    $iil_copy = iil_C_Copy($this->conn, join(',', $a_uids), $from_mbox, $to_mbox);
+    $copied = !($iil_copy === false || $iil_copy < 0);
+
+    if ($copied) {
+      $this->_clear_messagecount($to_mbox);
+    }
+
+    return $copied;
+  }
+
+
+  /**
    * Mark messages as deleted and expunge mailbox
    *
    * @param string List of UIDs to move, separated by comma

--
Gitblit v1.9.1