diff options
author | alecpl <alec@alec.pl> | 2010-03-19 11:20:12 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2010-03-19 11:20:12 +0000 |
commit | 9b3fdc25c171d2b2461af42224ea16ad6c032c49 (patch) | |
tree | d7414b8cf6c373439b66edcdb9a0b54837bdd429 /program/include/rcube_imap.php | |
parent | f093291bfdac81dd6f68fb7cebc9a871c9f9bf04 (diff) |
- Implemented messages copying using drag&drop + SHIFT (#1484086)
Diffstat (limited to 'program/include/rcube_imap.php')
-rw-r--r-- | 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 1e3c09dc1..651ecd61c 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -2202,6 +2202,13 @@ class rcube_imap $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)) { @@ -2211,13 +2218,6 @@ class rcube_imap 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; if ($config->get('read_when_deleted') && $tbox == $config->get('trash_mbox')) { @@ -2270,6 +2270,49 @@ class rcube_imap /** + * 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 |