diff options
Diffstat (limited to 'program/steps/mail')
-rw-r--r-- | program/steps/mail/autocomplete.inc | 54 | ||||
-rw-r--r-- | program/steps/mail/compose.inc | 22 | ||||
-rw-r--r-- | program/steps/mail/func.inc | 26 | ||||
-rw-r--r-- | program/steps/mail/get.inc | 6 | ||||
-rw-r--r-- | program/steps/mail/list.inc | 14 | ||||
-rw-r--r-- | program/steps/mail/search.inc | 6 | ||||
-rw-r--r-- | program/steps/mail/sendmail.inc | 75 | ||||
-rw-r--r-- | program/steps/mail/show.inc | 6 |
8 files changed, 112 insertions, 97 deletions
diff --git a/program/steps/mail/autocomplete.inc b/program/steps/mail/autocomplete.inc index 30b8f2299..38501eb9d 100644 --- a/program/steps/mail/autocomplete.inc +++ b/program/steps/mail/autocomplete.inc @@ -88,16 +88,18 @@ if (!empty($book_types) && strlen($search)) { continue; } + $index = $contact; + // skip duplicates - if (!in_array($contact, $contacts)) { + if (empty($contacts[$index])) { $contact = array('name' => $contact, 'type' => $sql_arr['_type']); if (($display = rcube_addressbook::compose_search_name($sql_arr, $email, $name)) && $display != $contact['name']) { $contact['display'] = $display; } - $contacts[] = $contact; - $sort_keys[] = sprintf('%s %03d', $contact['display'] ?: $name, $idx++); + $contacts[$index] = $contact; + $sort_keys[$index] = sprintf('%s %03d', $contact['display'] ?: $name, $idx++); if (count($contacts) >= $MAXNUM) { break 2; @@ -124,34 +126,40 @@ if (!empty($book_types) && strlen($search)) { if ($group_prop['email']) { $idx = 0; foreach ((array)$group_prop['email'] as $email) { - $contacts[] = array( - 'name' => format_email_recipient($email, $group['name']), - 'email' => $email, + $index = format_email_recipient($email, $group['name']); + + if (empty($contacts[$index])) { + $sort_keys[$index] = sprintf('%s %03d', $group['name'] , $idx++); + $contacts[$index] = array( + 'name' => $index, + 'email' => $email, + 'type' => 'group', + 'id' => $group['ID'], + 'source' => $id, + ); + + if (count($contacts) >= $MAXNUM) { + break 2; + } + } + } + } + // show group with count + else if (($result = $abook->count()) && $result->count) { + if (empty($contacts[$group['name']])) { + $sort_keys[$group['name']] = $group['name']; + $contacts[$group['name']] = array( + 'name' => $group['name'] . ' (' . intval($result->count) . ')', 'type' => 'group', 'id' => $group['ID'], - 'source' => $id, + 'source' => $id ); - $sort_keys[] = sprintf('%s %03d', $group['name'] , $idx++); if (count($contacts) >= $MAXNUM) { - break 2; + break; } } } - // show group with count - else if (($result = $abook->count()) && $result->count) { - $sort_keys[] = $group['name']; - $contacts[] = array( - 'name' => $group['name'] . ' (' . intval($result->count) . ')', - 'type' => 'group', - 'id' => $group['ID'], - 'source' => $id - ); - - if (count($contacts) >= $MAXNUM) { - break; - } - } } } } diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index db4efc7ce..5009c525a 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -83,7 +83,7 @@ $OUTPUT->add_label('nosubject', 'nosenderwarning', 'norecipientwarning', 'nosubj 'messagesaved', 'converting', 'editorwarning', 'searching', 'uploading', 'uploadingmany', 'fileuploaderror', 'sendmessage', 'newresponse', 'responsename', 'responsetext', 'save', 'savingresponse', 'restoresavedcomposedata', 'restoremessage', 'delete', 'restore', 'ignore', - 'selectimportfile'); + 'selectimportfile', 'messageissent'); $OUTPUT->set_pagetitle($RCMAIL->gettext('compose')); @@ -91,8 +91,10 @@ $OUTPUT->set_env('compose_id', $COMPOSE['id']); $OUTPUT->set_env('session_id', session_id()); $OUTPUT->set_env('mailbox', $RCMAIL->storage->get_folder()); $OUTPUT->set_env('top_posting', intval($RCMAIL->config->get('reply_mode')) > 0); +$OUTPUT->set_env('sig_below', $RCMAIL->config->get('sig_below')); $OUTPUT->set_env('recipients_separator', trim($RCMAIL->config->get('recipients_separator', ','))); $OUTPUT->set_env('save_localstorage', (bool)$RCMAIL->config->get('compose_save_localstorage')); +$OUTPUT->set_env('is_sent', false); $drafts_mbox = $RCMAIL->config->get('drafts_mbox'); $config_show_sig = $RCMAIL->config->get('show_sig', 1); @@ -447,6 +449,8 @@ function rcmail_process_compose_params(&$COMPOSE) // #1486037: remove "mailto:" prefix $COMPOSE['param']['to'] = preg_replace('/^mailto:/i', '', $mailto[0]); + // #1490346: decode the recipient address + $COMPOSE['param']['to'] = urldecode($COMPOSE['param']['to']); // Supported case-insensitive tokens in mailto URL $url_tokens = array('to', 'cc', 'bcc', 'reply-to', 'in-reply-to', 'references', 'subject', 'body'); @@ -609,8 +613,10 @@ 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) ? '---' : '-- '; + $top_posting = intval($RCMAIL->config->get('reply_mode')) > 0 + && !$RCMAIL->config->get('sig_below') + && ($compose_mode == RCUBE_COMPOSE_REPLY || $compose_mode == RCUBE_COMPOSE_FORWARD); + $separator = $top_posting ? '---' : '-- '; $field_attrib['onchange'] = rcmail_output::JS_OBJECT_NAME.".change_identity(this)"; $select_from = new html_select($field_attrib); @@ -625,11 +631,12 @@ function rcmail_compose_header_from($attrib) $text = $html = $sql_arr['signature']; if ($sql_arr['html_signature']) { - $h2t = new rcube_html2text($sql_arr['signature'], false, true); + $h2t = new rcube_html2text($html, false, true); $text = trim($h2t->get_text()); } else { - $html = htmlentities($html, ENT_NOQUOTES, RCUBE_CHARSET); + $t2h = new rcube_text2html($text, false); + $html = $t2h->get_html(); } if (!preg_match('/^--[ -]\r?\n/m', $text)) { @@ -637,11 +644,6 @@ function rcmail_compose_header_from($attrib) $html = $separator . "<br>" . $html; } - if (!$sql_arr['html_signature']) { - $t2h = new rcube_text2html($sql_arr['signature'], false); - $html = $t2h->get_html(); - } - $a_signatures[$identity_id]['text'] = $text; $a_signatures[$identity_id]['html'] = $html; } diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index c45fd2f97..684cdf933 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -64,17 +64,6 @@ if (empty($RCMAIL->action) || $RCMAIL->action == 'list') { $mbox_name = $RCMAIL->storage->get_folder(); if (empty($RCMAIL->action)) { - // initialize searching result if search_filter is used - if ($_SESSION['search_filter'] && $_SESSION['search_filter'] != 'ALL') { - $RCMAIL->storage->search($mbox_name, $_SESSION['search_filter'], RCUBE_CHARSET, rcmail_sort_column()); - - $search_request = md5($mbox_name.$_SESSION['search_filter']); - $_SESSION['search'] = $RCMAIL->storage->get_search_set(); - $_SESSION['search_request'] = $search_request; - - $OUTPUT->set_env('search_request', $search_request); - } - $OUTPUT->set_env('search_mods', rcmail_search_mods()); if (!empty($_SESSION['search_scope'])) @@ -399,6 +388,7 @@ function rcmail_js_message_list($a_headers, $insert_top=false, $a_show_cols=null $head_replace = true; } + $delimiter = $RCMAIL->storage->get_hierarchy_delimiter(); $search_set = $RCMAIL->storage->get_search_set(); $multifolder = $search_set && $search_set[1]->multi; @@ -489,8 +479,16 @@ function rcmail_js_message_list($a_headers, $insert_top=false, $a_show_cols=null $cont = show_bytes($header->$col); else if ($col == 'date') $cont = $RCMAIL->format_date($header->date); - else if ($col == 'folder') - $cont = rcube::Q(rcube_charset::convert($header->folder, 'UTF7-IMAP')); + else if ($col == 'folder') { + if ($last_folder !== $header->folder) { + $last_folder = $header->folder; + $last_folder_name = rcube_charset::convert($last_folder, 'UTF7-IMAP'); + $last_folder_name = $RCMAIL->localize_foldername($last_folder_name, true); + $last_folder_name = str_replace($delimiter, " \xC2\xBB ", $last_folder_name); + } + + $cont = rcube::Q($last_folder_name); + } else $cont = rcube::Q($header->$col); @@ -2047,7 +2045,7 @@ function rcmail_search_filter($attrib) $select_filter->add($RCMAIL->gettext('priority').': '.$RCMAIL->gettext('low'), 'HEADER X-PRIORITY 4'); $select_filter->add($RCMAIL->gettext('priority').': '.$RCMAIL->gettext('lowest'), 'HEADER X-PRIORITY 5'); - $out = $select_filter->show($_SESSION['search_filter']); + $out = $select_filter->show($_REQUEST['_search'] ? $_SESSION['search_filter'] : 'ALL'); $RCMAIL->output->add_gui_object('search_filter', $attrib['id']); diff --git a/program/steps/mail/get.inc b/program/steps/mail/get.inc index 5803e0c5a..831026eb7 100644 --- a/program/steps/mail/get.inc +++ b/program/steps/mail/get.inc @@ -22,7 +22,9 @@ // show loading page if (!empty($_GET['_preload'])) { - $url = preg_replace('/([&?]+)_preload=/', '\\1_mimewarning=1&_embed=', $_SERVER['REQUEST_URI']); + $_get = $_GET + array('_mimewarning' => 1, '_embed' => 1); + unset($_get['_preload']); + $url = $RCMAIL->url($_get); $message = $RCMAIL->gettext('loadingdata'); header('Content-Type: text/html; charset=' . RCUBE_CHARSET); @@ -85,7 +87,7 @@ 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); + $MESSAGE->get_part_body($part->mime_id, false, 0, $fp); fclose($fp); $image = new rcube_image($orig_name); diff --git a/program/steps/mail/list.inc b/program/steps/mail/list.inc index 32197bde3..4f2b73c53 100644 --- a/program/steps/mail/list.inc +++ b/program/steps/mail/list.inc @@ -58,20 +58,6 @@ $threading = (bool) $RCMAIL->storage->get_threading(); // Synchronize mailbox cache, handle flag changes $RCMAIL->storage->folder_sync($mbox_name); -// initialize searching result if search_filter is used -if ($_SESSION['search_filter'] && $_SESSION['search_filter'] != 'ALL') { - $search_request = md5($mbox_name.$_SESSION['search_scope'].$_SESSION['search_filter']); - $RCMAIL->storage->search($mbox_name, $_SESSION['search_filter'], RCUBE_CHARSET, rcmail_sort_column()); - - $_SESSION['search'] = $RCMAIL->storage->get_search_set(); - $_SESSION['search_request'] = $search_request; - - $OUTPUT->set_env('search_request', $search_request); - $OUTPUT->set_env('search_filter', $_SESSION['search_filter']); - - $multifolder = is_a($_SESSION['search'][1], 'rcube_result_multifolder'); -} - // fetch message headers if ($count = $RCMAIL->storage->count($mbox_name, $threading ? 'THREADS' : 'ALL', !empty($_REQUEST['_refresh']))) { $a_headers = $RCMAIL->storage->list_messages($mbox_name, NULL, rcmail_sort_column(), rcmail_sort_order()); diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc index d88e57568..02281e610 100644 --- a/program/steps/mail/search.inc +++ b/program/steps/mail/search.inc @@ -151,12 +151,14 @@ $_SESSION['search_scope'] = $scope; // Get the headers if (!$result->incomplete) { $result_h = $RCMAIL->storage->list_messages($mbox, 1, $sort_column, rcmail_sort_order()); - $count = $RCMAIL->storage->count($mbox, $RCMAIL->storage->get_threading() ? 'THREADS' : 'ALL'); } // Make sure we got the headers if (!empty($result_h)) { + $count = $RCMAIL->storage->count($mbox, $RCMAIL->storage->get_threading() ? 'THREADS' : 'ALL'); + rcmail_js_message_list($result_h, false); + if ($search_str) { $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $RCMAIL->storage->count(NULL, 'ALL'))); } @@ -172,6 +174,7 @@ if (!empty($result_h)) { } // handle IMAP errors (e.g. #1486905) else if ($err_code = $RCMAIL->storage->get_error_code()) { + $count = 0; $RCMAIL->display_server_error(); } // advice the client to re-send the (cross-folder) search request @@ -180,6 +183,7 @@ else if ($result->incomplete) { $OUTPUT->command('continue_search', $search_request); } else { + $count = 0; $OUTPUT->show_message('searchnomatch', 'notice'); $OUTPUT->set_env('multifolder_listing', (bool)$result->multi); if ($result->multi && $scope == 'all') { diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index 5843de43f..b3034f57d 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -24,7 +24,8 @@ $OUTPUT->reset(); $OUTPUT->framed = TRUE; -$savedraft = !empty($_POST['_draft']) ? true : false; +$saveonly = !empty($_GET['_saveonly']); +$savedraft = !empty($_POST['_draft']) && !$saveonly; $sendmail_delay = (int) $RCMAIL->config->get('sendmail_delay'); $drafts_mbox = $RCMAIL->config->get('drafts_mbox'); @@ -112,6 +113,12 @@ else if ($from_string = rcmail_email_input_format($from)) { $from = null; } +// check 'From' address (identity may be incomplete) +if (!$savedraft && !$saveonly && empty($from)) { + $OUTPUT->show_message('nofromaddress', 'error'); + $OUTPUT->send('iframe'); +} + if (!$from_string && $from) { $from_string = $from; } @@ -504,25 +511,15 @@ $MAIL_MIME->setParam('head_charset', $message_charset); $MAIL_MIME->setParam('html_charset', $message_charset); $MAIL_MIME->setParam('text_charset', $text_charset); -// encoding subject header with mb_encode provides better results with asian characters -if (function_exists('mb_encode_mimeheader')) { - mb_internal_encoding($message_charset); - $headers['Subject'] = mb_encode_mimeheader($headers['Subject'], - $message_charset, 'Q', "\r\n", 8); - mb_internal_encoding(RCUBE_CHARSET); -} - // pass headers to message object $MAIL_MIME->headers($headers); -// Begin SMTP Delivery Block -if (!$savedraft) { - // check 'From' address (identity may be incomplete) - if (empty($from)) { - $OUTPUT->show_message('nofromaddress', 'error'); - $OUTPUT->send('iframe'); - } +// This hook allows to modify the message before send or save action +$plugin = $RCMAIL->plugins->exec_hook('message_ready', array('message' => $MAIL_MIME)); +$MAIL_MIME = $plugin['message']; +// Begin SMTP Delivery Block +if (!$savedraft && !$saveonly) { // Handle Delivery Status Notification request $smtp_opts['dsn'] = $dsn_enabled; @@ -600,8 +597,9 @@ if ($store_target) { else { $temp_dir = $RCMAIL->config->get('temp_dir'); $mailbody_file = tempnam($temp_dir, 'rcmMsg'); + $msg = $MAIL_MIME->saveMessageBody($mailbody_file); - if (!PEAR::isError($msg = $MAIL_MIME->saveMessageBody($mailbody_file))) { + if (!is_a($msg, 'PEAR_Error')) { $msg = $mailbody_file; } } @@ -611,7 +609,7 @@ if ($store_target) { $headers = ''; } - if (PEAR::isError($msg)) { + if (is_a($msg, 'PEAR_Error')) { rcube::raise_error(array('code' => 650, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Could not create message: ".$msg->getMessage()), @@ -635,7 +633,8 @@ if ($store_target) { 'message' => "Could not save message in $store_target"), true, false); if ($savedraft) { - $OUTPUT->show_message('errorsaving', 'error'); + $RCMAIL->display_server_error('errorsaving'); + // start the auto-save timer again $OUTPUT->command('auto_save_start'); $OUTPUT->send('iframe'); @@ -688,24 +687,36 @@ else { // we'll refresh the list if currently opened folder is one of them (#1490238) $folders = array(); - if (in_array($COMPOSE['mode'], array('reply', 'forward', 'draft'))) { - $folders[] = $COMPOSE['mailbox']; - } - if (!empty($COMPOSE['param']['draft_uid']) && $drafts_mbox) { - $folders[] = $drafts_mbox; + if (!$saveonly) { + if (in_array($COMPOSE['mode'], array('reply', 'forward', 'draft'))) { + $folders[] = $COMPOSE['mailbox']; + } + if (!empty($COMPOSE['param']['draft_uid']) && $drafts_mbox) { + $folders[] = $drafts_mbox; + } } - rcmail_compose_cleanup($COMPOSE_ID); - $OUTPUT->command('remove_compose_data', $COMPOSE_ID); - if ($store_folder && !$saved) { - $OUTPUT->command('sent_successfully', 'error', $RCMAIL->gettext('errorsavingsent'), $folders); + $params = $saveonly ? null : array('prefix' => true); + $RCMAIL->display_server_error('errorsavingsent', null, null, $params); + if ($saveonly) { + $OUTPUT->send('iframe'); + } + + $save_error = true; } - else if ($store_folder) { - $folders[] = $store_target; + else { + rcmail_compose_cleanup($COMPOSE_ID); + $OUTPUT->command('remove_compose_data', $COMPOSE_ID); + + if ($store_folder) { + $folders[] = $store_target; + } } - $OUTPUT->command('sent_successfully', 'confirmation', $RCMAIL->gettext('messagesent'), $folders); + $msg = $RCMAIL->gettext($saveonly ? 'successfullysaved' : 'messagesent'); + + $OUTPUT->command('sent_successfully', 'confirmation', $msg, $folders, $save_error); } $OUTPUT->send('iframe'); @@ -786,7 +797,7 @@ function rcmail_fix_emoticon_paths($mime_message) if (!in_array($image_name, $included_images)) { // add the image to the MIME message $res = $mime_message->addHTMLImage($img_file, 'image/gif', '', true, $image_name); - if (PEAR::isError($res)) { + if (is_a($res, 'PEAR_Error')) { $RCMAIL->output->show_message("emoticonerror", 'error'); continue; } diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc index 747cbc2a0..a09a690f2 100644 --- a/program/steps/mail/show.inc +++ b/program/steps/mail/show.inc @@ -185,8 +185,12 @@ if (!empty($set_seen_flag)) { } } -exit; +// Save preview_pane preference, if not set yet (#1490362) +if ($RCMAIL->action == 'preview' && !$RCMAIL->config->get('preview_pane')) { + $RCMAIL->user->save_prefs(array('preview_pane' => true)); +} +exit; function rcmail_message_attachments($attrib) |