diff options
Diffstat (limited to 'program/steps')
-rw-r--r-- | program/steps/addressbook/save.inc | 4 | ||||
-rw-r--r-- | program/steps/mail/attachments.inc | 43 | ||||
-rw-r--r-- | program/steps/mail/check_recent.inc | 4 | ||||
-rw-r--r-- | program/steps/mail/compose.inc | 25 | ||||
-rw-r--r-- | program/steps/mail/func.inc | 182 | ||||
-rw-r--r-- | program/steps/mail/get.inc | 2 | ||||
-rw-r--r-- | program/steps/mail/list.inc | 97 | ||||
-rw-r--r-- | program/steps/mail/move_del.inc | 2 | ||||
-rw-r--r-- | program/steps/mail/search.inc | 10 | ||||
-rw-r--r-- | program/steps/mail/sendmail.inc | 54 | ||||
-rw-r--r-- | program/steps/mail/show.inc | 9 | ||||
-rw-r--r-- | program/steps/settings/edit_identity.inc | 2 | ||||
-rw-r--r-- | program/steps/settings/edit_prefs.inc | 4 | ||||
-rw-r--r-- | program/steps/settings/func.inc | 7 | ||||
-rw-r--r-- | program/steps/utils/html2text.inc | 7 | ||||
-rw-r--r-- | program/steps/utils/spell_html.inc | 36 | ||||
-rw-r--r-- | program/steps/utils/text2html.inc | 33 |
17 files changed, 295 insertions, 226 deletions
diff --git a/program/steps/addressbook/save.inc b/program/steps/addressbook/save.inc index 94556f96b..7451f433b 100644 --- a/program/steps/addressbook/save.inc +++ b/program/steps/addressbook/save.inc @@ -165,6 +165,10 @@ if (!empty($cid)) { $a_js_cols[] = rcube::Q((string)$record[$col]); } + // performance: unset some big data items we don't need here + $record = array_intersect_key($record, array('ID' => 1,'email' => 1,'name' => 1)); + $record['_type'] = 'person'; + // update the changed col in list $OUTPUT->command('parent.update_contact_row', $cid, $a_js_cols, $newcid, $source, $record); diff --git a/program/steps/mail/attachments.inc b/program/steps/mail/attachments.inc index 85bc36cac..c8b7f9517 100644 --- a/program/steps/mail/attachments.inc +++ b/program/steps/mail/attachments.inc @@ -60,7 +60,7 @@ if ($RCMAIL->action=='remove-attachment') { exit; } -if ($RCMAIL->action=='display-attachment') { +if ($RCMAIL->action == 'display-attachment') { $id = 'undefined'; if (preg_match('/^rcmfile(\w+)$/', $_GET['_file'], $regs)) { @@ -76,6 +76,47 @@ if ($RCMAIL->action=='display-attachment') { $attachment['size'] = $attachment['data'] ? strlen($attachment['data']) : @filesize($attachment['path']); } + // generate image thumbnail for file browser in HTML editor + if (!empty($_GET['_thumbnail'])) { + $temp_dir = $RCMAIL->config->get('temp_dir'); + $thumbnail_size = 80; + list(,$ext) = explode('/', $attachment['mimetype']); + $mimetype = $attachment['mimetype']; + $file_ident = $attachment['id'] . ':' . $attachment['mimetype'] . ':' . $attachment['size']; + $cache_basename = $temp_dir . '/' . md5($file_ident . ':' . $RCMAIL->user->ID . ':' . $thumbnail_size); + $cache_file = $cache_basename . '.' . $ext; + + // render thumbnail image if not done yet + if (!is_file($cache_file)) { + if (!$attachment['path']) { + $orig_name = $filename = $cache_basename . '.orig.' . $ext; + file_put_contents($orig_name, $attachment['data']); + } + else { + $filename = $attachment['path']; + } + + $image = new rcube_image($filename); + if ($imgtype = $image->resize($thumbnail_size, $cache_file, true)) { + $mimetype = 'image/' . $imgtype; + + if ($orig_name) { + unlink($orig_name); + } + } + } + + if (is_file($cache_file)) { + // cache for 1h + $RCMAIL->output->future_expire_header(3600); + header('Content-Type: ' . $mimetype); + header('Content-Length: ' . filesize($cache_file)); + + readfile($cache_file); + exit; + } + } + header('Content-Type: ' . $attachment['mimetype']); header('Content-Length: ' . $attachment['size']); diff --git a/program/steps/mail/check_recent.inc b/program/steps/mail/check_recent.inc index cfdcda605..70f4c03a6 100644 --- a/program/steps/mail/check_recent.inc +++ b/program/steps/mail/check_recent.inc @@ -85,7 +85,7 @@ foreach ($a_mailboxes as $mbox_name) { $OUTPUT->command('set_quota', $RCMAIL->quota_content()); } - $OUTPUT->set_env('exists', $RCMAIL->storage->count($mbox_name, 'EXISTS')); + $OUTPUT->set_env('exists', $RCMAIL->storage->count($mbox_name, 'EXISTS', true)); // "No-list" mode, don't get messages if (empty($_POST['_list'])) { @@ -146,7 +146,7 @@ foreach ($a_mailboxes as $mbox_name) { // set trash folder state if ($mbox_name === $trash) { - $OUTPUT->command('set_trash_count', $RCMAIL->storage->count($mbox_name, 'EXISTS')); + $OUTPUT->command('set_trash_count', $RCMAIL->storage->count($mbox_name, 'EXISTS', true)); } } diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index b56938596..0257f3187 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -611,7 +611,7 @@ function rcmail_compose_header_from($attrib) $text = $html = $sql_arr['signature']; if ($sql_arr['html_signature']) { - $h2t = new rcube_html2text($sql_arr['signature'], false, false); + $h2t = new rcube_html2text($sql_arr['signature'], false, true); $text = trim($h2t->get_text()); } else { @@ -624,7 +624,8 @@ function rcmail_compose_header_from($attrib) } if (!$sql_arr['html_signature']) { - $html = "<pre>" . $html . "</pre>"; + $t2h = new rcube_text2html($sql_arr['signature'], false); + $html = $t2h->get_html(); } $a_signatures[$identity_id]['text'] = $text; @@ -826,15 +827,8 @@ function rcmail_compose_part_body($part, $isHtml = false) } } - if ($part->ctype_parameters['format'] == 'flowed') { - $body = rcube_mime::unfold_flowed($body); - } - // add HTML formatting - $body = rcmail_plain_body($body); - if ($body) { - $body = '<pre>' . $body . '</pre>'; - } + $body = rcmail_plain_body($body, $part->ctype_parameters['format'] == 'flowed'); } } else { @@ -957,8 +951,7 @@ function rcmail_compose_body($attrib) "googie.setLanguages(%s);\n". "googie.setCurrentLanguage('%s');\n". "googie.setDecoration(false);\n". - "googie.decorateTextarea('%s');\n". - "%s.set_env('spellcheck', googie);", + "googie.decorateTextarea('%s');\n", $RCMAIL->output->get_skin_path(), $RCMAIL->url(array('_task' => 'utils', '_action' => 'spell', '_remote' => 1)), !empty($dictionary) ? 'true' : 'false', @@ -970,8 +963,7 @@ function rcmail_compose_body($attrib) rcube::JQ(rcube::Q($RCMAIL->gettext('addtodict'))), rcube_output::json_serialize($spellcheck_langs), $lang, - $attrib['id'], - rcmail_output::JS_OBJECT_NAME), 'foot'); + $attrib['id']), 'foot'); $OUTPUT->add_label('checking'); $OUTPUT->set_env('spellcheck_langs', join(',', $editor_lang_set)); @@ -1463,6 +1455,9 @@ function rcmail_compose_subject($attrib) $subject = $MESSAGE->subject; else $subject = 'Re: '.$MESSAGE->subject; + + // replace (was: ...) (#1489375) + $subject = preg_replace('/\s*\([wW]as:[^\)]+\)\s*$/', '', $subject); } // create a forward-subject else if ($compose_mode == RCUBE_COMPOSE_FORWARD) { @@ -1707,7 +1702,7 @@ function rcmail_editor_selector($attrib) if (empty($attrib['name'])) $attrib['name'] = 'editorSelect'; - $attrib['onchange'] = "return rcmail_toggle_editor(this, '".$attrib['editorid']."', '_is_html')"; + $attrib['onchange'] = "return rcmail.command('toggle-editor', {id: '".$attrib['editorid']."', html: this.value == 'html'}, '', event)"; $select = new html_select($attrib); diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index d8211f532..0dba3c125 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -23,39 +23,8 @@ // always instantiate storage object (but not connect to server yet) $RCMAIL->storage_init(); -// set imap properties and session vars -if (!strlen($mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC, true))) { - $mbox = strlen($_SESSION['mbox']) ? $_SESSION['mbox'] : 'INBOX'; -} -if (!($page = intval($_GET['_page']))) { - $page = $_SESSION['page'] ? $_SESSION['page'] : 1; -} - -$RCMAIL->storage->set_folder($_SESSION['mbox'] = $mbox); -$RCMAIL->storage->set_page($_SESSION['page'] = $page); - -$a_threading = $RCMAIL->config->get('message_threading', array()); -$message_sort_col = $RCMAIL->config->get('message_sort_col'); -$message_sort_order = $RCMAIL->config->get('message_sort_order'); - -// set default sort col/order to session -if (!isset($_SESSION['sort_col'])) { - $_SESSION['sort_col'] = $message_sort_col ? $message_sort_col : ''; -} -if (!isset($_SESSION['sort_order'])) { - $_SESSION['sort_order'] = strtoupper($message_sort_order) == 'ASC' ? 'ASC' : 'DESC'; -} - -// set threads mode -if (isset($_GET['_threads'])) { - if ($_GET['_threads']) - $a_threading[$_SESSION['mbox']] = true; - else - unset($a_threading[$_SESSION['mbox']]); - - $RCMAIL->user->save_prefs(array('message_threading' => $a_threading)); -} -$RCMAIL->storage->set_threading($a_threading[$_SESSION['mbox']]); +// init environment - set current folder, page, list mode +rcmail_init_env(); // set message set for search result if (!empty($_REQUEST['_search']) && isset($_SESSION['search']) @@ -187,6 +156,61 @@ $RCMAIL->register_action_map(array( /** + * Sets storage properties and session + */ +function rcmail_init_env() +{ + global $RCMAIL; + + $a_threading = $RCMAIL->config->get('message_threading', array()); + $message_sort_col = $RCMAIL->config->get('message_sort_col'); + $message_sort_order = $RCMAIL->config->get('message_sort_order'); + + // set imap properties and session vars + if (!strlen($mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC, true))) { + $mbox = strlen($_SESSION['mbox']) ? $_SESSION['mbox'] : 'INBOX'; + } + if (!($page = intval($_GET['_page']))) { + $page = $_SESSION['page'] ? $_SESSION['page'] : 1; + } + + $RCMAIL->storage->set_folder($_SESSION['mbox'] = $mbox); + $RCMAIL->storage->set_page($_SESSION['page'] = $page); + + // set default sort col/order to session + if (!isset($_SESSION['sort_col'])) { + $_SESSION['sort_col'] = $message_sort_col ? $message_sort_col : ''; + } + if (!isset($_SESSION['sort_order'])) { + $_SESSION['sort_order'] = strtoupper($message_sort_order) == 'ASC' ? 'ASC' : 'DESC'; + } + + // set threads mode + if (isset($_GET['_threads'])) { + if ($_GET['_threads']) { + // re-set current page number when listing mode changes + if (!$a_threading[$_SESSION['mbox']]) { + $RCMAIL->storage->set_page($_SESSION['page'] = 1); + } + + $a_threading[$_SESSION['mbox']] = true; + } + else { + // re-set current page number when listing mode changes + if ($a_threading[$_SESSION['mbox']]) { + $RCMAIL->storage->set_page($_SESSION['page'] = 1); + } + + unset($a_threading[$_SESSION['mbox']]); + } + + $RCMAIL->user->save_prefs(array('message_threading' => $a_threading)); + } + + $RCMAIL->storage->set_threading($a_threading[$_SESSION['mbox']]); +} + +/** * Returns default search mods */ function rcmail_search_mods() @@ -863,95 +887,29 @@ function rcmail_print_body($part, $p = array()) // 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); + $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', array('type' => $part->ctype_secondary, 'body' => $body, 'id' => $part->mime_id) + $data); - return $data['type'] == 'html' ? $data['body'] : html::tag('pre', array(), $data['body']); + return $data['body']; } /** * Handle links and citation marks in plain text message * * @param string Plain text string + * @param boolean Set to True if the source text is in 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); - - // search for patterns like links and e-mail addresses and replace with tokens - $body = $replacer->replace($body); - - // split body into single lines - $body = preg_split('/\r?\n/', $body); - $quote_level = 0; - $last = -1; - - // find/mark quoted lines... - for ($n=0, $cnt=count($body); $n < $cnt; $n++) { - if ($body[$n][0] == '>' && preg_match('/^(>+ {0,1})+/', $body[$n], $regs)) { - $q = substr_count($regs[0], '>'); - $body[$n] = substr($body[$n], strlen($regs[0])); - - if ($q > $quote_level) { - $body[$n] = $replacer->get_replacement($replacer->add( - str_repeat('<blockquote>', $q - $quote_level))) . $body[$n]; - $last = $n; - } - else if ($q < $quote_level) { - $body[$n] = $replacer->get_replacement($replacer->add( - str_repeat('</blockquote>', $quote_level - $q))) . $body[$n]; - $last = $n; - } - } - else { - $q = 0; - if ($quote_level > 0) - $body[$n] = $replacer->get_replacement($replacer->add( - str_repeat('</blockquote>', $quote_level))) . $body[$n]; - } - - $quote_level = $q; - } - - $body = join("\n", $body); - - // quote plain text (don't use rcube::Q() here, to display entities "as is") - $table = get_html_translation_table(HTML_SPECIALCHARS); - unset($table['?']); - $body = strtr($body, $table); - - // colorize signature (up to <sig_max_lines> lines) - $len = strlen($body); - $sig_max_lines = $RCMAIL->config->get('sig_max_lines', 15); - - while (($sp = strrpos($body, "-- \n", $sp ? -$len+$sp-1 : 0)) !== false) { - if ($sp == 0 || $body[$sp-1] == "\n") { - // do not touch blocks with more that X lines - if (substr_count($body, "\n", $sp) < $sig_max_lines) { - $body = substr($body, 0, max(0, $sp)) - . '<span class="sig">'.substr($body, $sp).'</span>'; - } - - break; - } - } - - // insert url/mailto links and citation tags - $body = $replacer->resolve($body); + $options = array('flowed' => $flowed, 'wrap' => !$flowed); + $text2html = new rcube_text2html($body, false, $options); + $body = $text2html->get_html(); return $body; } @@ -1106,7 +1064,9 @@ function rcmail_message_headers($attrib, $headers=null) $plugin = $RCMAIL->plugins->exec_hook('message_headers_output', array( 'output' => $output_headers, 'headers' => $headers_obj, - 'exclude' => $exclude_headers + 'exclude' => $exclude_headers, // readonly + 'folder' => $MESSAGE->folder, // readonly + 'uid' => $MESSAGE->uid, // readonly )); // single header value is requested @@ -1281,8 +1241,8 @@ function rcmail_message_body($attrib) $plugin = $RCMAIL->plugins->exec_hook('message_body_prefix', array('part' => $MESSAGE, 'prefix' => '')); - $out .= html::div('message-part', $plugin['prefix'] . html::tag('pre', array(), - rcmail_plain_body(rcube::Q($MESSAGE->body, 'strict', false)))); + $out .= html::div('message-part', + $plugin['prefix'] . rcmail_plain_body($MESSAGE->body)); } } @@ -1352,12 +1312,10 @@ function rcmail_message_body($attrib) function rcmail_part_image_type($part) { - $rcmail = rcmail::get_instance(); - // Skip TIFF images if browser doesn't support this format... $tiff_support = !empty($_SESSION['browser_caps']) && !empty($_SESSION['browser_caps']['tif']); // until we can convert them to JPEG - $tiff_support = $tiff_support || $rcmail->config->get('im_convert_path'); + $tiff_support = $tiff_support || rcube_image::is_convertable('image/tiff'); // Content-type regexp $mime_regex = $tiff_support ? '/^image\//i' : '/^image\/(?!tif)/i'; diff --git a/program/steps/mail/get.inc b/program/steps/mail/get.inc index c6262097f..02d57c7dc 100644 --- a/program/steps/mail/get.inc +++ b/program/steps/mail/get.inc @@ -221,7 +221,7 @@ else if (strlen($part_id)) { // TIFF to JPEG conversion, if needed $tiff_support = !empty($_SESSION['browser_caps']) && !empty($_SESSION['browser_caps']['tif']); if (!empty($_REQUEST['_embed']) && !$tiff_support - && $RCMAIL->config->get('im_convert_path') + && rcube_image::is_convertable('image/tiff') && rcmail_part_image_type($part) == 'image/tiff' ) { $tiff2jpeg = true; diff --git a/program/steps/mail/list.inc b/program/steps/mail/list.inc index c4a6df57b..496c95146 100644 --- a/program/steps/mail/list.inc +++ b/program/steps/mail/list.inc @@ -20,7 +20,7 @@ */ if (!$OUTPUT->ajax_call) { - return; + return; } $save_arr = array(); @@ -28,28 +28,28 @@ $dont_override = (array) $RCMAIL->config->get('dont_override'); // is there a sort type for this request? if ($sort = rcube_utils::get_input_value('_sort', rcube_utils::INPUT_GET)) { - // yes, so set the sort vars - list($sort_col, $sort_order) = explode('_', $sort); - - // set session vars for sort (so next page and task switch know how to sort) - if (!in_array('message_sort_col', $dont_override)) { - $_SESSION['sort_col'] = $save_arr['message_sort_col'] = $sort_col; - } - if (!in_array('message_sort_order', $dont_override)) { - $_SESSION['sort_order'] = $save_arr['message_sort_order'] = $sort_order; - } + // yes, so set the sort vars + list($sort_col, $sort_order) = explode('_', $sort); + + // set session vars for sort (so next page and task switch know how to sort) + if (!in_array('message_sort_col', $dont_override)) { + $_SESSION['sort_col'] = $save_arr['message_sort_col'] = $sort_col; + } + if (!in_array('message_sort_order', $dont_override)) { + $_SESSION['sort_order'] = $save_arr['message_sort_order'] = $sort_order; + } } // is there a set of columns for this request? if ($cols = rcube_utils::get_input_value('_cols', rcube_utils::INPUT_GET)) { - $_SESSION['list_attrib']['columns'] = explode(',', $cols); - if (!in_array('list_cols', $dont_override)) { - $save_arr['list_cols'] = explode(',', $cols); - } + $_SESSION['list_attrib']['columns'] = explode(',', $cols); + if (!in_array('list_cols', $dont_override)) { + $save_arr['list_cols'] = explode(',', $cols); + } } if (!empty($save_arr)) { - $RCMAIL->user->save_prefs($save_arr); + $RCMAIL->user->save_prefs($save_arr); } $mbox_name = $RCMAIL->storage->get_folder(); @@ -60,27 +60,30 @@ $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']); + $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']); } // 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()); +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()); +} // update search set (possible change of threading mode) if (!empty($_REQUEST['_search']) && isset($_SESSION['search']) && $_SESSION['search_request'] == $_REQUEST['_search'] ) { - $_SESSION['search'] = $RCMAIL->storage->get_search_set(); + $_SESSION['search'] = $RCMAIL->storage->get_search_set(); } // remove old search data else if (empty($_REQUEST['_search']) && isset($_SESSION['search'])) { - $RCMAIL->session->remove('search'); + $RCMAIL->session->remove('search'); } // empty result? we'll skip UNSEEN counting in rcmail_send_unread_count() @@ -93,7 +96,7 @@ rcmail_send_unread_count($mbox_name, !empty($_REQUEST['_refresh']), $unseen); // update message count display $pages = ceil($count/$RCMAIL->storage->get_pagesize()); -$exists = $RCMAIL->storage->count($mbox_name, 'EXISTS'); +$exists = $RCMAIL->storage->count($mbox_name, 'EXISTS', true); $OUTPUT->set_env('messagecount', $count); $OUTPUT->set_env('pagecount', $pages); @@ -104,33 +107,35 @@ $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count), $mbox_nam // remove old message rows if commanded by the client if (!empty($_REQUEST['_clear'])) { - $OUTPUT->command('clear_message_list'); + $OUTPUT->command('clear_message_list'); } // add message rows rcmail_js_message_list($a_headers, false, $cols); if (isset($a_headers) && count($a_headers)) { - if ($search_request) { - $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $count)); - } - - // remember last HIGHESTMODSEQ value (if supported) - // we need it for flag updates in check-recent - $data = $RCMAIL->storage->folder_data($mbox_name); - if (!empty($data['HIGHESTMODSEQ'])) { - $_SESSION['list_mod_seq'] = $data['HIGHESTMODSEQ']; - } + if ($search_request) { + $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $count)); + } + + // remember last HIGHESTMODSEQ value (if supported) + // we need it for flag updates in check-recent + $data = $RCMAIL->storage->folder_data($mbox_name); + if (!empty($data['HIGHESTMODSEQ'])) { + $_SESSION['list_mod_seq'] = $data['HIGHESTMODSEQ']; + } } else { - // handle IMAP errors (e.g. #1486905) - if ($err_code = $RCMAIL->storage->get_error_code()) { - $RCMAIL->display_server_error(); - } - else if ($search_request) - $OUTPUT->show_message('searchnomatch', 'notice'); - else - $OUTPUT->show_message('nomessagesfound', 'notice'); + // handle IMAP errors (e.g. #1486905) + if ($err_code = $RCMAIL->storage->get_error_code()) { + $RCMAIL->display_server_error(); + } + else if ($search_request) { + $OUTPUT->show_message('searchnomatch', 'notice'); + } + else { + $OUTPUT->show_message('nomessagesfound', 'notice'); + } } // set trash folder state diff --git a/program/steps/mail/move_del.inc b/program/steps/mail/move_del.inc index c29985875..d98d49d1f 100644 --- a/program/steps/mail/move_del.inc +++ b/program/steps/mail/move_del.inc @@ -166,7 +166,7 @@ else { $OUTPUT->command('set_trash_count', $exists); } else if ($target !== null && $target === $trash) { - $OUTPUT->command('set_trash_count', $RCMAIL->storage->count($trash, 'EXISTS')); + $OUTPUT->command('set_trash_count', $RCMAIL->storage->count($trash, 'EXISTS', true)); } } diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc index e610e9137..4aa22e14b 100644 --- a/program/steps/mail/search.inc +++ b/program/steps/mail/search.inc @@ -162,9 +162,11 @@ if (!empty($result_h)) { // remember last HIGHESTMODSEQ value (if supported) // we need it for flag updates in check-recent - $data = $RCMAIL->storage->folder_data($mbox_name); - if (!empty($data['HIGHESTMODSEQ'])) { - $_SESSION['list_mod_seq'] = $data['HIGHESTMODSEQ']; + if ($mbox !== null) { + $data = $RCMAIL->storage->folder_data($mbox); + if (!empty($data['HIGHESTMODSEQ'])) { + $_SESSION['list_mod_seq'] = $data['HIGHESTMODSEQ']; + } } } // handle IMAP errors (e.g. #1486905) @@ -189,7 +191,7 @@ $OUTPUT->set_env('search_filter', $_SESSION['search_filter']); $OUTPUT->set_env('threading', $RCMAIL->storage->get_threading()); $OUTPUT->set_env('messagecount', $count); $OUTPUT->set_env('pagecount', ceil($count/$RCMAIL->storage->get_pagesize())); -$OUTPUT->set_env('exists', $RCMAIL->storage->count($mbox_name, 'EXISTS')); +$OUTPUT->set_env('exists', $mbox === null ? 0 : $RCMAIL->storage->count($mbox, 'EXISTS')); $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count, 1), $mbox); $OUTPUT->set_pagetitle($RCMAIL->gettext(array('name' => 'searchfor', 'vars' => array('q' => $str)))); $OUTPUT->send(); diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index 04ba94f5e..b70b18b6b 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -273,20 +273,31 @@ if ($isHtml) { } // 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; + $bstyle = !empty($bstyle) ? (" style='" . implode($bstyle, '; ') . "'") : ''; + $message_body = '<html><head>' + . '<meta http-equiv="Content-Type" content="text/html; charset=' . $message_charset . '" /></head>' + . "<body" . $bstyle . ">\r\n" . $message_body; } if (!$savedraft) { if ($isHtml) { - // remove signature's div ID - $message_body = preg_replace('/\s*id="_rc_sig"/', '', $message_body); - - // add inline css for blockquotes - $bstyle = 'padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px'; - $message_body = preg_replace('/<blockquote>/', - '<blockquote type="cite" style="'.$bstyle.'">', $message_body); + $b_style = 'padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0'; + $pre_style = 'margin: 0; padding: 0; font-family: monospace'; + + $message_body = preg_replace( + array( + // remove signature's div ID + '/\s*id="_rc_sig"/', + // add inline css for blockquotes and container + '/<blockquote>/', + '/<div class="pre">/' + ), + array( + '', + '<blockquote type="cite" style="'.$b_style.'">', + '<div class="pre" style="'.$pre_style.'">' + ), + $message_body); } // Check spelling before send @@ -300,10 +311,16 @@ if (!$savedraft) { $COMPOSE['spell_checked'] = true; if (!$spell_result) { - $result = $isHtml ? $spellchecker->get_words() : $spellchecker->get_xml(); + if ($isHtml) { + $result['words'] = $spellchecker->get(); + $result['dictionary'] = (bool) $RCMAIL->config->get('spellcheck_dictionary'); + } + else { + $result = $spellchecker->get_xml(); + } $OUTPUT->show_message('mispellingsfound', 'error'); - $OUTPUT->command('spellcheck_resume', $isHtml, $result); + $OUTPUT->command('spellcheck_resume', $result); $OUTPUT->send('iframe'); } } @@ -411,7 +428,7 @@ if (is_array($COMPOSE['attachments'])) { $attachment = $RCMAIL->plugins->exec_hook('attachment_get', $attachment); if ($isHtml) { - $dispurl = '/\ssrc\s*=\s*[\'"]*\S+display-attachment\S+file=rcmfile' + $dispurl = '/\s(poster|src)\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); @@ -432,7 +449,7 @@ if (is_array($COMPOSE['attachments'])) { $cid .= '@localhost'; } - $message_body = preg_replace($dispurl, ' src="cid:' . $cid . '" ', $message_body); + $message_body = preg_replace($dispurl, ' \\1="cid:' . $cid . '" ', $message_body); $MAIL_MIME->setHTMLBody($message_body); @@ -728,11 +745,11 @@ function rcmail_get_identity($id) /** * go from this: - * <img src="http[s]://.../tiny_mce/plugins/emotions/images/smiley-cool.gif" border="0" alt="Cool" title="Cool" /> + * <img src="http[s]://.../tinymce/plugins/emoticons/img/smiley-cool.gif" border="0" alt="Cool" title="Cool" /> * * to this: * - * <img src="/path/on/server/.../tiny_mce/plugins/emotions/images/smiley-cool.gif" border="0" alt="Cool" title="Cool" /> + * <img src="/path/on/server/.../tinymce/plugins/emoticons/img/smiley-cool.gif" border="0" alt="Cool" title="Cool" /> */ function rcmail_fix_emoticon_paths($mime_message) { @@ -743,7 +760,7 @@ function rcmail_fix_emoticon_paths($mime_message) // remove any null-byte characters before parsing $body = preg_replace('/\x00/', '', $body); - $searchstr = 'program/js/tiny_mce/plugins/emotions/img/'; + $searchstr = 'program/js/tinymce/plugins/emoticons/img/'; $offset = 0; // keep track of added images, so they're only added once @@ -912,7 +929,8 @@ function rcmail_generic_message_footer($isHtml) if (!preg_match('/\.(php|ini|conf)$/', $file) && strpos($file, '/etc/') === false) { $footer = file_get_contents($file); if ($isHtml && !$html_footer) { - $footer = '<pre>' . $footer . '</pre>'; + $t2h = new rcube_text2html($footer, false); + $footer = $t2h->get_html(); } return $footer; } diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc index 7f9a23e7d..0ebdd6277 100644 --- a/program/steps/mail/show.inc +++ b/program/steps/mail/show.inc @@ -102,7 +102,7 @@ if ($uid) { } if (empty($_SESSION['browser_caps']['tif']) && ($key = array_search('image/tiff', $mimetypes)) !== false) { // we can convert tiff to jpeg - if (!$RCMAIL->config->get('im_convert_path')) { + if (!rcube_image::is_convertable('image/tiff')) { unset($mimetypes[$key]); } } @@ -148,11 +148,14 @@ if ($uid) { if (empty($MESSAGE->headers->flags['SEEN']) && ($RCMAIL->action == 'show' || ($RCMAIL->action == 'preview' && intval($RCMAIL->config->get('preview_pane_mark_read')) == 0)) ) { + $RCMAIL->output->command('set_unread_message', $MESSAGE->uid, $mbox_name); $RCMAIL->plugins->exec_hook('message_read', array( 'uid' => $MESSAGE->uid, 'mailbox' => $mbox_name, 'message' => $MESSAGE, )); + + $set_seen_flag = true; } } @@ -174,9 +177,7 @@ else // mark message as read -if ($MESSAGE && $MESSAGE->headers && empty($MESSAGE->headers->flags['SEEN']) && - ($RCMAIL->action == 'show' || ($RCMAIL->action == 'preview' && intval($RCMAIL->config->get('preview_pane_mark_read')) == 0)) -) { +if (!empty($set_seen_flag)) { if ($RCMAIL->storage->set_flag($MESSAGE->uid, 'SEEN')) { if ($count = rcmail_get_unseen_count($mbox_name)) { rcmail_set_unseen_count($mbox_name, $count - 1); diff --git a/program/steps/settings/edit_identity.inc b/program/steps/settings/edit_identity.inc index 3f7b6a58a..e43a7bb60 100644 --- a/program/steps/settings/edit_identity.inc +++ b/program/steps/settings/edit_identity.inc @@ -96,7 +96,7 @@ function rcube_identity_form($attrib) 'spellcheck' => true), 'html_signature' => array('type' => 'checkbox', 'label' => $RCMAIL->gettext('htmlsignature'), - 'onclick' => 'return rcmail_toggle_editor(this, \'rcmfd_signature\');'), + 'onclick' => 'return rcmail.command(\'toggle-editor\', {id: \'rcmfd_signature\', html: this.checked}, \'\', event)'), )) ); diff --git a/program/steps/settings/edit_prefs.inc b/program/steps/settings/edit_prefs.inc index 05f4db6a6..b72c3e73f 100644 --- a/program/steps/settings/edit_prefs.inc +++ b/program/steps/settings/edit_prefs.inc @@ -51,6 +51,10 @@ function rcmail_user_prefs_form($attrib) $out = $form_start; + if(!empty($SECTIONS[$CURR_SECTION]['header'])) { + $out .= html::div(array('id' => 'preferences-header', 'class' =>'boxcontent'), $SECTIONS[$CURR_SECTION]['header']); + } + foreach ($SECTIONS[$CURR_SECTION]['blocks'] as $class => $block) { if (!empty($block['options'])) { $table = new html_table(array('cols' => 2)); diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc index 5da01b757..8f9cf090f 100644 --- a/program/steps/settings/func.inc +++ b/program/steps/settings/func.inc @@ -1241,6 +1241,13 @@ function rcmail_user_prefs($current = null) $sections[$idx]['blocks'] = $data['blocks']; } + $data = $RCMAIL->plugins->exec_hook('preferences_section_header', + array('section' => $sect['id'], 'header' => '', 'current' => $current)); + + if(!empty($data['header'])) { + $sections[$idx]['header'] = $data['header']; + } + return array($sections, $plugin['cols']); } diff --git a/program/steps/utils/html2text.inc b/program/steps/utils/html2text.inc index c01443b22..f6e2bec4d 100644 --- a/program/steps/utils/html2text.inc +++ b/program/steps/utils/html2text.inc @@ -19,7 +19,12 @@ +-----------------------------------------------------------------------+ */ -$html = $HTTP_RAW_POST_DATA; +$html = stream_get_contents(fopen('php://input', 'r')); + +// strip slashes if magic_quotes enabled +if (get_magic_quotes_gpc() || get_magic_quotes_runtime()) { + $html = stripslashes($html); +} // Replace emoticon images with its text representation $html = $RCMAIL->replace_emoticons($html); diff --git a/program/steps/utils/spell_html.inc b/program/steps/utils/spell_html.inc index 5935dc13f..6722f8787 100644 --- a/program/steps/utils/spell_html.inc +++ b/program/steps/utils/spell_html.inc @@ -19,31 +19,28 @@ +-----------------------------------------------------------------------+ */ -// read input data -$data = file_get_contents('php://input'); -// Decode JSON input -$request = json_decode($data, true); +$method = rcube_utils::get_input_value('method', rcube_utils::INPUT_POST); +$lang = rcube_utils::get_input_value('lang', rcube_utils::INPUT_POST); $result = array(); -$lang = $request['params'][0]; -$data = $request['params'][1]; -$data = implode("\n", (array) $data); - -$result['id'] = $request['id']; - $spellchecker = new rcube_spellchecker($lang); -if ($request['method'] == 'checkWords') { - $result['result'] = empty($data) ? array() : $spellchecker->get_words($data); -} -else if ($request['method'] == 'getSuggestions') { - $result['result'] = $spellchecker->get_suggestions($data); -} -else if ($request['method'] == 'learnWord') { +if ($method == 'addToDictionary') { + $data = rcube_utils::get_input_value('word', rcube_utils::INPUT_POST); + $spellchecker->add_word($data); $result['result'] = true; } +else { + $data = rcube_utils::get_input_value('text', rcube_utils::INPUT_POST, true); + $data = html_entity_decode($data, ENT_QUOTES, RCUBE_CHARSET); + + if ($data && !$spellchecker->check($data)) { + $result['words'] = $spellchecker->get(); + $result['dictionary'] = (bool) $RCMAIL->config->get('spellcheck_dictionary'); + } +} if ($error = $spellchecker->error()) { rcube::raise_error(array('code' => 500, 'type' => 'php', @@ -51,12 +48,11 @@ if ($error = $spellchecker->error()) { 'message' => sprintf("Spell check engine error: " . $error)), true, false); - echo '{"error":{"errstr":"' . addslashes($error) . '","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}'; + echo json_encode(array('error' => $error)); exit; } // send output -header("Content-Type: text/xml; charset=".RCUBE_CHARSET); +header("Content-Type: application/json; charset=".RCUBE_CHARSET); echo json_encode($result); exit; - diff --git a/program/steps/utils/text2html.inc b/program/steps/utils/text2html.inc new file mode 100644 index 000000000..56d15fa19 --- /dev/null +++ b/program/steps/utils/text2html.inc @@ -0,0 +1,33 @@ +<?php + +/* + +-----------------------------------------------------------------------+ + | program/steps/utils/text2html.inc | + | | + | This file is part of the Roundcube Webmail client | + | Copyright (C) 2005-2014, The Roundcube Dev Team | + | | + | Licensed under the GNU General Public License version 3 or | + | any later version with exceptions for skins & plugins. | + | See the README file for a full license statement. | + | | + | PURPOSE: | + | Convert plain text to HTML | + | | + +-----------------------------------------------------------------------+ + | Author: Thomas Bruederli <roundcube@gmail.com> | + +-----------------------------------------------------------------------+ +*/ + +$text = stream_get_contents(fopen('php://input', 'r')); + +// strip slashes if magic_quotes enabled +if (get_magic_quotes_gpc() || get_magic_quotes_runtime()) { + $html = stripslashes($html); +} + +$converter = new rcube_text2html($text, false, array('wrap' => true)); + +header('Content-Type: text/html; charset=' . RCUBE_CHARSET); +print $converter->get_html(); +exit; |