summaryrefslogtreecommitdiff
path: root/program/steps/mail/compose.inc
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps/mail/compose.inc')
-rw-r--r--program/steps/mail/compose.inc224
1 files changed, 66 insertions, 158 deletions
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 646d2bcd1..0130b1c55 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -54,12 +54,30 @@ if (!is_array($COMPOSE))
$COMPOSE_ID = uniqid(mt_rand());
$_SESSION['compose_data_'.$COMPOSE_ID] = array(
'id' => $COMPOSE_ID,
- 'param' => rcube_utils::request2param(RCUBE_INPUT_GET, 'task|action', true),
+ 'param' => request2param(RCUBE_INPUT_GET),
'mailbox' => $RCMAIL->storage->get_folder(),
);
$COMPOSE =& $_SESSION['compose_data_'.$COMPOSE_ID];
- rcmail_process_compose_params($COMPOSE);
+ // process values like "mailto:foo@bar.com?subject=new+message&cc=another"
+ if ($COMPOSE['param']['to']) {
+ // #1486037: remove "mailto:" prefix
+ $COMPOSE['param']['to'] = preg_replace('/^mailto:/i', '', $COMPOSE['param']['to']);
+ $mailto = explode('?', $COMPOSE['param']['to']);
+ if (count($mailto) > 1) {
+ $COMPOSE['param']['to'] = $mailto[0];
+ parse_str($mailto[1], $query);
+ foreach ($query as $f => $val)
+ $COMPOSE['param'][$f] = $val;
+ }
+ }
+
+ // select folder where to save the sent message
+ $COMPOSE['param']['sent_mbox'] = $RCMAIL->config->get('sent_mbox');
+
+ // pipe compose parameters thru plugins
+ $plugin = $RCMAIL->plugins->exec_hook('message_compose', $COMPOSE);
+ $COMPOSE['param'] = array_merge($COMPOSE['param'], $plugin['param']);
// add attachments listed by message_compose hook
if (is_array($plugin['attachments'])) {
@@ -109,8 +127,7 @@ if (!is_array($COMPOSE))
$OUTPUT->add_label('nosubject', 'nosenderwarning', 'norecipientwarning', 'nosubjectwarning', 'cancel',
'nobodywarning', 'notsentwarning', 'notuploadedwarning', 'savingmessage', 'sendingmessage',
'messagesaved', 'converting', 'editorwarning', 'searching', 'uploading', 'uploadingmany',
- 'fileuploaderror', 'sendmessage', 'savenewresponse', 'responsename', 'responsetext', 'save',
- 'savingresponse');
+ 'fileuploaderror', 'sendmessage');
$OUTPUT->set_env('compose_id', $COMPOSE['id']);
$OUTPUT->set_pagetitle(rcube_label('compose'));
@@ -131,11 +148,6 @@ if ($font && !is_array($font)) {
$OUTPUT->set_env('default_font', $font);
}
-// default font size for HTML editor
-if ($font_size = $RCMAIL->config->get('default_font_size')) {
- $OUTPUT->set_env('default_font_size', $font_size);
-}
-
// get reference message and set compose mode
if ($msg_uid = $COMPOSE['param']['draft_uid']) {
$compose_mode = RCUBE_COMPOSE_DRAFT;
@@ -153,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);
@@ -176,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
@@ -243,14 +244,6 @@ if (!empty($msg_uid) && empty($COMPOSE['as_attachment']))
}
else {
$MESSAGE = new stdClass();
-
- // apply mailto: URL parameters
- if (!empty($COMPOSE['param']['in-reply-to'])) {
- $COMPOSE['reply_msgid'] = '<' . $COMPOSE['param']['in-reply-to'] . '>';
- }
- if (!empty($COMPOSE['param']['references'])) {
- $COMPOSE['references'] = $COMPOSE['param']['references'];
- }
}
$MESSAGE->compose = array();
@@ -320,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;
}
}
@@ -405,58 +398,11 @@ $MESSAGE_BODY = rcmail_prepare_message_body();
/****** compose mode functions ********/
-// process compose request parameters
-function rcmail_process_compose_params(&$COMPOSE)
-{
- if ($COMPOSE['param']['to']) {
- $mailto = explode('?', $COMPOSE['param']['to'], 2);
-
- // #1486037: remove "mailto:" prefix
- $COMPOSE['param']['to'] = preg_replace('/^mailto:/i', '', $mailto[0]);
-
- // Supported case-insensitive tokens in mailto URL
- $url_tokens = array('to', 'cc', 'bcc', 'reply-to', 'in-reply-to', 'references', 'subject', 'body');
-
- if (!empty($mailto[1])) {
- parse_str($mailto[1], $query);
- foreach ($query as $f => $val) {
- if (($key = array_search(strtolower($f), $url_tokens)) !== false) {
- $f = $url_tokens[$key];
- }
-
- // merge mailto: addresses with addresses from 'to' parameter
- if ($f == 'to' && !empty($COMPOSE['param']['to'])) {
- $to_addresses = rcube_mime::decode_address_list($COMPOSE['param']['to'], null, true, null, true);
- $add_addresses = rcube_mime::decode_address_list($val, null, true);
- foreach ($add_addresses as $addr) {
- if (!in_array($addr['mailto'], $to_addresses)) {
- $to_addresses[] = $addr['mailto'];
- $COMPOSE['param']['to'] = (!empty($to_addresses) ? ', ' : '') . $addr['string'];
- }
- }
- }
- else {
- $COMPOSE['param'][$f] = $val;
- }
- }
- }
- }
-
- $RCMAIL = rcmail::get_instance();
-
- // select folder where to save the sent message
- $COMPOSE['param']['sent_mbox'] = $RCMAIL->config->get('sent_mbox');
-
- // pipe compose parameters thru plugins
- $plugin = $RCMAIL->plugins->exec_hook('message_compose', $COMPOSE);
- $COMPOSE['param'] = array_merge($COMPOSE['param'], $plugin['param']);
-}
-
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']);
@@ -520,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');
@@ -531,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) ? '---' : '-- ';
@@ -569,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 {
@@ -627,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'])) {
@@ -760,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) {
@@ -785,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);
@@ -804,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']);
@@ -853,14 +787,29 @@ function rcmail_compose_body($attrib)
// Set language list
if (!empty($CONFIG['enable_spellcheck'])) {
- $engine = new rcube_spellchecker();
+ $engine = $RCMAIL->config->get('spellcheck_engine','googie');
$dictionary = (bool) $RCMAIL->config->get('spellcheck_dictionary');
- $spellcheck_langs = $engine->languages();
- $lang = $_SESSION['language'];
+ $spellcheck_langs = (array) $RCMAIL->config->get('spellcheck_languages',
+ array('da'=>'Dansk', 'de'=>'Deutsch', 'en' => 'English', 'es'=>'Español',
+ 'fr'=>'Français', 'it'=>'Italiano', 'nl'=>'Nederlands', 'pl'=>'Polski',
+ 'pt'=>'Português', 'ru'=>'Русский', 'fi'=>'Suomi', 'sv'=>'Svenska'));
+
+ // googie works only with two-letter codes
+ if ($engine == 'googie') {
+ $lang = strtolower(substr($_SESSION['language'], 0, 2));
+
+ $spellcheck_langs_googie = array();
+ foreach ($spellcheck_langs as $key => $name)
+ $spellcheck_langs_googie[strtolower(substr($key,0,2))] = $name;
+ $spellcheck_langs = $spellcheck_langs_googie;
+ }
+ else {
+ $lang = $_SESSION['language'];
- // if not found in the list, try with two-letter code
- if (!$spellcheck_langs[$lang])
- $lang = strtolower(substr($lang, 0, 2));
+ // if not found in the list, try with two-letter code
+ if (!$spellcheck_langs[$lang])
+ $lang = strtolower(substr($lang, 0, 2));
+ }
if (!$spellcheck_langs[$lang])
$lang = 'en';
@@ -973,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";
@@ -1025,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
@@ -1081,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) {
@@ -1124,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',
@@ -1178,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;
}
@@ -1467,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()")) . ' ' .
@@ -1481,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[]';
@@ -1599,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;
@@ -1607,7 +1549,6 @@ function rcmail_editor_selector($attrib)
}
return $selector;
-*/
}
@@ -1701,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));
@@ -1743,38 +1684,6 @@ function compose_file_drop_area($attrib)
}
-/**
- *
- */
-function rcmail_compose_responses_list($attrib)
-{
- global $RCMAIL, $OUTPUT;
-
- $attrib += array('id' => 'rcmresponseslist', 'tagname' => 'ul', 'cols' => 1);
-
- $jsenv = array();
- $list = new html_table($attrib);
- foreach ($RCMAIL->get_compose_responses(true) as $response) {
- $key = $response['key'];
- $item = html::a(array(
- 'href '=> '#'.urlencode($response['name']),
- 'class' => rtrim('insertresponse ' . $attrib['itemclass']),
- 'unselectable' => 'on',
- 'rel' => $key,
- ), Q($response['name']));
-
- $jsenv[$key] = $response;
- $list->add(array(), $item);
- }
-
- // set client env
- $OUTPUT->set_env('textresponses', $jsenv);
- $OUTPUT->add_gui_object('responseslist', $attrib['id']);
-
- return $list->show();
-}
-
-
// register UI objects
$OUTPUT->add_handlers(array(
'composeheaders' => 'rcmail_compose_headers',
@@ -1791,7 +1700,6 @@ $OUTPUT->add_handlers(array(
'storetarget' => 'rcmail_store_target_selection',
'addressbooks' => 'rcmail_addressbook_list',
'addresslist' => 'rcmail_contacts_list',
- 'responseslist' => 'rcmail_compose_responses_list',
));
$OUTPUT->send('compose');