summaryrefslogtreecommitdiff
path: root/program/steps/mail
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps/mail')
-rw-r--r--program/steps/mail/check_recent.inc9
-rw-r--r--program/steps/mail/compose.inc224
-rw-r--r--program/steps/mail/func.inc420
-rw-r--r--program/steps/mail/get.inc109
-rw-r--r--program/steps/mail/list.inc1
-rw-r--r--program/steps/mail/list_contacts.inc29
-rw-r--r--program/steps/mail/move_del.inc11
-rw-r--r--program/steps/mail/sendmail.inc86
-rw-r--r--program/steps/mail/show.inc58
9 files changed, 357 insertions, 590 deletions
diff --git a/program/steps/mail/check_recent.inc b/program/steps/mail/check_recent.inc
index 8c0b1ffc0..d3c14a38d 100644
--- a/program/steps/mail/check_recent.inc
+++ b/program/steps/mail/check_recent.inc
@@ -52,12 +52,12 @@ foreach ($a_mailboxes as $mbox_name) {
}
// Get mailbox status
- $status = $RCMAIL->storage->folder_status($mbox_name, $diff);
+ $status = $RCMAIL->storage->folder_status($mbox_name);
if ($status & 1) {
// trigger plugin hook
$RCMAIL->plugins->exec_hook('new_messages',
- array('mailbox' => $mbox_name, 'is_current' => $is_current, 'diff' => $diff));
+ array('mailbox' => $mbox_name, 'is_current' => $is_current));
}
rcmail_send_unread_count($mbox_name, true, null,
@@ -81,10 +81,9 @@ foreach ($a_mailboxes as $mbox_name) {
if (empty($_GET['_list']))
continue;
- // get overall message count; allow caching because rcube_storage::folder_status()
- // did a refresh but only in list mode
+ // get overall message count; allow caching because rcube_storage::folder_status() did a refresh
$list_mode = $RCMAIL->storage->get_threading() ? 'THREADS' : 'ALL';
- $all_count = $RCMAIL->storage->count($mbox_name, $list_mode, $list_mode == 'THREADS', false);
+ $all_count = $RCMAIL->storage->count($mbox_name, $list_mode, false, false);
$page = $RCMAIL->storage->get_page();
$page_size = $RCMAIL->storage->get_pagesize();
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');
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 78a977b82..2938e91e1 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -89,15 +89,13 @@ if (empty($RCMAIL->action) || $RCMAIL->action == 'list') {
}
$threading = (bool) $RCMAIL->storage->get_threading();
- $delimiter = $RCMAIL->storage->get_hierarchy_delimiter();
// set current mailbox and some other vars in client environment
$OUTPUT->set_env('mailbox', $mbox_name);
$OUTPUT->set_env('pagesize', $RCMAIL->storage->get_pagesize());
- $OUTPUT->set_env('delimiter', $delimiter);
+ $OUTPUT->set_env('delimiter', $RCMAIL->storage->get_hierarchy_delimiter());
$OUTPUT->set_env('threading', $threading);
$OUTPUT->set_env('threads', $threading || $RCMAIL->storage->get_capability('THREAD'));
- $OUTPUT->set_env('reply_all_mode', (int) $RCMAIL->config->get('reply_all_mode'));
$OUTPUT->set_env('preview_pane_mark_read', $RCMAIL->config->get('preview_pane_mark_read', 0));
if ($RCMAIL->storage->get_capability('QUOTA')) {
$OUTPUT->set_env('quota', true);
@@ -121,48 +119,11 @@ if (empty($RCMAIL->action) || $RCMAIL->action == 'list') {
if (!$OUTPUT->ajax_call)
$OUTPUT->add_label('checkingmail', 'deletemessage', 'movemessagetotrash',
'movingmessage', 'copyingmessage', 'deletingmessage', 'markingmessage',
- 'copy', 'move', 'quota', 'replyall', 'replylist', 'importwait');
+ 'copy', 'move', 'quota');
- $pagetitle = $RCMAIL->localize_foldername($RCMAIL->storage->mod_folder($mbox_name), true);
- $pagetitle = str_replace($delimiter, " \xC2\xBB ", $pagetitle);
-
- $OUTPUT->set_pagetitle($pagetitle);
+ $OUTPUT->set_pagetitle(rcmail_localize_foldername($RCMAIL->storage->mod_folder($mbox_name)));
}
-// register UI objects
-$OUTPUT->add_handlers(array(
- 'mailboxlist' => 'rcmail_mailbox_list',
- 'messages' => 'rcmail_message_list',
- 'messagecountdisplay' => 'rcmail_messagecount_display',
- 'quotadisplay' => 'rcmail_quota_display',
- 'mailboxname' => 'rcmail_mailbox_name_display',
- 'messageheaders' => 'rcmail_message_headers',
- 'messagefullheaders' => 'rcmail_message_full_headers',
- 'messagebody' => 'rcmail_message_body',
- 'messagecontentframe' => 'rcmail_messagecontent_frame',
- 'messageimportform' => 'rcmail_message_import_form',
- 'searchfilter' => 'rcmail_search_filter',
- 'searchform' => array($OUTPUT, 'search_form'),
-));
-
-// register action aliases
-$RCMAIL->register_action_map(array(
- 'refresh' => 'check_recent.inc',
- 'preview' => 'show.inc',
- 'print' => 'show.inc',
- 'move' => 'move_del.inc',
- 'delete' => 'move_del.inc',
- 'send' => 'sendmail.inc',
- 'expunge' => 'folders.inc',
- 'purge' => 'folders.inc',
- 'remove-attachment' => 'attachments.inc',
- 'display-attachment' => 'attachments.inc',
- 'upload' => 'attachments.inc',
- 'group-expand' => 'autocomplete.inc',
-));
-
-
-
/**
* Returns 'to' if current folder is configured Sent or Drafts
* or their subfolders, otherwise returns 'from'.
@@ -178,9 +139,7 @@ function rcmail_message_list_smart_column_name()
$sent_mbox = $RCMAIL->config->get('sent_mbox');
$drafts_mbox = $RCMAIL->config->get('drafts_mbox');
- if ((strpos($mbox.$delim, $sent_mbox.$delim) === 0 || strpos($mbox.$delim, $drafts_mbox.$delim) === 0)
- && strtoupper($mbox) != 'INBOX'
- ) {
+ if (strpos($mbox.$delim, $sent_mbox.$delim) === 0 || strpos($mbox.$delim, $drafts_mbox.$delim) === 0) {
return 'to';
}
@@ -261,7 +220,7 @@ function rcmail_message_list($attrib)
if (!in_array('threads', $a_show_cols))
array_unshift($a_show_cols, 'threads');
- $_SESSION['skin_path'] = $CONFIG['skin_path'];
+ $skin_path = $_SESSION['skin_path'] = $CONFIG['skin_path'];
// set client env
$OUTPUT->add_gui_object('messagelist', $attrib['id']);
@@ -273,13 +232,15 @@ function rcmail_message_list($attrib)
$OUTPUT->include_script('list.js');
- $table = new html_table($attrib);
- if (!$attrib['noheader']) {
- foreach (rcmail_message_list_head($attrib, $a_show_cols) as $cell)
- $table->add_header(array('class' => $cell['className'], 'id' => $cell['id']), $cell['html']);
- }
+ $thead = '';
+ foreach (rcmail_message_list_head($attrib, $a_show_cols) as $cell)
+ $thead .= html::tag('td', array('class' => $cell['className'], 'id' => $cell['id']), $cell['html']);
- return $table->show();
+ return html::tag('table',
+ $attrib,
+ html::tag('thead', null, html::tag('tr', null, $thead)) .
+ html::tag('tbody', null, ''),
+ array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary'));
}
@@ -326,7 +287,7 @@ function rcmail_js_message_list($a_headers, $insert_top=FALSE, $a_show_cols=null
$thead = $head_replace ? rcmail_message_list_head($_SESSION['list_attrib'], $a_show_cols) : NULL;
// get name of smart From/To column in folder context
- if (array_search('fromto', $a_show_cols) !== false) {
+ if (($f = array_search('fromto', $a_show_cols)) !== false) {
$smart_col = rcmail_message_list_smart_column_name();
}
@@ -342,7 +303,7 @@ function rcmail_js_message_list($a_headers, $insert_top=FALSE, $a_show_cols=null
}
// loop through message headers
- foreach ($a_headers as $header) {
+ foreach ($a_headers as $n => $header) {
if (empty($header))
continue;
@@ -416,6 +377,7 @@ function rcmail_message_list_head($attrib, $a_show_cols)
global $RCMAIL;
$skin_path = $_SESSION['skin_path'];
+ $image_tag = html::img(array('src' => "%s%s", 'alt' => "%s"));
// check to see if we have some settings for sorting
$sort_col = $_SESSION['sort_col'];
@@ -451,7 +413,7 @@ function rcmail_message_list_head($attrib, $a_show_cols)
$cells = array();
// get name of smart From/To column in folder context
- if (array_search('fromto', $a_show_cols) !== false) {
+ if (($f = array_search('fromto', $a_show_cols)) !== false) {
$smart_col = rcmail_message_list_smart_column_name();
}
@@ -642,8 +604,6 @@ function rcmail_check_safe(&$message)
$message->set_safe(true);
}
}
-
- $RCMAIL->plugins->exec_hook('message_check_safe', array('message' => $message));
break;
case 2: // always
@@ -743,10 +703,7 @@ function rcmail_print_body($part, $p = array())
+ $p + array('safe' => false, 'plain' => false, 'inline_html' => true));
// convert html to text/plain
- if ($data['plain'] && ($data['type'] == 'html' || $data['type'] == 'enriched')) {
- if ($data['type'] == 'enriched') {
- $data['body'] = rcube_enriched::to_html($data['body']);
- }
+ if ($data['type'] == 'html' && $data['plain']) {
$txt = new rcube_html2text($data['body'], false, true);
$body = $txt->get_text();
$part->ctype_secondary = 'plain';
@@ -772,13 +729,8 @@ function rcmail_print_body($part, $p = array())
unset($data['body']);
// plaintext postprocessing
- if ($part->ctype_secondary == 'plain') {
- if ($part->ctype_secondary == 'plain' && $part->ctype_parameters['format'] == 'flowed') {
- $body = rcube_mime::unfold_flowed($body);
- }
-
- $body = rcmail_plain_body($body);
- }
+ if ($part->ctype_secondary == 'plain')
+ $body = rcmail_plain_body($body, $part->ctype_parameters['format'] == 'flowed');
// allow post-processing of the message body
$data = $RCMAIL->plugins->exec_hook('message_part_after',
@@ -792,16 +744,16 @@ function rcmail_print_body($part, $p = array())
* Handle links and citation marks in plain text message
*
* @param string Plain text string
+ * @param boolean Text uses format=flowed
*
* @return string Formatted HTML string
*/
-function rcmail_plain_body($body)
+function rcmail_plain_body($body, $flowed=false)
{
global $RCMAIL;
// make links and email-addresses clickable
- $attribs = array('link_attribs' => array('rel' => 'noreferrer', 'target' => '_blank'));
- $replacer = new rcmail_string_replacer($attribs);
+ $replacer = new rcmail_string_replacer;
// search for patterns like links and e-mail addresses and replace with tokens
$body = $replacer->replace($body);
@@ -827,10 +779,48 @@ function rcmail_plain_body($body)
str_repeat('</blockquote>', $quote_level - $q))) . $body[$n];
$last = $n;
}
+ else if ($flowed) {
+ // previous line is flowed
+ if (isset($body[$last]) && $body[$n]
+ && $body[$last][strlen($body[$last])-1] == ' ') {
+ // merge lines
+ $body[$last] .= $body[$n];
+ unset($body[$n]);
+ }
+ else {
+ $last = $n;
+ }
+ }
}
else {
$q = 0;
- if ($quote_level > 0)
+ if ($flowed) {
+ // sig separator - line is fixed
+ if ($body[$n] == '-- ') {
+ $last = $last_sig = $n;
+ }
+ else {
+ // remove space-stuffing
+ if ($body[$n][0] == ' ')
+ $body[$n] = substr($body[$n], 1);
+
+ // previous line is flowed?
+ if (isset($body[$last]) && $body[$n]
+ && $last !== $last_sig
+ && $body[$last][strlen($body[$last])-1] == ' '
+ ) {
+ $body[$last] .= $body[$n];
+ unset($body[$n]);
+ }
+ else {
+ $last = $n;
+ }
+ }
+ if ($quote_level > 0)
+ $body[$last] = $replacer->get_replacement($replacer->add(
+ str_repeat('</blockquote>', $quote_level))) . $body[$last];
+ }
+ else if ($quote_level > 0)
$body[$n] = $replacer->get_replacement($replacer->add(
str_repeat('</blockquote>', $quote_level))) . $body[$n];
}
@@ -901,7 +891,7 @@ function rcmail_washtml_callback($tagname, $attrib, $content, $washtml)
*/
function rcmail_message_headers($attrib, $headers=null)
{
- global $MESSAGE, $PRINT_MODE, $RCMAIL;
+ global $OUTPUT, $MESSAGE, $PRINT_MODE, $RCMAIL;
static $sa_attrib;
// keep header table attrib
@@ -1086,7 +1076,7 @@ function rcmail_message_body($attrib)
$header_attrib[$regs[1]] = $value;
if (!empty($MESSAGE->parts)) {
- foreach ($MESSAGE->parts as $part) {
+ foreach ($MESSAGE->parts as $i => $part) {
if ($part->type == 'headers') {
$out .= html::div('message-partheaders', rcmail_message_headers(sizeof($header_attrib) ? $header_attrib : null, $part->headers));
}
@@ -1190,9 +1180,10 @@ function rcmail_message_body($attrib)
$show_link = array(
'href' => $MESSAGE->get_part_url($attach_prop->mime_id, false),
'onclick' => sprintf(
- 'return %s.command(\'load-attachment\',\'%s\',this)',
+ 'return %s.command(\'load-attachment\',{part:\'%s\', mimetype:\'%s\'},this)',
JS_OBJECT_NAME,
- $attach_prop->mime_id)
+ $attach_prop->mime_id,
+ $mimetype)
);
$out .= html::p('image-attachment',
html::a($show_link + array('class' => 'image-link', 'style' => sprintf('width:%dpx', $thumbnail_size)),
@@ -1378,15 +1369,18 @@ function rcmail_html4inline($body, $container_id, $body_id='', &$attributes=null
/**
- * parse link (a, link, area) attributes and set correct target
+ * parse link attributes and set correct target
*/
function rcmail_alter_html_link($matches)
{
global $RCMAIL;
- $tag = strtolower($matches[1]);
+ // Support unicode/punycode in top-level domain part
+ $EMAIL_PATTERN = '([a-z0-9][a-z0-9\-\.\+\_]*@[^&@"\'.][^@&"\']*\\.([^\\x00-\\x40\\x5b-\\x60\\x7b-\\x7f]{2,}|xn--[a-z0-9]{2,}))';
+
+ $tag = $matches[1];
$attrib = parse_attrib_string($matches[2]);
- $end = '>';
+ $end = '>';
// Remove non-printable characters in URL (#1487805)
if ($attrib['href'])
@@ -1398,36 +1392,12 @@ function rcmail_alter_html_link($matches)
$attrib['href'] = $RCMAIL->url(array('task' => 'utils', 'action' => 'modcss', 'u' => $tempurl, 'c' => $GLOBALS['rcmail_html_container_id']));
$end = ' />';
}
- else if (preg_match('/^mailto:(.+)/i', $attrib['href'], $mailto)) {
- list($mailto, $url) = explode('?', html_entity_decode($mailto[1], ENT_QUOTES, 'UTF-8'), 2);
-
- $url = urldecode($url);
- $mailto = urldecode($mailto);
- $addresses = rcube_mime::decode_address_list($mailto, null, true);
- $mailto = array();
-
- // do sanity checks on recipients
- foreach ($addresses as $idx => $addr) {
- if (rcube_utils::check_email($addr['mailto'], false)) {
- $addresses[$idx] = $addr['mailto'];
- $mailto[] = $addr['string'];
- }
- else {
- unset($addresses[$idx]);
- }
- }
-
- if (!empty($addresses)) {
- $attrib['href'] = 'mailto:' . implode(',', $addresses);
- $attrib['onclick'] = sprintf(
- "return %s.command('compose','%s',this)",
- JS_OBJECT_NAME,
- JQ(implode(',', $mailto) . ($url ? "?$url" : '')));
- }
- else {
- $attrib['href'] = '#NOP';
- $attrib['onclick'] = '';
- }
+ else if (preg_match('/^mailto:'.$EMAIL_PATTERN.'(\?[^"\'>]+)?/i', $attrib['href'], $mailto)) {
+ $attrib['href'] = $mailto[0];
+ $attrib['onclick'] = sprintf(
+ "return %s.command('compose','%s',this)",
+ JS_OBJECT_NAME,
+ JQ($mailto[1].$mailto[3]));
}
else if (empty($attrib['href']) && !$attrib['name']) {
$attrib['href'] = './#NOP';
@@ -1437,11 +1407,6 @@ function rcmail_alter_html_link($matches)
$attrib['target'] = '_blank';
}
- // Better security by adding rel="noreferrer" (#1484686)
- if (($tag == 'a' || $tag == 'area') && $attrib['href'] && $attrib['href'][0] != '#') {
- $attrib['rel'] = 'noreferrer';
- }
-
// allowed attributes for a|link|area tags
$allow = array('href','name','target','onclick','id','class','style','title',
'rel','type','media','alt','coords','nohref','hreflang','shape');
@@ -1465,8 +1430,7 @@ function rcmail_address_string($input, $max=null, $linked=false, $addicon=null,
$c = count($a_parts);
$j = 0;
$out = '';
- $allvalues = array();
- $show_email = $RCMAIL->config->get('message_show_email');
+ $allvalues = array();
if ($addicon && !isset($_SESSION['writeable_abook'])) {
$_SESSION['writeable_abook'] = $RCMAIL->get_address_sources(true) ? true : false;
@@ -1480,7 +1444,7 @@ function rcmail_address_string($input, $max=null, $linked=false, $addicon=null,
$valid = check_email($mailto, false);
// phishing email prevention (#1488981), e.g. "valid@email.addr <phishing@email.addr>"
- if (!$show_email && $valid && $name && $name != $mailto && strpos($name, '@')) {
+ if ($name && $valid && $name != $mailto && strpos($name, '@')) {
$name = '';
}
@@ -1492,25 +1456,19 @@ function rcmail_address_string($input, $max=null, $linked=false, $addicon=null,
$mailto = rcube_idn_to_utf8($mailto);
if ($PRINT_MODE) {
- $address = sprintf('%s &lt;%s&gt;', Q($name), Q($mailto));
+ $out .= ($out ? ', ' : '') . sprintf('%s &lt;%s&gt;', Q($name), $mailto);
+ // for printing we display all addresses
+ continue;
}
else if ($valid) {
if ($linked) {
- $attrs = array(
- 'href' => 'mailto:' . $mailto,
- 'onclick' => sprintf("return %s.command('compose','%s',this)", JS_OBJECT_NAME, JQ(format_email_recipient($mailto, $name))),
- 'class' => "rcmContactAddress",
- );
-
- if ($show_email && $name && $mailto) {
- $content = Q($name ? sprintf('%s <%s>', $name, $mailto) : $mailto);
- }
- else {
- $content = Q($name ? $name : $mailto);
- $attrs['title'] = $mailto;
- }
-
- $address = html::a($attrs, $content);
+ $address = html::a(array(
+ 'href' => 'mailto:'.$mailto,
+ 'onclick' => sprintf("return %s.command('compose','%s',this)", JS_OBJECT_NAME, JQ($mailto)),
+ 'title' => $mailto,
+ 'class' => "rcmContactAddress",
+ ),
+ Q($name ? $name : $mailto));
}
else {
$address = html::span(array('title' => $mailto, 'class' => "rcmContactAddress"),
@@ -1556,15 +1514,6 @@ function rcmail_address_string($input, $max=null, $linked=false, $addicon=null,
}
if ($moreadrs) {
- if ($PRINT_MODE) {
- $out .= ' ' . html::a(array(
- 'href' => '#more',
- 'class' => 'morelink',
- 'onclick' => '$(this).hide().next().show()',
- ), Q(rcube_label(array('name' => 'andnmore', 'vars' => array('nr' => $moreadrs))))) .
- html::span(array('style' => 'display:none'), join(', ', $allvalues));
- }
- else {
$out .= ' ' . html::a(array(
'href' => '#more',
'class' => 'morelink',
@@ -1574,7 +1523,6 @@ function rcmail_address_string($input, $max=null, $linked=false, $addicon=null,
JQ($title))
),
Q(rcube_label(array('name' => 'andnmore', 'vars' => array('nr' => $moreadrs)))));
- }
}
return $out;
@@ -1647,6 +1595,45 @@ function rcmail_draftinfo_decode($str)
}
+function rcmail_message_part_controls($attrib)
+{
+ global $MESSAGE, $RCMAIL;
+
+ $part = asciiwords(get_input_value('_part', RCUBE_INPUT_GPC));
+ if (!is_object($MESSAGE) || !is_array($MESSAGE->parts) || !($_GET['_uid'] && $_GET['_part']) || !$MESSAGE->mime_parts[$part])
+ return '';
+
+ $part = $MESSAGE->mime_parts[$part];
+ $table = new html_table(array('cols' => 3));
+
+ $filename = rcmail_attachment_name($part);
+
+ if (!empty($filename)) {
+ $table->add('title', Q(rcube_label('filename')));
+ $table->add('header', Q($filename));
+ $table->add('download-link', html::a(array('href' => './?'.str_replace('_frame=', '_download=', $_SERVER['QUERY_STRING'])), Q(rcube_label('download'))));
+ }
+
+ $table->add('title', Q(rcube_label('filesize')));
+ $table->add('header', Q($RCMAIL->message_part_size($part)));
+
+ return $table->show($attrib);
+}
+
+
+function rcmail_message_part_frame($attrib)
+{
+ global $MESSAGE;
+
+ $part = $MESSAGE->mime_parts[asciiwords(get_input_value('_part', RCUBE_INPUT_GPC))];
+ $ctype_primary = strtolower($part->ctype_primary);
+
+ $attrib['src'] = './?' . str_replace('_frame=', ($ctype_primary=='text' ? '_embed=' : '_preload='), $_SERVER['QUERY_STRING']);
+
+ return html::iframe($attrib);
+}
+
+
/**
* clear message composing settings
*/
@@ -1734,7 +1721,8 @@ function rcmail_send_mdn($message, &$smtp_error)
$sent = rcmail_deliver_message($compose, $identity['email'], $mailto, $smtp_error, $body_file, $options);
- if ($sent) {
+ if ($sent)
+ {
$RCMAIL->storage->set_flag($message->uid, 'MDNSENT');
return true;
}
@@ -1776,34 +1764,28 @@ function rcmail_identity_select($MESSAGE, $identities = null, $compose_mode = 'r
}
}
- // decode From: address
- $from = rcube_mime::decode_address_list($MESSAGE->headers->from, null, true, $MESSAGE->headers->charset);
- $from = array_shift($from);
- $from['mailto'] = strtolower($from['mailto']);
-
- $from_idx = null;
- $found_idx = array('to' => null, 'from' => null);
- $check_from = in_array($compose_mode, array('draft', 'edit', 'reply'));
+ $from_idx = null;
+ $found_idx = null;
+ $default_identity = 0; // default identity is always first on the list
// Select identity
foreach ($identities as $idx => $ident) {
- // use From: header when in edit/draft or reply-to-self
- if ($check_from && $from['mailto'] == strtolower($ident['email_ascii'])) {
- // remember first matching identity address
- if ($found_idx['from'] === null) {
- $found_idx['from'] = $idx;
- }
- // match identity name
- if ($from['name'] && $ident['name'] && $from['name'] == $ident['name']) {
+ // use From header
+ if (in_array($compose_mode, array('draft', 'edit'))) {
+ if ($MESSAGE->headers->from == $ident['ident']) {
$from_idx = $idx;
break;
}
}
- // use replied/forwarded message recipients
+ // reply to yourself
+ else if ($compose_mode == 'reply' && $MESSAGE->headers->from == $ident['ident']) {
+ $from_idx = $idx;
+ break;
+ }
+ // use replied message recipients
else if (($found = array_search(strtolower($ident['email_ascii']), $a_recipients)) !== false) {
- // remember first matching identity address
- if ($found_idx['to'] === null) {
- $found_idx['to'] = $idx;
+ if ($found_idx === null) {
+ $found_idx = $idx;
}
// match identity name
if ($a_names[$found] && $ident['name'] && $a_names[$found] == $ident['name']) {
@@ -1813,10 +1795,9 @@ function rcmail_identity_select($MESSAGE, $identities = null, $compose_mode = 'r
}
}
- // If matching by name+address didn't find any matches,
- // get first found identity (address) if any
+ // If matching by name+address doesn't found any matches, get first found address (identity)
if ($from_idx === null) {
- $from_idx = $found_idx['from'] !== null ? $found_idx['from'] : $found_idx['to'];
+ $from_idx = $found_idx;
}
// Try Return-Path
@@ -1841,14 +1822,27 @@ function rcmail_identity_select($MESSAGE, $identities = null, $compose_mode = 'r
}
}
- // See identity_select plugin for example usage of this hook
- $plugin = rcmail::get_instance()->plugins->exec_hook('identity_select',
- array('message' => $MESSAGE, 'identities' => $identities, 'selected' => $from_idx));
+ // Fallback using Delivered-To
+ if ($from_idx === null && ($delivered_to = $MESSAGE->headers->others['delivered-to'])) {
+ foreach ($identities as $idx => $ident) {
+ if (in_array($ident['email_ascii'], (array)$delivered_to)) {
+ $from_idx = $idx;
+ break;
+ }
+ }
+ }
- $selected = $plugin['selected'];
+ // Fallback using Envelope-To
+ if ($from_idx === null && ($envelope_to = $MESSAGE->headers->others['envelope-to'])) {
+ foreach ($identities as $idx => $ident) {
+ if (in_array($ident['email_ascii'], (array)$envelope_to)) {
+ $from_idx = $idx;
+ break;
+ }
+ }
+ }
- // default identity is always first on the list
- return $identities[$selected !== null ? $selected : 0];
+ return $identities[$from_idx !== null ? $from_idx : $default_identity];
}
// Fixes some content-type names
@@ -1905,15 +1899,13 @@ function rcmail_search_filter($attrib)
$attrib['onchange'] = JS_OBJECT_NAME.'.filter_mailbox(this.value)';
- // Content-Type values of messages with attachments
- // the same as in app.js:add_message_row()
- $ctypes = array('application/', 'multipart/m', 'multipart/signed', 'multipart/report');
-
- // Build search string of "with attachment" filter
- $attachment = str_repeat(' OR', count($ctypes)-1);
- foreach ($ctypes as $type) {
- $attachment .= ' HEADER Content-Type ' . rcube_imap_generic::escape($type);
- }
+ /*
+ RFC3501 (6.4.4): 'ALL', 'RECENT',
+ 'ANSWERED', 'DELETED', 'FLAGGED', 'SEEN',
+ 'UNANSWERED', 'UNDELETED', 'UNFLAGGED', 'UNSEEN',
+ 'NEW', // = (RECENT UNSEEN)
+ 'OLD' // = NOT RECENT
+ */
$select_filter = new html_select($attrib);
$select_filter->add(rcube_label('all'), 'ALL');
@@ -1924,7 +1916,6 @@ function rcmail_search_filter($attrib)
$select_filter->add(rcube_label('deleted'), 'DELETED');
$select_filter->add(rcube_label('undeleted'), 'UNDELETED');
}
- $select_filter->add(rcube_label('withattachment'), $attachment);
$select_filter->add(rcube_label('priority').': '.rcube_label('highest'), 'HEADER X-PRIORITY 1');
$select_filter->add(rcube_label('priority').': '.rcube_label('high'), 'HEADER X-PRIORITY 2');
$select_filter->add(rcube_label('priority').': '.rcube_label('normal'), 'NOT HEADER X-PRIORITY 1 NOT HEADER X-PRIORITY 2 NOT HEADER X-PRIORITY 4 NOT HEADER X-PRIORITY 5');
@@ -1954,36 +1945,35 @@ function rcmail_message_error($uid=null)
$RCMAIL->output->send('messageerror');
}
-function rcmail_message_import_form($attrib = array())
-{
- global $OUTPUT;
-
- // set defaults
- $attrib += array('id' => 'rcmImportform', 'buttons' => 'yes');
-
- // Get filesize, enable upload progress bar
- $max_filesize = rcube_upload_init();
-
- $button = new html_inputfield(array('type' => 'button'));
- $fileinput = new html_inputfield(array(
- 'type' => 'file',
- 'name' => '_file[]',
- 'multiple' => 'multiple',
- 'accept' => ".eml, .mbox, message/rfc822, text/*",
- ));
-
- $out = html::div($attrib,
- $OUTPUT->form_tag(array('id' => $attrib['id'].'Frm', 'method' => 'post', 'enctype' => 'multipart/form-data'),
- html::tag('input', array('type' => 'hidden', 'name' => '_unlock', 'value' => '')) .
- html::div(null, $fileinput->show()) .
- 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()")) . ' ' .
- $button->show(rcube_label('upload'), array('class' => 'button mainaction', 'onclick' => JS_OBJECT_NAME . ".command('import-messages', this.form)"))
- ) : '')
- )
- );
+// register UI objects
+$OUTPUT->add_handlers(array(
+ 'mailboxlist' => 'rcmail_mailbox_list',
+ 'messages' => 'rcmail_message_list',
+ 'messagecountdisplay' => 'rcmail_messagecount_display',
+ 'quotadisplay' => 'rcmail_quota_display',
+ 'mailboxname' => 'rcmail_mailbox_name_display',
+ 'messageheaders' => 'rcmail_message_headers',
+ 'messagefullheaders' => 'rcmail_message_full_headers',
+ 'messagebody' => 'rcmail_message_body',
+ 'messagecontentframe' => 'rcmail_messagecontent_frame',
+ 'messagepartframe' => 'rcmail_message_part_frame',
+ 'messagepartcontrols' => 'rcmail_message_part_controls',
+ 'searchfilter' => 'rcmail_search_filter',
+ 'searchform' => array($OUTPUT, 'search_form'),
+));
- $OUTPUT->add_gui_object('importform', $attrib['id'].'Frm');
- return $out;
-}
+// register action aliases
+$RCMAIL->register_action_map(array(
+ 'refresh' => 'check_recent.inc',
+ 'preview' => 'show.inc',
+ 'print' => 'show.inc',
+ 'moveto' => 'move_del.inc',
+ 'delete' => 'move_del.inc',
+ 'send' => 'sendmail.inc',
+ 'expunge' => 'folders.inc',
+ 'purge' => 'folders.inc',
+ 'remove-attachment' => 'attachments.inc',
+ 'display-attachment' => 'attachments.inc',
+ 'upload' => 'attachments.inc',
+ 'group-expand' => 'autocomplete.inc',
+));
diff --git a/program/steps/mail/get.inc b/program/steps/mail/get.inc
index ae48307e3..372757720 100644
--- a/program/steps/mail/get.inc
+++ b/program/steps/mail/get.inc
@@ -38,34 +38,19 @@ ob_end_clean();
// similar code as in program/steps/mail/show.inc
if (!empty($_GET['_uid'])) {
- $uid = get_input_value('_uid', RCUBE_INPUT_GET);
$RCMAIL->config->set('prefer_html', true);
- $MESSAGE = new rcube_message($uid);
+ $MESSAGE = new rcube_message(get_input_value('_uid', RCUBE_INPUT_GET));
}
// check connection status
check_storage_status();
-$part_id = get_input_value('_part', RCUBE_INPUT_GPC);
-
// show part page
if (!empty($_GET['_frame'])) {
- if ($part_id && ($part = $MESSAGE->mime_parts[$part_id])) {
- $filename = rcmail_attachment_name($part);
- $OUTPUT->set_pagetitle($filename);
+ if (($part_id = get_input_value('_part', RCUBE_INPUT_GPC)) && ($part = $MESSAGE->mime_parts[$part_id])) {
+ $OUTPUT->set_pagetitle(rcmail_attachment_name($part));
}
- // register UI objects
- $OUTPUT->add_handlers(array(
- 'messagepartframe' => 'rcmail_message_part_frame',
- 'messagepartcontrols' => 'rcmail_message_part_controls',
- ));
-
- $OUTPUT->set_env('mailbox', $RCMAIL->storage->get_folder());
- $OUTPUT->set_env('uid', $uid);
- $OUTPUT->set_env('part', $part_id);
- $OUTPUT->set_env('filename', $filename);
-
$OUTPUT->send('messagepart');
exit;
}
@@ -84,18 +69,17 @@ else if ($_GET['_thumb']) {
// render thumbnail image if not done yet
if (!is_file($cache_file)) {
- if ($fp = fopen(($orig_name = $cache_basename . '.orig.' . $ext), 'w')) {
- $MESSAGE->get_part_content($part->mime_id, $fp);
- fclose($fp);
-
- $image = new rcube_image($orig_name);
- if ($imgtype = $image->resize($thumbnail_size, $cache_file, true)) {
- $mimetype = 'image/' . $imgtype;
- unlink($orig_name);
- }
- else {
- rename($orig_name, $cache_file);
- }
+ $fp = fopen(($orig_name = $cache_basename . '.orig.' . $ext), 'w');
+ $MESSAGE->get_part_content($part->mime_id, $fp);
+ fclose($fp);
+
+ $image = new rcube_image($orig_name);
+ if ($imgtype = $image->resize($thumbnail_size, $cache_file, true)) {
+ $mimetype = 'image/' . $imgtype;
+ unlink($orig_name);
+ }
+ else {
+ rename($orig_name, $cache_file);
}
}
@@ -108,8 +92,9 @@ else if ($_GET['_thumb']) {
exit;
}
-else if (strlen($part_id)) {
- if ($part = $MESSAGE->mime_parts[$part_id]) {
+else if (strlen($pid = get_input_value('_part', RCUBE_INPUT_GET))) {
+
+ if ($part = $MESSAGE->mime_parts[$pid]) {
$mimetype = rcmail_fix_mimetype($part->mimetype);
// allow post-processing of the message body
@@ -135,7 +120,7 @@ else if (strlen($part_id)) {
$valid = $file_extension && in_array($file_extension, (array)$extensions) || !empty($_REQUEST['_mimeclass']);
// 2. detect the real mimetype of the attachment part and compare it with the stated mimetype and filename extension
- if ($valid || !$file_extension || $mimetype == 'application/octet-stream' || stripos($mimetype, 'text/') === 0) {
+ if ($valid || !$file_extension || $mimetype == 'application/octet-stream' || $mimetype == 'text/plain') {
if ($part->body) // part body is already loaded
$body = $part->body;
else if ($part->size && $part->size < 1024*1024) // load the entire part if it's small enough
@@ -190,8 +175,8 @@ else if (strlen($part_id)) {
rcube_label(array(
'name' => 'attachmentvalidationerror',
'vars' => array(
- 'expected' => $mimetype . ($file_extension ? " (.$file_extension)" : ''),
- 'detected' => $real_mimetype . ($extensions[0] ? " (.$extensions[0])" : ''),
+ 'expected' => $mimetype . ($file_extension ? "(.$file_extension)" : ''),
+ 'detected' => $real_mimetype . ($extensions[0] ? "(.$extensions[0])" : ''),
)
)) .
html::p(array('class' => 'rcmail-inline-buttons'),
@@ -234,6 +219,7 @@ else if (strlen($part_id)) {
header("Content-Transfer-Encoding: binary");
}
+
// deliver part content
if ($ctype_primary == 'text' && $ctype_secondary == 'html' && empty($plugin['download'])) {
// Check if we have enough memory to handle the message in it
@@ -358,8 +344,7 @@ else if (strlen($part_id)) {
header("Content-Length: $size");
}
- // 8th argument disables re-formatting of text/* parts (#1489267)
- $sent = $RCMAIL->storage->get_message_part($MESSAGE->uid, $part->mime_id, $part, true, null, false, 0, false);
+ $sent = $RCMAIL->storage->get_message_part($MESSAGE->uid, $part->mime_id, $part, true);
}
}
@@ -393,9 +378,7 @@ else {
header('HTTP/1.1 404 Not Found');
exit;
-/**
- * Handles nicely storage connection errors
- */
+
function check_storage_status()
{
$error = rcmail::get_instance()->storage->get_error_code();
@@ -427,49 +410,3 @@ function check_storage_status()
exit;
}
}
-
-/**
- * Attachment properties table
- */
-function rcmail_message_part_controls($attrib)
-{
- global $MESSAGE, $RCMAIL;
-
- $part = asciiwords(get_input_value('_part', RCUBE_INPUT_GPC));
- if (!is_object($MESSAGE) || !is_array($MESSAGE->parts)
- || !($_GET['_uid'] && $_GET['_part']) || !$MESSAGE->mime_parts[$part]
- ) {
- return '';
- }
-
- $part = $MESSAGE->mime_parts[$part];
- $table = new html_table(array('cols' => 2));
-
- $table->add('title', Q(rcube_label('namex')).':');
- $table->add('header', Q(rcmail_attachment_name($part)));
-
- $table->add('title', Q(rcube_label('type')).':');
- $table->add('header', Q($part->mimetype));
-
- $table->add('title', Q(rcube_label('size')).':');
- $table->add('header', Q($RCMAIL->message_part_size($part)));
-
- return $table->show($attrib);
-}
-
-/**
- * Attachment preview frame
- */
-function rcmail_message_part_frame($attrib)
-{
- global $MESSAGE, $RCMAIL;
-
- $part = $MESSAGE->mime_parts[asciiwords(get_input_value('_part', RCUBE_INPUT_GPC))];
- $ctype_primary = strtolower($part->ctype_primary);
-
- $attrib['src'] = './?' . str_replace('_frame=', ($ctype_primary=='text' ? '_embed=' : '_preload='), $_SERVER['QUERY_STRING']);
-
- $RCMAIL->output->add_gui_object('messagepartframe', $attrib['id']);
-
- return html::iframe($attrib);
-}
diff --git a/program/steps/mail/list.inc b/program/steps/mail/list.inc
index a2380131a..b8c3ee021 100644
--- a/program/steps/mail/list.inc
+++ b/program/steps/mail/list.inc
@@ -97,6 +97,7 @@ $OUTPUT->set_env('threading', $threading);
$OUTPUT->set_env('current_page', $count ? $RCMAIL->storage->get_page() : 1);
$OUTPUT->set_env('exists', $RCMAIL->storage->count($mbox_name, 'EXISTS'));
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count), $mbox_name);
+$OUTPUT->command('set_mailboxname', rcmail_get_mailbox_name_text());
// add message rows
rcmail_js_message_list($a_headers, FALSE, $cols);
diff --git a/program/steps/mail/list_contacts.inc b/program/steps/mail/list_contacts.inc
index dab146431..479c21422 100644
--- a/program/steps/mail/list_contacts.inc
+++ b/program/steps/mail/list_contacts.inc
@@ -73,11 +73,8 @@ else {
$CONTACTS->set_pagesize($page_size);
$CONTACTS->set_page($list_page);
- if ($group_id = get_input_value('_gid', RCUBE_INPUT_GPC)) {
- $CONTACTS->set_group($group_id);
- }
// list groups of this source (on page one)
- else if ($CONTACTS->groups && $CONTACTS->list_page == 1) {
+ if ($CONTACTS->groups && $CONTACTS->list_page == 1) {
foreach ($CONTACTS->list_groups() as $group) {
$CONTACTS->reset();
$CONTACTS->set_group($group['ID']);
@@ -92,19 +89,6 @@ else {
'contactgroup' => html::span(array('title' => $email), Q($group['name']))), 'group');
}
}
- // make virtual groups clickable to list their members
- else if ($group_prop['virtual']) {
- $row_id = 'G'.$group['ID'];
- $OUTPUT->command('add_contact_row', $row_id, array(
- 'contactgroup' => html::a(array(
- 'href' => '#list',
- 'rel' => $row['ID'],
- 'title' => rcube_label('listgroup'),
- 'onclick' => sprintf("return %s.command('pushgroup',{'source':'%s','id':'%s'},this,event)", JS_OBJECT_NAME, $source, $group['ID']),
- ), Q($group['name']) . '&nbsp;' . html::span('action', '&raquo;'))),
- 'group',
- array('ID' => $group['ID'], 'name' => $group['name'], 'virtual' => true));
- }
// show group with count
else if (($result = $CONTACTS->count()) && $result->count) {
$row_id = 'E'.$group['ID'];
@@ -113,12 +97,10 @@ else {
'contactgroup' => Q($group['name'] . ' (' . intval($result->count) . ')')), 'group');
}
}
-
- $CONTACTS->reset();
- $CONTACTS->set_group(0);
}
// get contacts for this user
+ $CONTACTS->set_group(0);
$result = $CONTACTS->list_records($afields);
}
}
@@ -136,13 +118,10 @@ else if (!empty($result) && $result->count > 0) {
foreach ($emails as $i => $email) {
$row_id = $row['ID'].$i;
$jsresult[$row_id] = format_email_recipient($email, $name);
- $classname = $row['_type'] == 'group' ? 'group' : 'person';
- $keyname = $row['_type'] == 'group' ? 'contactgroup' : 'contact';
-
$OUTPUT->command('add_contact_row', $row_id, array(
- $keyname => html::span(array('title' => $email), Q($name ? $name : $email) .
+ 'contact' => html::span(array('title' => $email), Q($name ? $name : $email) .
($name && count($emails) > 1 ? '&nbsp;' . html::span('email', Q($email)) : '')
- )), $classname);
+ )), 'person');
}
}
}
diff --git a/program/steps/mail/move_del.inc b/program/steps/mail/move_del.inc
index f15cd2460..37157b71f 100644
--- a/program/steps/mail/move_del.inc
+++ b/program/steps/mail/move_del.inc
@@ -29,11 +29,10 @@ $old_count = $RCMAIL->storage->count(NULL, $threading ? 'THREADS' : 'ALL');
$old_pages = ceil($old_count / $RCMAIL->storage->get_pagesize());
// move messages
-if ($RCMAIL->action == 'move' && !empty($_POST['_uid']) && strlen($_POST['_target_mbox'])) {
- $count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST))));
+if ($RCMAIL->action=='moveto' && !empty($_POST['_uid']) && strlen($_POST['_target_mbox'])) {
+ $count = sizeof(explode(',', ($uids = get_input_value('_uid', RCUBE_INPUT_POST))));
$target = get_input_value('_target_mbox', RCUBE_INPUT_POST, true);
- $mbox = get_input_value('_mbox', RCUBE_INPUT_POST, true);
- $trash = $RCMAIL->config->get('trash_mbox');
+ $mbox = get_input_value('_mbox', RCUBE_INPUT_POST, true);
$moved = $RCMAIL->storage->move_message($uids, $target, $mbox);
@@ -41,7 +40,7 @@ if ($RCMAIL->action == 'move' && !empty($_POST['_uid']) && strlen($_POST['_targe
// send error message
if ($_POST['_from'] != 'show')
$OUTPUT->command('list_mailbox');
- rcmail_display_server_error('errormoving', null, $target == $trash ? 'delete' : '');
+ rcmail_display_server_error('errormoving');
$OUTPUT->send();
exit;
}
@@ -126,7 +125,7 @@ else
rcmail_set_unseen_count($mbox, $unseen_count);
}
- if ($RCMAIL->action == 'move' && strlen($target)) {
+ if ($RCMAIL->action == 'moveto' && strlen($target)) {
rcmail_send_unread_count($target, true);
}
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 52b02ecff..c1c257127 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -123,7 +123,7 @@ function rcmail_fix_emoticon_paths($mime_message)
// sanitize image name so resulting attachment doesn't leave images dir
$image_name = preg_replace('/[^a-zA-Z0-9_\.\-]/i', '', $image_name);
- $img_file = INSTALL_PATH . '/' . $searchstr . $image_name;
+ $img_file = '/usr/share/tinymce/www/plugins/emotions/img/' . $image_name;
if (! in_array($image_name, $included_images)) {
// add the image to the MIME message
@@ -391,6 +391,10 @@ if (!empty($mailcc)) {
if (!empty($mailbcc)) {
$headers['Bcc'] = $mailbcc;
}
+if (!empty($identity_arr['bcc']) && stripos($headers['Bcc'], $identity_arr['bcc']) === false) {
+ $headers['Bcc'] = ($headers['Bcc'] ? $headers['Bcc'].', ' : '') . $identity_arr['bcc'];
+ $RECIPIENT_COUNT ++;
+}
if (($max_recipients = (int) $RCMAIL->config->get('max_recipients')) > 0) {
if ($RECIPIENT_COUNT > $max_recipients) {
@@ -408,12 +412,18 @@ if (!empty($identity_arr['organization'])) {
if (!empty($_POST['_replyto'])) {
$headers['Reply-To'] = rcmail_email_input_format(get_input_value('_replyto', RCUBE_INPUT_POST, TRUE, $message_charset));
}
+else if (!empty($identity_arr['reply-to'])) {
+ $headers['Reply-To'] = rcmail_email_input_format($identity_arr['reply-to'], false, true);
+}
if (!empty($headers['Reply-To'])) {
$headers['Mail-Reply-To'] = $headers['Reply-To'];
}
if (!empty($_POST['_followupto'])) {
$headers['Mail-Followup-To'] = rcmail_email_input_format(get_input_value('_followupto', RCUBE_INPUT_POST, TRUE, $message_charset));
}
+if (!empty($COMPOSE['reply_msgid'])) {
+ $headers['In-Reply-To'] = $COMPOSE['reply_msgid'];
+}
// remember reply/forward UIDs in special headers
if (!empty($COMPOSE['reply_uid']) && $savedraft) {
@@ -423,9 +433,6 @@ else if (!empty($COMPOSE['forward_uid']) && $savedraft) {
$headers['X-Draft-Info'] = array('type' => 'forward', 'uid' => $COMPOSE['forward_uid']);
}
-if (!empty($COMPOSE['reply_msgid'])) {
- $headers['In-Reply-To'] = $COMPOSE['reply_msgid'];
-}
if (!empty($COMPOSE['references'])) {
$headers['References'] = $COMPOSE['references'];
}
@@ -473,19 +480,12 @@ $isHtml = (bool) get_input_value('_is_html', RCUBE_INPUT_POST);
$message_body = get_input_value('_message', RCUBE_INPUT_POST, TRUE, $message_charset);
if ($isHtml) {
- $bstyle = array();
-
- if ($font_size = $RCMAIL->config->get('default_font_size')) {
- $bstyle[] = 'font-size: ' . $font_size;
- }
- if ($font_family = $RCMAIL->config->get('default_font')) {
- $bstyle[] = 'font-family: ' . rcmail::font_defs($font_family);
- }
+ $font = rcube_fontdefs($RCMAIL->config->get('default_font'));
+ $bstyle = $font && is_string($font) ? " style='font-family: $font'" : '';
// append doctype and html/body wrappers
- $message_body = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">'
- . "\r\n<html><body" . (!empty($bstyle) ? " style='" . implode($bstyle, '; ') . "'" : '') . ">\r\n"
- . $message_body;
+ $message_body = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">' .
+ "\r\n<html><body$bstyle>\r\n" . $message_body;
}
if (!$savedraft) {
@@ -615,39 +615,22 @@ else {
}
// add stored attachments, if any
-if (is_array($COMPOSE['attachments'])) {
+if (is_array($COMPOSE['attachments']))
+{
foreach ($COMPOSE['attachments'] as $id => $attachment) {
// This hook retrieves the attachment contents from the file storage backend
$attachment = $RCMAIL->plugins->exec_hook('attachment_get', $attachment);
- if ($isHtml) {
- $dispurl = '/\ssrc\s*=\s*[\'"]*\S+display-attachment\S+file=rcmfile' . preg_quote($attachment['id']) . '[\s\'"]*/';
- $message_body = $MAIL_MIME->getHTMLBody();
- $is_inline = preg_match($dispurl, $message_body);
- }
- else {
- $is_inline = false;
- }
-
- // inline image
- if ($is_inline) {
- // Mail_Mime does not support many inline attachments with the same name (#1489406)
- // we'll generate cid: urls here to workaround this
- $cid = preg_replace('/[^0-9a-zA-Z]/', '', uniqid(time(), true));
- if (preg_match('#(@[0-9a-zA-Z\-\.]+)#', $from, $matches)) {
- $cid .= $matches[1];
- } else {
- $cid .= '@localhost';
- }
-
- $message_body = preg_replace($dispurl, ' src="cid:' . $cid . '" ', $message_body);
-
+ $dispurl = '/\ssrc\s*=\s*[\'"]*\S+display-attachment\S+file=rcmfile' . preg_quote($attachment['id']) . '[\s\'"]*/';
+ $message_body = $MAIL_MIME->getHTMLBody();
+ if ($isHtml && (preg_match($dispurl, $message_body) > 0)) {
+ $message_body = preg_replace($dispurl, ' src="'.$attachment['name'].'" ', $message_body);
$MAIL_MIME->setHTMLBody($message_body);
if ($attachment['data'])
- $MAIL_MIME->addHTMLImage($attachment['data'], $attachment['mimetype'], $attachment['name'], false, $cid);
+ $MAIL_MIME->addHTMLImage($attachment['data'], $attachment['mimetype'], $attachment['name'], false);
else
- $MAIL_MIME->addHTMLImage($attachment['path'], $attachment['mimetype'], $attachment['name'], true, $cid);
+ $MAIL_MIME->addHTMLImage($attachment['path'], $attachment['mimetype'], $attachment['name'], true);
}
else {
$ctype = str_replace('image/pjpeg', 'image/jpeg', $attachment['mimetype']); // #1484914
@@ -776,7 +759,7 @@ if ($store_target) {
if (PEAR::isError($msg))
raise_error(array('code' => 650, 'type' => 'php',
- 'file' => __FILE__, 'line' => __LINE__,
+ 'file' => __FILE__, 'line' => __LINE__,
'message' => "Could not create message: ".$msg->getMessage()),
TRUE, FALSE);
else {
@@ -847,24 +830,15 @@ if ($savedraft) {
// start the auto-save timer again
$OUTPUT->command('auto_save_start');
+
+ $OUTPUT->send('iframe');
}
else {
- $folders = array();
-
- if ($COMPOSE['mode'] == 'reply' || $COMPOSE['mode'] == 'forward')
- $folders[] = $COMPOSE['mailbox'];
-
rcmail_compose_cleanup($COMPOSE_ID);
if ($store_folder && !$saved)
- $OUTPUT->command('sent_successfully', 'error', rcube_label('errorsavingsent'), $folders);
- else {
- if ($store_folder) {
- $folders[] = $store_target;
- }
-
- $OUTPUT->command('sent_successfully', 'confirmation', rcube_label('messagesent'), $folders);
- }
+ $OUTPUT->command('sent_successfully', 'error', rcube_label('errorsavingsent'));
+ else
+ $OUTPUT->command('sent_successfully', 'confirmation', rcube_label('messagesent'), $store_target);
+ $OUTPUT->send('iframe');
}
-
-$OUTPUT->send('iframe');
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index 9d85f9c8f..c1726bbdf 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -19,7 +19,7 @@
+-----------------------------------------------------------------------+
*/
-$PRINT_MODE = $RCMAIL->action == 'print' ? TRUE : FALSE;
+$PRINT_MODE = $RCMAIL->action=='print' ? TRUE : FALSE;
// Read browser capabilities and store them in session
if ($caps = get_input_value('_caps', RCUBE_INPUT_GET)) {
@@ -31,21 +31,8 @@ if ($caps = get_input_value('_caps', RCUBE_INPUT_GET)) {
$_SESSION['browser_caps'] = $browser_caps;
}
-$uid = get_input_value('_uid', RCUBE_INPUT_GET);
-$mbox_name = $RCMAIL->storage->get_folder();
-
// similar code as in program/steps/mail/get.inc
-if ($uid) {
- // set message format (need to be done before rcube_message construction)
- if (!empty($_GET['_format'])) {
- $prefer_html = $_GET['_format'] == 'html';
- $RCMAIL->config->set('prefer_html', $prefer_html);
- $_SESSION['msg_formats'][$mbox_name.':'.$uid] = $prefer_html;
- }
- else if (isset($_SESSION['msg_formats'][$mbox_name.':'.$uid])) {
- $RCMAIL->config->set('prefer_html', $_SESSION['msg_formats'][$mbox_name.':'.$uid]);
- }
-
+if ($uid = get_input_value('_uid', RCUBE_INPUT_GET)) {
$MESSAGE = new rcube_message($uid);
// if message not found (wrong UID)...
@@ -53,6 +40,7 @@ if ($uid) {
rcmail_message_error($uid);
}
+ $mbox_name = $RCMAIL->storage->get_folder();
// show images?
rcmail_check_safe($MESSAGE);
@@ -116,12 +104,7 @@ if ($uid) {
if (!$OUTPUT->ajax_call)
$OUTPUT->add_label('checkingmail', 'deletemessage', 'movemessagetotrash',
- 'movingmessage', 'deletingmessage', 'markingmessage', 'replyall', 'replylist');
-
- $prefer_html = $RCMAIL->config->get('prefer_html');
- if ($MESSAGE->has_html_part()) {
- $OUTPUT->set_env('optional_format', $prefer_html ? 'text' : 'html');
- }
+ 'movingmessage', 'deletingmessage', 'markingmessage');
// check for unset disposition notification
if ($MESSAGE->headers->mdn_to
@@ -164,7 +147,6 @@ function rcmail_message_attachments($attrib)
global $PRINT_MODE, $MESSAGE, $RCMAIL;
$out = $ol = '';
- $attachments = array();
if (sizeof($MESSAGE->attachments)) {
foreach ($MESSAGE->attachments as $attach_prop) {
@@ -183,24 +165,22 @@ function rcmail_message_attachments($attrib)
$title = '';
}
- $mimetype = rcmail_fix_mimetype($attach_prop->mimetype);
- $class = rcmail_filetype2classname($mimetype, $filename);
- $id = 'attach' . $attach_prop->mime_id;
- $link = html::a(array(
+ $ol .= html::tag('li', rcmail_filetype2classname($attach_prop->mimetype, $filename),
+ html::a(array(
'href' => $MESSAGE->get_part_url($attach_prop->mime_id, false),
- 'onclick' => sprintf('return %s.command(\'load-attachment\',\'%s\',this)',
- JS_OBJECT_NAME, $attach_prop->mime_id),
- 'onmouseover' => $title ? '' : 'rcube_webmail.long_subject_title_ex(this, 0)',
- 'title' => Q($title),
- ), Q($filename));
- $ol .= html::tag('li', array('class' => $class, 'id' => $id), $link);
-
- $attachments[$attach_prop->mime_id] = $mimetype;
+ 'onclick' => sprintf(
+ 'return %s.command(\'load-attachment\',{part:\'%s\', mimetype:\'%s\'},this)',
+ JS_OBJECT_NAME,
+ $attach_prop->mime_id,
+ rcmail_fix_mimetype($attach_prop->mimetype)),
+ 'onmouseover' => $title ? '' : 'rcube_webmail.long_subject_title_ex(this, 0)',
+ 'title' => Q($title),
+ ),
+ Q($filename)));
}
}
$out = html::tag('ul', $attrib, $ol, html::$common_attrib);
- $RCMAIL->output->set_env('attachments', $attachments);
}
return $out;
@@ -229,11 +209,11 @@ function rcmail_remote_objects_msg()
function rcmail_message_buttons()
{
- global $RCMAIL;
+ global $MESSAGE, $RCMAIL, $CONFIG;
$mbox = $RCMAIL->storage->get_folder();
$delim = $RCMAIL->storage->get_hierarchy_delimiter();
- $dbox = $RCMAIL->config->get('drafts_mbox');
+ $dbox = $CONFIG['drafts_mbox'];
// the message is not a draft
if ($mbox != $dbox && strpos($mbox, $dbox.$delim) !== 0) {
@@ -310,9 +290,9 @@ $OUTPUT->add_handlers(array(
));
-if ($RCMAIL->action == 'print' && $OUTPUT->template_exists('messageprint'))
+if ($RCMAIL->action=='print' && $OUTPUT->template_exists('messageprint'))
$OUTPUT->send('messageprint', false);
-else if ($RCMAIL->action == 'preview' && $OUTPUT->template_exists('messagepreview'))
+else if ($RCMAIL->action=='preview' && $OUTPUT->template_exists('messagepreview'))
$OUTPUT->send('messagepreview', false);
else
$OUTPUT->send('message', false);