Aleksander Machniak
2013-12-30 5e303496399909268ec3a8a27ade4ff78c6dea81
CS fixes
1 files modified
264 ■■■■■ changed files
program/steps/mail/compose.inc 264 ●●●●● patch | view | raw | blame | history
program/steps/mail/compose.inc
@@ -5,7 +5,7 @@
 | program/steps/mail/compose.inc                                        |
 |                                                                       |
 | This file is part of the Roundcube Webmail client                     |
 | Copyright (C) 2005-2012, The Roundcube Dev Team                       |
 | Copyright (C) 2005-2013, The Roundcube Dev Team                       |
 |                                                                       |
 | Licensed under the GNU General Public License version 3 or            |
 | any later version with exceptions for skins & plugins.                |
@@ -37,19 +37,20 @@
while ($COMPOSE_ID && !is_array($COMPOSE) && $RCMAIL->db->is_replicated() && $retries++ < 5) {
  usleep(500000);
  $RCMAIL->session->reload();
  if ($_SESSION['compose_data_'.$COMPOSE_ID])
    if ($_SESSION['compose_data_'.$COMPOSE_ID]) {
    $COMPOSE =& $_SESSION['compose_data_'.$COMPOSE_ID];
    }
}
// Nothing below is called during message composition, only at "new/forward/reply/draft" initialization or
// if a compose-ID is given (i.e. when the compose step is opened in a new window/tab).
if (!is_array($COMPOSE))
{
if (!is_array($COMPOSE)) {
  // Infinite redirect prevention in case of broken session (#1487028)
  if ($COMPOSE_ID)
    if ($COMPOSE_ID) {
    rcube::raise_error(array('code' => 500, 'type' => 'php',
      'file' => __FILE__, 'line' => __LINE__,
      'message' => "Invalid compose ID"), true, true);
    }
  $COMPOSE_ID = uniqid(mt_rand());
  $_SESSION['compose_data_'.$COMPOSE_ID] = array(
@@ -112,19 +113,19 @@
    'fileuploaderror', 'sendmessage', 'savenewresponse', 'responsename', 'responsetext', 'save',
    'savingresponse', 'restoresavedcomposedata', 'restoremessage', 'delete', 'restore', 'ignore');
$OUTPUT->set_pagetitle($RCMAIL->gettext('compose'));
$OUTPUT->set_env('compose_id', $COMPOSE['id']);
$OUTPUT->set_env('session_id', session_id());
$OUTPUT->set_pagetitle($RCMAIL->gettext('compose'));
$OUTPUT->set_env('mailbox', $RCMAIL->storage->get_folder());
$OUTPUT->set_env('top_posting', intval($RCMAIL->config->get('reply_mode')) > 0);
$OUTPUT->set_env('recipients_separator', trim($RCMAIL->config->get('recipients_separator', ',')));
// add config parameters to client script
if (!empty($CONFIG['drafts_mbox'])) {
  $OUTPUT->set_env('drafts_mailbox', $CONFIG['drafts_mbox']);
  $OUTPUT->set_env('draft_autosave', $CONFIG['draft_autosave']);
}
// set current mailbox in client environment
$OUTPUT->set_env('mailbox', $RCMAIL->storage->get_folder());
$OUTPUT->set_env('top_posting', intval($RCMAIL->config->get('reply_mode')) > 0);
$OUTPUT->set_env('recipients_separator', trim($RCMAIL->config->get('recipients_separator', ',')));
// default font for HTML editor
$font = rcmail::font_defs($RCMAIL->config->get('default_font'));
@@ -162,8 +163,9 @@
if ($compose_mode == RCUBE_COMPOSE_EDIT || $compose_mode == RCUBE_COMPOSE_DRAFT) {
  // don't add signature in draft/edit mode, we'll also not remove the old-one
  // but only on page display, later we should be able to change identity/sig (#1489229)
  if ($config_show_sig == 1 || $config_show_sig == 2)
    if ($config_show_sig == 1 || $config_show_sig == 2) {
    $OUTPUT->set_env('show_sig_later', true);
    }
}
else if ($config_show_sig == 1)
  $OUTPUT->set_env('show_sig', true);
@@ -175,8 +177,7 @@
// set line length for body wrapping
$LINE_LENGTH = $RCMAIL->config->get('line_length', 72);
if (!empty($msg_uid) && empty($COMPOSE['as_attachment']))
{
if (!empty($msg_uid) && empty($COMPOSE['as_attachment'])) {
  $mbox_name = $RCMAIL->storage->get_folder();
  // set format before rcube_message construction
@@ -192,11 +193,13 @@
  $MESSAGE = new rcube_message($msg_uid);
  // make sure message is marked as read
  if ($MESSAGE->headers && empty($MESSAGE->headers->flags['SEEN']))
    if ($MESSAGE->headers && empty($MESSAGE->headers->flags['SEEN'])) {
    $RCMAIL->storage->set_flag($msg_uid, 'SEEN');
    }
  if (!empty($MESSAGE->headers->charset))
    if (!empty($MESSAGE->headers->charset)) {
    $RCMAIL->storage->set_charset($MESSAGE->headers->charset);
    }
  if (!$MESSAGE->headers) {
    // error
@@ -206,8 +209,9 @@
    $COMPOSE['reply_msgid'] = $MESSAGE->headers->messageID;
    $COMPOSE['references']  = trim($MESSAGE->headers->references . " " . $MESSAGE->headers->messageID);
    if (!empty($COMPOSE['param']['all']))
        if (!empty($COMPOSE['param']['all'])) {
      $MESSAGE->reply_all = $COMPOSE['param']['all'];
        }
    // Save the sent message in the same folder of the message being replied to
    if ($RCMAIL->config->get('reply_same_folder') && ($sent_folder = $COMPOSE['mailbox'])
@@ -243,8 +247,9 @@
      $OUTPUT->set_env('draft_id', $msg_uid);
    }
    if ($in_reply_to = $MESSAGE->headers->get('in-reply-to'))
        if ($in_reply_to = $MESSAGE->headers->get('in-reply-to')) {
      $COMPOSE['reply_msgid'] = '<' . $in_reply_to . '>';
        }
    $COMPOSE['references'] = $MESSAGE->headers->references;
  }
@@ -256,6 +261,7 @@
  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'];
  }
@@ -377,18 +383,17 @@
    $fvalue = array();
    foreach ($to_addresses as $addr_part) {
      if (empty($addr_part['mailto']))
            if (empty($addr_part['mailto'])) {
        continue;
            }
      $mailto = format_email(rcube_utils::idn_to_utf8($addr_part['mailto']));
      if (!in_array($mailto, $a_recipients)
        && (
          $header == 'to'
                && ($header == 'to'
          || $compose_mode != RCUBE_COMPOSE_REPLY
          || empty($MESSAGE->compose['from_email'])
          || $mailto != $MESSAGE->compose['from_email']
        )
                    || $mailto != $MESSAGE->compose['from_email'])
      ) {
        if ($addr_part['name'] && $addr_part['mailto'] != $addr_part['name'])
          $string = format_email_recipient($mailto, $addr_part['name']);
@@ -409,6 +414,28 @@
// process $MESSAGE body/attachments, set $MESSAGE_BODY/$HTML_MODE vars and some session data
$MESSAGE_BODY = rcmail_prepare_message_body();
// register UI objects
$OUTPUT->add_handlers(array(
    'composeheaders'        => 'rcmail_compose_headers',
    'composesubject'        => 'rcmail_compose_subject',
    'composebody'           => 'rcmail_compose_body',
    'composeattachmentlist' => 'rcmail_compose_attachment_list',
    'composeattachmentform' => 'rcmail_compose_attachment_form',
    'composeattachment'     => 'rcmail_compose_attachment_field',
    'filedroparea'          => 'compose_file_drop_area',
    'priorityselector'      => 'rcmail_priority_selector',
    'editorselector'        => 'rcmail_editor_selector',
    'receiptcheckbox'       => 'rcmail_receipt_checkbox',
    'dsncheckbox'           => 'rcmail_dsn_checkbox',
    'storetarget'           => 'rcmail_store_target_selection',
    'addressbooks'          => 'rcmail_addressbook_list',
    'addresslist'           => 'rcmail_contacts_list',
    'responseslist'         => 'rcmail_compose_responses_list',
));
$OUTPUT->send('compose');
/****** compose mode functions ********/
@@ -436,6 +463,7 @@
        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'];
@@ -451,7 +479,7 @@
  }
  // clean HTML message body which can be submitted by URL
  if ($COMPOSE['param']['body']) {
    if (!empty($COMPOSE['param']['body'])) {
    $COMPOSE['param']['body'] = rcmail_wash_html($COMPOSE['param']['body'], array('safe' => false, 'inline_html' => true), array());
  }
@@ -474,8 +502,7 @@
  $out  = '';
  $part = strtolower($attrib['part']);
  switch ($part)
  {
    switch ($part) {
    case 'from':
      return $form_start . rcmail_compose_header_from($attrib);
@@ -508,21 +535,23 @@
      break;
  }
  if ($fname && $field_type)
  {
    if ($fname && $field_type) {
    // pass the following attributes to the form class
    $field_attrib = array('name' => $fname, 'spellcheck' => 'false');
    foreach ($attrib as $attr => $value)
      if (in_array($attr, $allow_attrib))
        foreach ($attrib as $attr => $value) {
            if (in_array($attr, $allow_attrib)) {
        $field_attrib[$attr] = $value;
            }
        }
    // create teaxtarea object
    $input = new $field_type($field_attrib);
    $out = $input->show($MESSAGE->compose[$param]);
  }
  if ($form_start)
    if ($form_start) {
    $out = $form_start.$out;
    }
  // configure autocompletion
  $RCMAIL->autocomplete_init();
@@ -537,12 +566,13 @@
  // pass the following attributes to the form class
  $field_attrib = array('name' => '_from');
  foreach ($attrib as $attr => $value)
    if (in_array($attr, array('id', 'class', 'style', 'size', 'tabindex')))
    foreach ($attrib as $attr => $value) {
        if (in_array($attr, array('id', 'class', 'style', 'size', 'tabindex'))) {
      $field_attrib[$attr] = $value;
        }
    }
  if (count($MESSAGE->identities))
  {
    if (count($MESSAGE->identities)) {
    $a_signatures = array();
    $identities   = array();
    $separator    = intval($RCMAIL->config->get('reply_mode')) > 0
@@ -552,14 +582,12 @@
    $select_from = new html_select($field_attrib);
    // create SELECT element
    foreach ($MESSAGE->identities as $sql_arr)
    {
        foreach ($MESSAGE->identities as $sql_arr) {
      $identity_id = $sql_arr['identity_id'];
      $select_from->add(format_email_recipient($sql_arr['email'], $sql_arr['name']), $identity_id);
      // add signature to array
      if (!empty($sql_arr['signature']) && empty($COMPOSE['param']['nosig']))
      {
            if (!empty($sql_arr['signature']) && empty($COMPOSE['param']['nosig'])) {
        $text = $html = $sql_arr['signature'];
        if ($sql_arr['html_signature']) {
@@ -614,8 +642,9 @@
  global $RCMAIL, $compose_mode;
  static $useHtml;
  if ($useHtml !== null)
    if ($useHtml !== null) {
    return $useHtml;
    }
  $html_editor = intval($RCMAIL->config->get('htmleditor'));
@@ -641,6 +670,7 @@
function rcmail_message_is_html()
{
    global $RCMAIL, $MESSAGE;
    return $RCMAIL->config->get('prefer_html') && ($MESSAGE instanceof rcube_message) && $MESSAGE->has_html_part(true);
}
@@ -661,6 +691,7 @@
  else if ($compose_mode == RCUBE_COMPOSE_FORWARD && $COMPOSE['as_attachment']) {
    $isHtml = rcmail_compose_editor_mode();
    $body = '';
    rcmail_write_forward_attachments();
  }
  // reply/edit/draft/forward
@@ -716,6 +747,7 @@
  $plugin = $RCMAIL->plugins->exec_hook('message_compose_body',
    array('body' => $body, 'html' => $isHtml, 'mode' => $compose_mode));
  $body = $plugin['body'];
  unset($plugin);
@@ -854,6 +886,7 @@
  else {
    $textarea = new html_textarea($attrib);
    $out .= $textarea->show('');
    // quote plain text, inject into textarea
    $table = get_html_translation_table(HTML_SPECIALCHARS);
    $MESSAGE_BODY = strtr($MESSAGE_BODY, $table);
@@ -875,11 +908,13 @@
    $lang = $_SESSION['language'];
    // if not found in the list, try with two-letter code
    if (!$spellcheck_langs[$lang])
        if (!$spellcheck_langs[$lang]) {
      $lang = strtolower(substr($lang, 0, 2));
        }
    if (!$spellcheck_langs[$lang])
        if (!$spellcheck_langs[$lang]) {
      $lang = 'en';
        }
    $OUTPUT->set_env('spell_langs', $spellcheck_langs);
    $OUTPUT->set_env('spell_lang', $lang);
@@ -986,8 +1021,9 @@
  global $RCMAIL, $MESSAGE, $COMPOSE;
  // add attachments
  if (!isset($COMPOSE['forward_attachments']) && is_array($MESSAGE->mime_parts))
    if (!isset($COMPOSE['forward_attachments']) && is_array($MESSAGE->mime_parts)) {
    $cid_map = rcmail_write_compose_attachments($MESSAGE, $bodyIsHtml);
    }
  $date = $RCMAIL->format_date($MESSAGE->headers->date, $RCMAIL->config->get('date_long'));
@@ -998,10 +1034,12 @@
    $prefix .= $RCMAIL->gettext('from')    . ': ' . $MESSAGE->get_header('from') . "\n";
    $prefix .= $RCMAIL->gettext('to')      . ': ' . $MESSAGE->get_header('to') . "\n";
    if ($cc = $MESSAGE->headers->get('cc'))
        if ($cc = $MESSAGE->headers->get('cc')) {
      $prefix .= $RCMAIL->gettext('cc') . ': ' . $cc . "\n";
    if (($replyto = $MESSAGE->headers->get('reply-to')) && $replyto != $MESSAGE->get_header('from'))
        }
        if (($replyto = $MESSAGE->headers->get('reply-to')) && $replyto != $MESSAGE->get_header('from')) {
      $prefix .= $RCMAIL->gettext('replyto') . ': ' . $replyto . "\n";
        }
    $prefix .= "\n";
    $body = trim($body, "\r\n");
@@ -1009,6 +1047,7 @@
  else {
    // set is_safe flag (we need this for html body washing)
    rcmail_check_safe($MESSAGE);
    // clean up html tags
    $body = rcmail_wash_html($body, array('safe' => $MESSAGE->is_safe), $cid_map);
@@ -1043,14 +1082,12 @@
{
  global $MESSAGE, $COMPOSE;
  /**
   * add attachments
   * sizeof($MESSAGE->mime_parts can be 1 - e.g. attachment, but no text!
   */
    // add attachments
    // sizeof($MESSAGE->mime_parts can be 1 - e.g. attachment, but no text!
  if (empty($COMPOSE['forward_attachments'])
      && is_array($MESSAGE->mime_parts)
      && count($MESSAGE->mime_parts) > 0)
  {
        && count($MESSAGE->mime_parts) > 0
    ) {
    $cid_map = rcmail_write_compose_attachments($MESSAGE, $bodyIsHtml);
  }
@@ -1105,17 +1142,18 @@
  $cid_map  = array();
  $messages = array();
  foreach ((array)$message->mime_parts as $pid => $part)
  {
    foreach ((array)$message->mime_parts as $pid => $part) {
    if ($part->disposition == 'attachment' || ($part->disposition == 'inline' && $bodyIsHtml) || $part->filename) {
      // skip parts that aren't valid attachments
      if ($part->ctype_primary == 'multipart' || $part->mimetype == 'application/ms-tnef') {
        continue;
      }
      // skip message attachments in reply mode
      if ($part->ctype_primary == 'message' && $compose_mode == RCUBE_COMPOSE_REPLY) {
        continue;
      }
      // skip inline images when forwarding in text mode
      if ($part->content_id && $part->disposition == 'inline' && !$bodyIsHtml && $compose_mode == RCUBE_COMPOSE_FORWARD) {
        continue;
@@ -1134,18 +1172,22 @@
      }
      else if ($compose_mode != RCUBE_COMPOSE_FORWARD) {
        // skip attachments included in message/rfc822 attachment (#1486487)
        foreach ($messages as $mimeid)
                foreach ($messages as $mimeid) {
          if (strpos($part->mime_id, $mimeid . '.') === 0) {
            continue 2;
          }
      }
            }
      if (($attachment = $loaded_attachments[rcmail_attachment_name($part) . $part->mimetype])
          || ($attachment = rcmail_save_attachment($message, $pid))) {
                || ($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',
            $RCMAIL->comm_path, $COMPOSE['id'], $attachment['id']);
          if ($part->content_id)
            $cid_map['cid:'.$part->content_id] = $url;
          else
@@ -1172,6 +1214,7 @@
        $COMPOSE['attachments'][$attachment['id']] = $attachment;
          $url = sprintf('%s&_id=%s&_action=display-attachment&_file=rcmfile%s',
            $RCMAIL->comm_path, $COMPOSE['id'], $attachment['id']);
        if ($part->content_id)
          $cid_map['cid:'.$part->content_id] = $url;
        else
@@ -1189,8 +1232,6 @@
  global $RCMAIL, $COMPOSE, $MESSAGE;
  $storage   = $RCMAIL->get_storage();
  $mem_limit = parse_bytes(ini_get('memory_limit'));
  $curr_mem  = function_exists('memory_get_usage') ? memory_get_usage() : 16*1024*1024; // safe value: 16MB
  $names     = array();
  $loaded_attachments = array();
@@ -1237,7 +1278,7 @@
    }
    // don't load too big attachments into memory
    if ($mem_limit > 0 && $message->size > $mem_limit - $curr_mem) {
        if (!rcube_utils::mem_check($message->size)) {
      $temp_dir = unslashify($RCMAIL->config->get('temp_dir'));
      $path = tempnam($temp_dir, 'rcmAttmnt');
      if ($fp = fopen($path, 'w')) {
@@ -1281,20 +1322,22 @@
  $rcmail = rcmail::get_instance();
  $part = $message->mime_parts[$pid];
  $mem_limit = parse_bytes(ini_get('memory_limit'));
  $curr_mem = function_exists('memory_get_usage') ? memory_get_usage() : 16*1024*1024; // safe value: 16MB
  $data = $path = null;
  // don't load too big attachments into memory
  if ($mem_limit > 0 && $part->size > $mem_limit - $curr_mem) {
    if (!rcube_utils::mem_check($part->size)) {
    $temp_dir = unslashify($rcmail->config->get('temp_dir'));
    $path = tempnam($temp_dir, 'rcmAttmnt');
    if ($fp = fopen($path, 'w')) {
      $message->get_part_content($pid, $fp, true, 0, false);
      fclose($fp);
    } else
        }
        else {
      return false;
  } else {
        }
    }
    else {
    $data = $message->get_part_content($pid, null, true, 0, false);
  }
@@ -1316,7 +1359,8 @@
  if ($attachment['status']) {
    unset($attachment['data'], $attachment['status'], $attachment['content_id'], $attachment['abort']);
    return $attachment;
  } else if ($path) {
    }
    else if ($path) {
    @unlink($path);
  }
@@ -1354,7 +1398,8 @@
  // basename() is not unicode safe and locale dependent
  if (stristr(PHP_OS, 'win') || stristr(PHP_OS, 'netware')) {
    return preg_replace('/^.*[\\\\\\/]/', '', $filename);
  } else {
    }
    else {
    return preg_replace('/^.*[\/]/', '', $filename);
  }
}
@@ -1368,8 +1413,8 @@
  $attrib['name'] = '_subject';
  $attrib['spellcheck'] = 'true';
  $textfield = new html_inputfield($attrib);
    $textfield = new html_inputfield($attrib);
  $subject = '';
  // use subject from post
@@ -1430,11 +1475,11 @@
    }
    foreach ($COMPOSE['attachments'] as $id => $a_prop) {
      if (empty($a_prop))
            if (empty($a_prop)) {
        continue;
            }
      $out .= html::tag('li',
        array(
            $out .= html::tag('li', array(
          'id'          => 'rcmfile'.$id,
          'class'       => rcube_utils::file2class($a_prop['mimetype'], $a_prop['name']),
          'onmouseover' => "rcube_webmail.long_subject_title_ex(this, 0)",
@@ -1449,7 +1494,11 @@
        ) . rcube::Q($a_prop['name'])
      );
      $jslist['rcmfile'.$id] = array('name' => $a_prop['name'], 'complete' => true, 'mimetype' => $a_prop['mimetype']);
            $jslist['rcmfile'.$id] = array(
                'name'     => $a_prop['name'],
                'complete' => true,
                'mimetype' => $a_prop['mimetype']
            );
    }
  }
@@ -1480,19 +1529,26 @@
  $max_filesize = $RCMAIL->upload_init();
  $button = new html_inputfield(array('type' => 'button'));
    $content = html::div(null, rcmail_compose_attachment_field())
        . html::div('hint', $RCMAIL->gettext(array('name' => 'maxuploadsize', 'vars' => array('size' => $max_filesize))));
  $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('hint', $RCMAIL->gettext(array('name' => 'maxuploadsize', 'vars' => array('size' => $max_filesize)))) .
      (rcube_utils::get_boolean($attrib['buttons']) ? html::div('buttons',
    if (rcube_utils::get_boolean($attrib['buttons'])) {
        $content .= html::div('buttons',
        $button->show($RCMAIL->gettext('close'), array('class' => 'button', 'onclick' => "$('#$attrib[id]').hide()")) . ' ' .
        $button->show($RCMAIL->gettext('upload'), array('class' => 'button mainaction', 'onclick' => rcmail_output::JS_OBJECT_NAME . ".command('send-attachment', this.form)"))
      ) : '')
    )
  );
    }
    $out = html::div($attrib, $OUTPUT->form_tag(array(
            'id'      => $attrib['id'] . 'Frm',
            'name'    => 'uploadform',
            'method'  => 'post',
            'enctype' => 'multipart/form-data'
        ), $content
    ));
  $OUTPUT->add_gui_object('uploadform', $attrib['id'].'Frm');
  return $out;
}
@@ -1504,6 +1560,7 @@
  $attrib['multiple'] = 'multiple';
  $field = new html_inputfield($attrib);
  return $field->show();
}
@@ -1516,14 +1573,16 @@
  unset($attrib['form']);
  $attrib['name'] = '_priority';
  $selector = new html_select($attrib);
    $prio_list = array(
        $RCMAIL->gettext('lowest')  => 5,
        $RCMAIL->gettext('low')     => 4,
        $RCMAIL->gettext('normal')  => 0,
        $RCMAIL->gettext('high')    => 2,
        $RCMAIL->gettext('highest') => 1,
    );
  $selector->add(array($RCMAIL->gettext('lowest'),
                       $RCMAIL->gettext('low'),
                       $RCMAIL->gettext('normal'),
                       $RCMAIL->gettext('high'),
                       $RCMAIL->gettext('highest')),
                 array('5', '4', '0', '2', '1'));
    $selector = new html_select($attrib);
    $selector->add(array_keys($prio_list), array_values($prio_list));
  if (isset($_POST['_priority']))
    $sel = $_POST['_priority'];
@@ -1552,6 +1611,7 @@
  $attrib['name'] = '_receipt';
  $attrib['value'] = '1';
  $checkbox = new html_checkbox($attrib);
  if (isset($_POST['_receipt']))
@@ -1581,10 +1641,11 @@
  $attrib['name'] = '_dsn';
  $attrib['value'] = '1';
  $checkbox = new html_checkbox($attrib);
  if (isset($_POST['_dsn']))
    $dsn_value = $_POST['_dsn'];
        $dsn_value = (int) $_POST['_dsn'];
  else
    $dsn_value = $RCMAIL->config->get('dsn_default');
@@ -1617,15 +1678,6 @@
  $select->add(rcube::Q($RCMAIL->gettext('plaintoggle')), 'plain');
  return $select->show($useHtml ? 'html' : 'plain');
/*
  foreach ($choices as $value => $text) {
    $attrib['id'] = '_' . $value;
    $attrib['value'] = $value;
    $selector .= $radio->show($chosenvalue, $attrib) . html::label($attrib['id'], rcube::Q($RCMAIL->gettext($text)));
  }
  return $selector;
*/
}
@@ -1639,6 +1691,7 @@
    'folder_filter' => 'mail',
    'folder_rights' => 'w',
  )));
  return $select->show(isset($_POST['_store_target']) ? $_POST['_store_target'] : $COMPOSE['param']['sent_mbox'], $attrib);
}
@@ -1673,8 +1726,7 @@
  global $RCMAIL, $MESSAGE_FORM, $COMPOSE;
  $form_start = '';
  if (!$MESSAGE_FORM)
  {
    if (!$MESSAGE_FORM) {
    $hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $RCMAIL->task));
    $hiddenfields->add(array('name' => '_action', 'value' => 'send'));
    $hiddenfields->add(array('name' => '_id', 'value' => $COMPOSE['id']));
@@ -1791,25 +1843,3 @@
    return $list->show();
}
// register UI objects
$OUTPUT->add_handlers(array(
  'composeheaders' => 'rcmail_compose_headers',
  'composesubject' => 'rcmail_compose_subject',
  'composebody' => 'rcmail_compose_body',
  'composeattachmentlist' => 'rcmail_compose_attachment_list',
  'composeattachmentform' => 'rcmail_compose_attachment_form',
  'composeattachment' => 'rcmail_compose_attachment_field',
  'filedroparea'    => 'compose_file_drop_area',
  'priorityselector' => 'rcmail_priority_selector',
  'editorselector' => 'rcmail_editor_selector',
  'receiptcheckbox' => 'rcmail_receipt_checkbox',
  'dsncheckbox' => 'rcmail_dsn_checkbox',
  'storetarget' => 'rcmail_store_target_selection',
  'addressbooks' => 'rcmail_addressbook_list',
  'addresslist' => 'rcmail_contacts_list',
  'responseslist' => 'rcmail_compose_responses_list',
));
$OUTPUT->send('compose');