From 8fd923e70c08c103a3b9aa644431e4ee8cd0b330 Mon Sep 17 00:00:00 2001 From: Nathan Kinkade Date: Thu, 5 Mar 2009 21:11:55 +0000 Subject: Added functionality to copy messages from one mailbox to another. --- roundcubemail/program/include/rcube_imap.php | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'roundcubemail/program/include') diff --git a/roundcubemail/program/include/rcube_imap.php b/roundcubemail/program/include/rcube_imap.php index 788b0ff58..2f3a49cb1 100644 --- a/roundcubemail/program/include/rcube_imap.php +++ b/roundcubemail/program/include/rcube_imap.php @@ -1758,6 +1758,45 @@ class rcube_imap return $moved; } + /** + * Copy a message from one mailbox to another + * + * @param string List of UIDs to move, 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='') + { + $to_mbox = $this->_mod_mailbox($to_mbox); + $from_mbox = $from_mbox ? $this->_mod_mailbox($from_mbox) : $this->mailbox; + + // make sure mailbox exists + if ($to_mbox != 'INBOX' && !in_array($to_mbox, $this->_list_mailboxes())) + { + if (in_array($to_mbox_in, $this->default_folders)) + $this->create_mailbox($to_mbox_in, TRUE); + 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)) + return false; + + // convert uids to message ids + $a_mids = array(); + foreach ($a_uids as $uid) + $a_mids[] = $this->_uid2id($uid, $from_mbox); + + $iil_copy = iil_C_Copy($this->conn, join(',', $a_mids), $from_mbox, $to_mbox); + $copied = !($iil_copy === false || $iil_copy < 0); + + return $copied; + } /** * Mark messages as deleted and expunge mailbox -- cgit v1.2.3