From 59478e06c25303a790a0840ab2ac30662c4ef781 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Tue, 5 Aug 2014 16:46:22 +0200 Subject: c'est la merde.. --- program/steps/mail/compose.inc | 103 +++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 61 deletions(-) (limited to 'program/steps/mail/compose.inc') diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index e9f638cb1..0130b1c55 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -165,8 +165,6 @@ else if ($msg_uid = $COMPOSE['param']['forward_uid']) { else if ($msg_uid = $COMPOSE['param']['uid']) { $compose_mode = RCUBE_COMPOSE_EDIT; } - -$COMPOSE['mode'] = $compose_mode; $OUTPUT->set_env('compose_mode', $compose_mode); $config_show_sig = $RCMAIL->config->get('show_sig', 1); @@ -188,18 +186,9 @@ $LINE_LENGTH = $RCMAIL->config->get('line_length', 72); if (!empty($msg_uid) && empty($COMPOSE['as_attachment'])) { - $mbox_name = $RCMAIL->storage->get_folder(); - - // set format before rcube_message construction - // use the same format as for the message view - if (isset($_SESSION['msg_formats'][$mbox_name.':'.$msg_uid])) { - $RCMAIL->config->set('prefer_html', $_SESSION['msg_formats'][$mbox_name.':'.$msg_uid]); - } - else { - $prefer_html = $CONFIG['prefer_html'] || $CONFIG['htmleditor'] || $compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT; - $RCMAIL->config->set('prefer_html', $prefer_html); - } - + // similar as in program/steps/mail/show.inc + // re-set 'prefer_html' to have possibility to use html part for compose + $CONFIG['prefer_html'] = $CONFIG['prefer_html'] || $CONFIG['htmleditor'] || $compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT; $MESSAGE = new rcube_message($msg_uid); // make sure message is marked as read @@ -324,8 +313,8 @@ foreach ($parts as $header) { else if (!empty($MESSAGE->headers->from)) $fvalue = $MESSAGE->headers->from; - // Reply to message sent by yourself (#1487074, #1489230) - if (!empty($ident) && in_array($ident['ident'], array($fvalue, $MESSAGE->headers->from))) { + // Reply to message sent by yourself (#1487074) + if (!empty($ident) && $fvalue == $ident['ident']) { $fvalue = $MESSAGE->headers->to; } } @@ -413,7 +402,7 @@ function rcmail_compose_headers($attrib) { global $MESSAGE; - list($form_start,) = get_form_tags($attrib); + list($form_start, $form_end) = get_form_tags($attrib); $out = ''; $part = strtolower($attrib['part']); @@ -477,7 +466,7 @@ function rcmail_compose_headers($attrib) function rcmail_compose_header_from($attrib) { - global $MESSAGE, $OUTPUT, $RCMAIL, $COMPOSE, $compose_mode; + global $MESSAGE, $OUTPUT, $RCMAIL, $compose_mode; // pass the following attributes to the form class $field_attrib = array('name' => '_from'); @@ -488,7 +477,6 @@ function rcmail_compose_header_from($attrib) if (count($MESSAGE->identities)) { $a_signatures = array(); - $identities = array(); $separator = intval($RCMAIL->config->get('reply_mode')) > 0 && ($compose_mode == RCUBE_COMPOSE_REPLY || $compose_mode == RCUBE_COMPOSE_FORWARD) ? '---' : '-- '; @@ -526,21 +514,12 @@ function rcmail_compose_header_from($attrib) $a_signatures[$identity_id]['text'] = $text; $a_signatures[$identity_id]['html'] = $html; } - - // add bcc and reply-to - if (!empty($sql_arr['reply-to'])) { - $identities[$identity_id]['replyto'] = $sql_arr['reply-to']; - } - if (!empty($sql_arr['bcc'])) { - $identities[$identity_id]['bcc'] = $sql_arr['bcc']; - } } $out = $select_from->show($MESSAGE->compose['from']); // add signatures to client $OUTPUT->set_env('signatures', $a_signatures); - $OUTPUT->set_env('identities', $identities); } // no identities, display text input field else { @@ -584,13 +563,13 @@ function rcmail_compose_editor_mode() function rcmail_message_is_html() { - global $RCMAIL, $MESSAGE; - return $RCMAIL->config->get('prefer_html') && ($MESSAGE instanceof rcube_message) && $MESSAGE->has_html_part(true); + global $MESSAGE; + return ($MESSAGE instanceof rcube_message) && $MESSAGE->has_html_part(false, true); } function rcmail_prepare_message_body() { - global $RCMAIL, $MESSAGE, $COMPOSE, $compose_mode, $HTML_MODE; + global $RCMAIL, $MESSAGE, $COMPOSE, $compose_mode, $LINE_LENGTH, $HTML_MODE; // use posted message body if (!empty($_POST['_message'])) { @@ -717,11 +696,6 @@ function rcmail_compose_part_body($part, $isHtml = false) $body = rcmail_remove_signature($body); } } - - if ($part->ctype_parameters['format'] == 'flowed') { - $body = rcube_mime::unfold_flowed($body); - } - // add HTML formatting $body = rcmail_plain_body($body); if ($body) { @@ -742,6 +716,9 @@ function rcmail_compose_part_body($part, $isHtml = false) $txt = new rcube_html2text($body, false, true, $len); $body = $txt->get_text(); } + else if ($part->ctype_secondary == 'enriched') { + $body = rcube_enriched::to_html($body); + } else { if ($part->ctype_secondary == 'plain' && $part->ctype_parameters['format'] == 'flowed') { $body = rcube_mime::unfold_flowed($body); @@ -761,7 +738,7 @@ function rcmail_compose_part_body($part, $isHtml = false) function rcmail_compose_body($attrib) { - global $RCMAIL, $CONFIG, $OUTPUT, $MESSAGE, $compose_mode, $HTML_MODE, $MESSAGE_BODY; + global $RCMAIL, $CONFIG, $OUTPUT, $MESSAGE, $compose_mode, $LINE_LENGTH, $HTML_MODE, $MESSAGE_BODY; list($form_start, $form_end) = get_form_tags($attrib); unset($attrib['form']); @@ -945,7 +922,8 @@ function rcmail_create_forward_body($body, $bodyIsHtml) if (!isset($COMPOSE['forward_attachments']) && is_array($MESSAGE->mime_parts)) $cid_map = rcmail_write_compose_attachments($MESSAGE, $bodyIsHtml); - $date = format_date($MESSAGE->headers->date, $RCMAIL->config->get('date_long')); + $date = format_date($MESSAGE->headers->date, $RCMAIL->config->get('date_long')); + $charset = $RCMAIL->output->get_charset(); if (!$bodyIsHtml) { $prefix = "\n\n\n-------- " . rcube_label('originalmessage') . " --------\n"; @@ -997,7 +975,7 @@ function rcmail_create_forward_body($body, $bodyIsHtml) function rcmail_create_draft_body($body, $bodyIsHtml) { - global $MESSAGE, $COMPOSE; + global $MESSAGE, $OUTPUT, $COMPOSE; /** * add attachments @@ -1053,14 +1031,7 @@ function rcmail_write_compose_attachments(&$message, $bodyIsHtml) { global $RCMAIL, $COMPOSE, $compose_mode; - $loaded_attachments = array(); - foreach ((array)$COMPOSE['attachments'] as $attachment) { - $loaded_attachments[$attachment['name'] . $attachment['mimetype']] = $attachment; - } - - $cid_map = array(); - $messages = array(); - + $cid_map = $messages = array(); foreach ((array)$message->mime_parts as $pid => $part) { if ($part->disposition == 'attachment' || ($part->disposition == 'inline' && $bodyIsHtml) || $part->filename) { @@ -1096,8 +1067,7 @@ function rcmail_write_compose_attachments(&$message, $bodyIsHtml) } } - if (($attachment = $loaded_attachments[rcmail_attachment_name($part) . $part->mimetype]) - || ($attachment = rcmail_save_attachment($message, $pid))) { + if ($attachment = rcmail_save_attachment($message, $pid)) { $COMPOSE['attachments'][$attachment['id']] = $attachment; if ($bodyIsHtml && ($part->content_id || $part->content_location)) { $url = sprintf('%s&_id=%s&_action=display-attachment&_file=rcmfile%s', @@ -1150,7 +1120,7 @@ function rcmail_write_forward_attachments() $names = array(); $loaded_attachments = array(); - foreach ((array)$COMPOSE['attachments'] as $attachment) { + foreach ((array)$COMPOSE['attachments'] as $id => $attachment) { $loaded_attachments[$attachment['name'] . $attachment['mimetype']] = $attachment; } @@ -1370,8 +1340,9 @@ function rcmail_compose_attachment_list($attrib) if (!$attrib['id']) $attrib['id'] = 'rcmAttachmentList'; - $out = "\n"; + $out = "\n"; $jslist = array(); + $button = ''; if (is_array($COMPOSE['attachments'])) { if ($attrib['deleteicon']) { @@ -1380,27 +1351,38 @@ function rcmail_compose_attachment_list($attrib) 'alt' => rcube_label('delete') )); } - else + else if (rcube_utils::get_boolean($attrib['textbuttons'])) { $button = Q(rcube_label('delete')); + } foreach ($COMPOSE['attachments'] as $id => $a_prop) { if (empty($a_prop)) continue; - $out .= html::tag('li', array('id' => 'rcmfile'.$id, 'class' => rcmail_filetype2classname($a_prop['mimetype'], $a_prop['name'])), + $out .= html::tag('li', + array( + 'id' => 'rcmfile'.$id, + 'class' => rcmail_filetype2classname($a_prop['mimetype'], $a_prop['name']), + 'onmouseover' => "rcube_webmail.long_subject_title_ex(this, 0)", + ), html::a(array( 'href' => "#delete", 'title' => rcube_label('delete'), 'onclick' => sprintf("return %s.command('remove-attachment','rcmfile%s', this)", JS_OBJECT_NAME, $id), - 'class' => 'delete'), - $button) . Q($a_prop['name'])); + 'class' => 'delete' + ), + $button + ) . Q($a_prop['name']) + ); - $jslist['rcmfile'.$id] = array('name' => $a_prop['name'], 'complete' => true, 'mimetype' => $a_prop['mimetype']); + $jslist['rcmfile'.$id] = array('name' => $a_prop['name'], 'complete' => true, 'mimetype' => $a_prop['mimetype']); } } if ($attrib['deleteicon']) $COMPOSE['deleteicon'] = $CONFIG['skin_path'] . $attrib['deleteicon']; + else if (rcube_utils::get_boolean($attrib['textbuttons'])) + $COMPOSE['textbuttons'] = true; if ($attrib['cancelicon']) $OUTPUT->set_env('cancelicon', $CONFIG['skin_path'] . $attrib['cancelicon']); if ($attrib['loadingicon']) @@ -1427,7 +1409,7 @@ function rcmail_compose_attachment_form($attrib) $out = html::div($attrib, $OUTPUT->form_tag(array('id' => $attrib['id'].'Frm', 'name' => 'uploadform', 'method' => 'post', 'enctype' => 'multipart/form-data'), - html::div(null, rcmail_compose_attachment_field()) . + html::div(null, rcmail_compose_attachment_field(array('size' => $attrib['attachmentfieldsize']))) . html::div('hint', rcube_label(array('name' => 'maxuploadsize', 'vars' => array('size' => $max_filesize)))) . (get_boolean($attrib['buttons']) ? html::div('buttons', $button->show(rcube_label('close'), array('class' => 'button', 'onclick' => "$('#$attrib[id]').hide()")) . ' ' . @@ -1441,7 +1423,7 @@ function rcmail_compose_attachment_form($attrib) } -function rcmail_compose_attachment_field($attrib = array()) +function rcmail_compose_attachment_field($attrib) { $attrib['type'] = 'file'; $attrib['name'] = '_attachments[]'; @@ -1559,7 +1541,7 @@ function rcmail_editor_selector($attrib) $select->add(Q(rcube_label('plaintoggle')), 'plain'); return $select->show($useHtml ? 'html' : 'plain'); -/* + foreach ($choices as $value => $text) { $attrib['id'] = '_' . $value; $attrib['value'] = $value; @@ -1567,7 +1549,6 @@ function rcmail_editor_selector($attrib) } return $selector; -*/ } @@ -1661,7 +1642,7 @@ function rcmail_addressbook_list($attrib = array()) $class_name .= ' ' . $source['class_name']; $out .= sprintf($line_templ, - html_identifier($id,true), + html_identifier($id), $class_name, $source['id'], $js_id, (!empty($source['name']) ? $source['name'] : $id)); -- cgit v1.2.3