diff options
Diffstat (limited to 'program/include')
-rw-r--r-- | program/include/rcube_imap.php | 57 | ||||
-rwxr-xr-x | program/include/rcube_template.php | 2 |
2 files changed, 51 insertions, 8 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 diff --git a/program/include/rcube_template.php b/program/include/rcube_template.php index 6de32722c..ad498c9c5 100755 --- a/program/include/rcube_template.php +++ b/program/include/rcube_template.php @@ -860,7 +860,7 @@ class rcube_template extends rcube_html_page if (!$attrib['href']) { $attrib['href'] = '#'; } - if ($command) { + if ($command && !$attrib['onclick']) { $attrib['onclick'] = sprintf( "return %s.command('%s','%s',this)", JS_OBJECT_NAME, |