| | |
| | | $mailbox = $this->mod_mailbox($mbox_name); |
| | | |
| | | // make sure mailbox exists |
| | | if ($mailbox == 'INBOX' || $this->mailbox_exists($mbox_name)) { |
| | | if ($this->mailbox_exists($mbox_name, true)) { |
| | | if ($is_file) { |
| | | $separator = rcmail::get_instance()->config->header_delimiter(); |
| | | $saved = iil_C_AppendFromFile($this->conn, $mailbox, $message, |
| | |
| | | $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' && !$this->mailbox_exists($tbox)) |
| | | { |
| | | if (in_array($tbox, $this->default_folders)) |
| | | $this->create_mailbox($tbox, 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) || empty($a_uids)) |
| | | return false; |
| | | |
| | | // make sure mailbox exists |
| | | if ($to_mbox != 'INBOX' && !$this->mailbox_exists($tbox, true)) |
| | | { |
| | | if (in_array($tbox, $this->default_folders)) |
| | | $this->create_mailbox($tbox, true); |
| | | else |
| | | return false; |
| | | } |
| | | |
| | | // flag messages as read before moving them |
| | | $config = rcmail::get_instance()->config; |
| | |
| | | } |
| | | |
| | | return $moved; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 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, true)) |
| | | { |
| | | 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; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | $mailbox = $this->mod_mailbox($mbox_name); |
| | | $sub_mboxes = iil_C_ListMailboxes($this->conn, $this->mod_mailbox(''), |
| | | $mailbox . $this->delimiter . '*'); |
| | | $mbox_name . $this->delimiter . '*'); |
| | | |
| | | // unsubscribe mailbox before deleting |
| | | iil_C_UnSubscribe($this->conn, $mailbox); |
| | |
| | | |
| | | foreach ($sub_mboxes as $c_mbox) |
| | | if ($c_mbox != 'INBOX') { |
| | | iil_C_UnSubscribe($this->conn, $c_mbox); |
| | | $result = iil_C_DeleteFolder($this->conn, $c_mbox); |
| | | if ($result >= 0) { |
| | | $deleted = true; |
| | | $this->clear_message_cache($c_mbox.'.msg'); |
| | | iil_C_UnSubscribe($this->conn, $c_mbox); |
| | | $result = iil_C_DeleteFolder($this->conn, $c_mbox); |
| | | if ($result >= 0) { |
| | | $deleted = true; |
| | | $this->clear_message_cache($c_mbox.'.msg'); |
| | | } |
| | | } |
| | | } |
| | |
| | | if ($mbox_name == 'INBOX') |
| | | return true; |
| | | |
| | | $mbox = $this->mod_mailbox($mbox_name); |
| | | |
| | | if ($subscription) { |
| | | if ($a_folders = iil_C_ListSubscribed($this->conn, $this->mod_mailbox(''), $mbox)) |
| | | if ($a_folders = iil_C_ListSubscribed($this->conn, $this->mod_mailbox(''), $mbox_name)) |
| | | return true; |
| | | } |
| | | else { |
| | | $a_folders = iil_C_ListMailboxes($this->conn, $this->mod_mailbox(''), $mbox); |
| | | $a_folders = iil_C_ListMailboxes($this->conn, $this->mod_mailbox(''), $mbox_mbox); |
| | | |
| | | if (is_array($a_folders) && in_array($mbox, $a_folders)) |
| | | if (is_array($a_folders) && in_array($this->mod_mailbox($mbox_name), $a_folders)) |
| | | return true; |
| | | } |
| | | } |