| | |
| | | } |
| | | // set current mailbox in client environment |
| | | $OUTPUT->set_env('mailbox', $RCMAIL->storage->get_folder()); |
| | | $OUTPUT->set_env('sig_above', $RCMAIL->config->get('sig_above', false)); |
| | | $OUTPUT->set_env('top_posting', intval($RCMAIL->config->get('reply_mode')) > 0); |
| | | $OUTPUT->set_env('recipients_separator', trim($RCMAIL->config->get('recipients_separator', ','))); |
| | | |
| | |
| | | // get reference message and set compose mode |
| | | if ($msg_uid = $COMPOSE['param']['draft_uid']) { |
| | | $compose_mode = RCUBE_COMPOSE_DRAFT; |
| | | $OUTPUT->set_env('draft_id', $msg_uid); |
| | | $RCMAIL->storage->set_folder($CONFIG['drafts_mbox']); |
| | | } |
| | | else if ($msg_uid = $COMPOSE['param']['reply_uid']) { |
| | |
| | | if (count($MESSAGE->identities)) |
| | | { |
| | | $a_signatures = array(); |
| | | $separator = $RCMAIL->config->get('sig_above') |
| | | $separator = intval($RCMAIL->config->get('reply_mode')) > 0 |
| | | && ($compose_mode == RCUBE_COMPOSE_REPLY || $compose_mode == RCUBE_COMPOSE_FORWARD) ? '---' : '-- '; |
| | | |
| | | $field_attrib['onchange'] = JS_OBJECT_NAME.".change_identity(this)"; |
| | |
| | | $text = $html = $sql_arr['signature']; |
| | | |
| | | if ($sql_arr['html_signature']) { |
| | | $h2t = new html2text($sql_arr['signature'], false, false); |
| | | $h2t = new rcube_html2text($sql_arr['signature'], false, false); |
| | | $text = trim($h2t->get_text()); |
| | | } |
| | | else { |
| | |
| | | |
| | | function rcmail_compose_editor_mode() |
| | | { |
| | | global $RCMAIL, $MESSAGE, $compose_mode; |
| | | global $RCMAIL, $compose_mode; |
| | | static $useHtml; |
| | | |
| | | if ($useHtml !== null) |
| | |
| | | $useHtml = !empty($_POST['_is_html']); |
| | | } |
| | | else if ($compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT) { |
| | | $useHtml = $MESSAGE->has_html_part(false, true); |
| | | $useHtml = rcmail_message_is_html(); |
| | | } |
| | | else if ($compose_mode == RCUBE_COMPOSE_REPLY) { |
| | | $useHtml = ($html_editor == 1 || ($html_editor >= 2 && $MESSAGE->has_html_part(false, true))); |
| | | $useHtml = ($html_editor == 1 || ($html_editor >= 2 && rcmail_message_is_html())); |
| | | } |
| | | else if ($compose_mode == RCUBE_COMPOSE_FORWARD) { |
| | | $useHtml = ($html_editor == 1 || ($html_editor == 3 && $MESSAGE->has_html_part(false, true))); |
| | | $useHtml = ($html_editor == 1 || ($html_editor == 3 && rcmail_message_is_html())); |
| | | } |
| | | else { |
| | | $useHtml = ($html_editor == 1); |
| | |
| | | return $useHtml; |
| | | } |
| | | |
| | | function rcmail_message_is_html() |
| | | { |
| | | global $MESSAGE; |
| | | return ($MESSAGE instanceof rcube_message) && $MESSAGE->has_html_part(false, true); |
| | | } |
| | | |
| | | function rcmail_prepare_message_body() |
| | | { |
| | |
| | | else if ($compose_mode == RCUBE_COMPOSE_FORWARD && $COMPOSE['as_attachment']) { |
| | | $isHtml = rcmail_compose_editor_mode(); |
| | | $body = ''; |
| | | if (empty($COMPOSE['attachments'])) |
| | | rcmail_write_forward_attachments(); |
| | | rcmail_write_forward_attachments(); |
| | | } |
| | | // reply/edit/draft/forward |
| | | else if ($compose_mode && ($compose_mode != RCUBE_COMPOSE_REPLY || $RCMAIL->config->get('reply_mode') != -1)) { |
| | |
| | | // use html part if it has been used for message (pre)viewing |
| | | // decrease line length for quoting |
| | | $len = $compose_mode == RCUBE_COMPOSE_REPLY ? $LINE_LENGTH-2 : $LINE_LENGTH; |
| | | $txt = new html2text($body, false, true, $len); |
| | | $txt = new rcube_html2text($body, false, true, $len); |
| | | $body = $txt->get_text(); |
| | | } |
| | | else if ($part->ctype_secondary == 'enriched') { |
| | |
| | | foreach ((array)$message->mime_parts as $pid => $part) |
| | | { |
| | | if ($part->disposition == 'attachment' || ($part->disposition == 'inline' && $bodyIsHtml) || $part->filename) { |
| | | if ($part->ctype_primary == 'message' || $part->ctype_primary == 'multipart') { |
| | | if (($part->ctype_primary == 'message' && $bodyIsHtml) || $part->ctype_primary == 'multipart') { |
| | | continue; |
| | | } |
| | | if ($part->mimetype == 'application/ms-tnef') { |
| | |
| | | $curr_mem = function_exists('memory_get_usage') ? memory_get_usage() : 16*1024*1024; // safe value: 16MB |
| | | $names = array(); |
| | | |
| | | $loaded_attachments = array(); |
| | | foreach ((array)$COMPOSE['attachments'] as $id => $attachment) { |
| | | $loaded_attachments[$attachment['name'] . $attachment['mimetype']] = $attachment; |
| | | } |
| | | |
| | | if ($COMPOSE['forward_uid'] == '*') { |
| | | $index = $storage->index(null, rcmail_sort_column(), rcmail_sort_order()); |
| | | $COMPOSE['forward_uid'] = $index->get(); |
| | |
| | | $name .= '.eml'; |
| | | |
| | | $data = $path = null; |
| | | |
| | | if (!empty($loaded_attachments[$name . 'message/rfc822'])) { |
| | | continue; |
| | | } |
| | | |
| | | // don't load too big attachments into memory |
| | | if ($mem_limit > 0 && $message->size > $mem_limit - $curr_mem) { |
| | |
| | | } |
| | | |
| | | $mimetype = $part->ctype_primary . '/' . $part->ctype_secondary; |
| | | $filename = $part->filename; |
| | | if (!strlen($filename)) { |
| | | if ($mimetype == 'text/html') { |
| | | $filename = rcube_label('htmlmessage'); |
| | | } |
| | | else { |
| | | $filename = 'Part_'.$pid; |
| | | } |
| | | $filename .= '.' . $part->ctype_secondary; |
| | | } |
| | | $filename = rcmail_attachment_name($part); |
| | | |
| | | $attachment = array( |
| | | 'group' => $COMPOSE['id'], |