Aleksander Machniak
2012-11-26 3ff8cc2bc83c57010bbfe64efa76b70203857650
program/steps/mail/compose.inc
@@ -130,6 +130,7 @@
    'fileuploaderror', 'sendmessage');
$OUTPUT->set_env('compose_id', $COMPOSE['id']);
$OUTPUT->set_pagetitle(rcube_label('compose'));
// add config parameters to client script
if (!empty($CONFIG['drafts_mbox'])) {
@@ -412,11 +413,11 @@
  else if (in_array($compose_mode, array(RCUBE_COMPOSE_DRAFT, RCUBE_COMPOSE_EDIT))) {
    // get drafted headers
    if ($header=='to' && !empty($MESSAGE->headers->to))
      $fvalue = $MESSAGE->get_header('to');
      $fvalue = $MESSAGE->get_header('to', true);
    else if ($header=='cc' && !empty($MESSAGE->headers->cc))
      $fvalue = $MESSAGE->get_header('cc');
      $fvalue = $MESSAGE->get_header('cc', true);
    else if ($header=='bcc' && !empty($MESSAGE->headers->bcc))
      $fvalue = $MESSAGE->get_header('bcc');
      $fvalue = $MESSAGE->get_header('bcc', true);
    else if ($header=='replyto' && !empty($MESSAGE->headers->others['mail-reply-to']))
      $fvalue = $MESSAGE->get_header('mail-reply-to');
    else if ($header=='replyto' && !empty($MESSAGE->headers->replyto))
@@ -606,14 +607,17 @@
  $html_editor = intval($RCMAIL->config->get('htmleditor'));
  if ($compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT) {
    $useHtml = $MESSAGE->has_html_part(false);
  if (isset($_POST['_is_html'])) {
    $useHtml = !empty($_POST['_is_html']);
  }
  else if ($compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT) {
    $useHtml = $MESSAGE->has_html_part(false, true);
  }
  else if ($compose_mode == RCUBE_COMPOSE_REPLY) {
    $useHtml = ($html_editor == 1 || ($html_editor >= 2 && $MESSAGE->has_html_part(false)));
    $useHtml = ($html_editor == 1 || ($html_editor >= 2 && $MESSAGE->has_html_part(false, true)));
  }
  else if ($compose_mode == RCUBE_COMPOSE_FORWARD) {
    $useHtml = ($html_editor == 1 || ($html_editor == 3 && $MESSAGE->has_html_part(false)));
    $useHtml = ($html_editor == 1 || ($html_editor == 3 && $MESSAGE->has_html_part(false, true)));
  }
  else {
    $useHtml = ($html_editor == 1);
@@ -726,6 +730,10 @@
    if ($isHtml) {
        if ($part->ctype_secondary == 'html') {
        }
        else if ($part->ctype_secondary == 'enriched') {
            require_once(INSTALL_PATH . 'program/lib/enriched.inc');
            $body = enriched_to_html($body);
        }
        else {
            // try to remove the signature
            if ($RCMAIL->config->get('strip_existing_sig', true)) {
@@ -739,12 +747,22 @@
        }
    }
    else {
        if ($part->ctype_secondary == 'enriched') {
            require_once(INSTALL_PATH . 'program/lib/enriched.inc');
            $body = enriched_to_html($body);
            $part->ctype_secondary = 'html';
        }
        if ($part->ctype_secondary == 'html') {
            // use html part if it has been used for message (pre)viewing
            // decrease line length for quoting
            $len = $compose_mode == RCUBE_COMPOSE_REPLY ? $LINE_LENGTH-2 : $LINE_LENGTH;
            $txt = new html2text($body, false, true, $len);
            $body = $txt->get_text();
        }
        else if ($part->ctype_secondary == 'enriched') {
            require_once(INSTALL_PATH . 'program/lib/enriched.inc');
            $body = enriched_to_html($body);
        }
        else {
            if ($part->ctype_secondary == 'plain' && $part->ctype_parameters['format'] == 'flowed') {
@@ -902,9 +920,10 @@
  if (!$bodyIsHtml) {
    $body = preg_replace('/\r?\n/', "\n", $body);
    $body = trim($body, "\n");
    // soft-wrap and quote message text
    $body = rcmail_wrap_and_quote(rtrim($body, "\n"), $LINE_LENGTH);
    $body = rcmail_wrap_and_quote($body, $LINE_LENGTH);
    $prefix .= "\n";
    $suffix = '';
@@ -949,8 +968,7 @@
  $date    = format_date($MESSAGE->headers->date, $RCMAIL->config->get('date_long'));
  $charset = $RCMAIL->output->get_charset();
  if (!$bodyIsHtml)
  {
  if (!$bodyIsHtml) {
    $prefix = "\n\n\n-------- " . rcube_label('originalmessage') . " --------\n";
    $prefix .= rcube_label('subject') . ': ' . $MESSAGE->subject . "\n";
    $prefix .= rcube_label('date')    . ': ' . $date . "\n";
@@ -963,9 +981,9 @@
      $prefix .= rcube_label('replyto') . ': ' . $MESSAGE->get_header('replyto') . "\n";
    $prefix .= "\n";
    $body = trim($body, "\r\n");
  }
  else
  {
  else {
    // set is_safe flag (we need this for html body washing)
    rcmail_check_safe($MESSAGE);
    // clean up html tags
@@ -1445,7 +1463,9 @@
  $attrib['value'] = '1';
  $checkbox = new html_checkbox($attrib);
  if (in_array($compose_mode, array(RCUBE_COMPOSE_DRAFT, RCUBE_COMPOSE_EDIT)))
  if (isset($_POST['_receipt']))
    $mdn_default = $_POST['_receipt'];
  else if (in_array($compose_mode, array(RCUBE_COMPOSE_DRAFT, RCUBE_COMPOSE_EDIT)))
    $mdn_default = (bool) $MESSAGE->headers->mdn_to;
  else
    $mdn_default = $RCMAIL->config->get('mdn_default');
@@ -1472,8 +1492,13 @@
  $attrib['value'] = '1';
  $checkbox = new html_checkbox($attrib);
  if (isset($_POST['_dsn']))
    $dsn_value = $_POST['_dsn'];
  else
    $dsn_value = $RCMAIL->config->get('dsn_default');
  $out = $form_start ? "$form_start\n" : '';
  $out .= $checkbox->show($RCMAIL->config->get('dsn_default'));
  $out .= $checkbox->show($dsn_value);
  $out .= $form_end ? "\n$form_end" : '';
  return $out;
@@ -1520,13 +1545,18 @@
    'folder_filter' => 'mail',
    'folder_rights' => 'w',
  )));
  return $select->show($COMPOSE['param']['sent_mbox'], $attrib);
  return $select->show(isset($_POST['_store_target']) ? $_POST['_store_target'] : $COMPOSE['param']['sent_mbox'], $attrib);
}
function rcmail_check_sent_folder($folder, $create=false)
{
  global $RCMAIL;
  // we'll not save the message, so it doesn't matter
  if ($RCMAIL->config->get('no_save_sent_messages')) {
    return true;
  }
  if ($RCMAIL->storage->folder_exists($folder, true)) {
    return true;
@@ -1585,7 +1615,7 @@
            'rel' => '%s',
            'onclick' => "return ".JS_OBJECT_NAME.".command('list-adresses','%s',this)"), '%s'));
    foreach ($RCMAIL->get_address_sources() as $j => $source) {
    foreach ($RCMAIL->get_address_sources(false, true) as $j => $source) {
        $id = strval(strlen($source['id']) ? $source['id'] : $j);
        $js_id = JQ($id);
@@ -1598,7 +1628,7 @@
            html_identifier($id),
            $class_name,
            $source['id'],
            $js_id, (!empty($source['name']) ? Q($source['name']) : Q($id)));
            $js_id, (!empty($source['name']) ? $source['name'] : $id));
    }
    $OUTPUT->add_gui_object('addressbookslist', $attrib['id']);