thomascube
2006-12-20 2bca6e1da0e46f93297a7f60ff449b6c6ebac239
program/steps/mail/compose.inc
@@ -20,6 +20,7 @@
*/
require_once('Mail/mimeDecode.php');
require_once('lib/html2text.inc');
// define constants for message compose mode
define('RCUBE_COMPOSE_REPLY', 0x0106);
@@ -76,7 +77,7 @@
  $MESSAGE['structure'] = &$IMAP->get_structure($msg_uid);  
  $MESSAGE['subject'] = $IMAP->decode_header($MESSAGE['headers']->subject);
  $MESSAGE['parts'] = $IMAP->get_mime_numbers($MESSAGE['structure']);
  if ($compose_mode == RCUBE_COMPOSE_REPLY)
    {
    $_SESSION['compose']['reply_uid'] = $msg_uid;
@@ -149,7 +150,10 @@
        }
    case 'bcc':
      if (!$fname)
        {
        $fname = '_bcc';
        $header = 'bcc';
        }
        
      $allow_attrib = array('id', 'class', 'style', 'cols', 'rows', 'wrap', 'tabindex');
      $field_type = 'textarea';            
@@ -171,18 +175,18 @@
    {
    // get recipent address(es) out of the message headers
    if ($header=='to' && !empty($MESSAGE['headers']->replyto))
      $fvalue = $IMAP->decode_header($MESSAGE['headers']->replyto);
      $fvalue = $MESSAGE['headers']->replyto;
    else if ($header=='to' && !empty($MESSAGE['headers']->from))
      $fvalue = $IMAP->decode_header($MESSAGE['headers']->from);
      $fvalue = $MESSAGE['headers']->from;
    // add recipent of original message if reply to all
    else if ($header=='cc' && !empty($MESSAGE['reply_all']))
      {
      if ($v = $IMAP->decode_header($MESSAGE['headers']->to))
      if ($v = $MESSAGE['headers']->to)
        $fvalue .= $v;
      if ($v = $IMAP->decode_header($MESSAGE['headers']->cc))
      if ($v = $MESSAGE['headers']->cc)
        $fvalue .= (!empty($fvalue) ? ', ' : '') . $v;
      }
@@ -212,7 +216,6 @@
    if ($header=='bcc' && !empty($MESSAGE['headers']->bcc))
      $fvalue = $IMAP->decode_header($MESSAGE['headers']->bcc);
    }
        
@@ -253,7 +256,7 @@
    {
    $MESSAGE['FROM'] = array();
    $a_to = $IMAP->decode_address_list($MESSAGE['headers']->to);
    $a_to = $IMAP->decode_address_list($MESSAGE['headers']->to);
    foreach ($a_to as $addr)
      {
      if (!empty($addr['mailto']))
@@ -297,6 +300,12 @@
        {
        $a_signatures[$identity_id]['text'] = $sql_arr['signature'];
        $a_signatures[$identity_id]['is_html'] = ($sql_arr['html_signature'] == 1) ? true : false;
        if ($a_signatures[$identity_id]['is_html'])
          {
            $h2t = new html2text($a_signatures[$identity_id]['text'], false, false);
            $plainTextPart = $h2t->get_text();
            $a_signatures[$identity_id]['plain_text'] = trim($plainTextPart);
          }
        }
      // set identity if it's one of the reply-message recipients
@@ -414,7 +423,7 @@
  $out = $form_start ? "$form_start\n" : '';
  $saveid = new hiddenfield(array('name' => '_draft_saveid', 'value' => str_replace(array('<','>'),"",$MESSAGE['headers']->messageID) ));
  $saveid = new hiddenfield(array('name' => '_draft_saveid', 'value' => $compose_mode==RCUBE_COMPOSE_DRAFT ? str_replace(array('<','>'), "", $MESSAGE['headers']->messageID) : ''));
  $out .= $saveid->show();
  $drafttoggle = new hiddenfield(array('name' => '_draft', 'value' => 'yes'));
@@ -438,25 +447,26 @@
      $lang_set = "googie.setLanguages(".array2js($CONFIG['spellcheck_languages']).");\n";
    
    $OUTPUT->include_script('googiespell.js');
    $OUTPUT->add_script(sprintf("var googie = new GoogieSpell('\$__skin_path/images/googiespell/','%s&_action=spell&lang=');\n".
                                "googie.lang_chck_spell = \"%s\";\n".
                                "googie.lang_rsm_edt = \"%s\";\n".
                                "googie.lang_close = \"%s\";\n".
                                "googie.lang_revert = \"%s\";\n".
                                "googie.lang_no_error_found = \"%s\";\n%s".
                                "googie.setCurrentLanguage('%s');\n".
                                "googie.decorateTextarea('%s');\n".
                                "%s.set_env('spellcheck', googie);",
                                $GLOBALS['COMM_PATH'],
                                rep_specialchars_output(rcube_label('checkspelling')),
                                rep_specialchars_output(rcube_label('resumeediting')),
                                rep_specialchars_output(rcube_label('close')),
                                rep_specialchars_output(rcube_label('revertto')),
                                rep_specialchars_output(rcube_label('nospellerrors')),
                                $lang_set,
                                substr($_SESSION['user_lang'], 0, 2),
                                $attrib['id'],
                                $JS_OBJECT_NAME), 'foot');
    $OUTPUT->add_script(sprintf(
      "var googie = new GoogieSpell('\$__skin_path/images/googiespell/','%s&_action=spell&lang=');\n".
      "googie.lang_chck_spell = \"%s\";\n".
      "googie.lang_rsm_edt = \"%s\";\n".
      "googie.lang_close = \"%s\";\n".
      "googie.lang_revert = \"%s\";\n".
      "googie.lang_no_error_found = \"%s\";\n%s".
      "googie.setCurrentLanguage('%s');\n".
      "googie.decorateTextarea('%s');\n".
      "%s.set_env('spellcheck', googie);",
      $GLOBALS['COMM_PATH'],
      JQ(Q(rcube_label('checkspelling'))),
      JQ(Q(rcube_label('resumeediting'))),
      JQ(Q(rcube_label('close'))),
      JQ(Q(rcube_label('revertto'))),
      JQ(Q(rcube_label('nospellerrors'))),
      $lang_set,
      substr($_SESSION['user_lang'], 0, 2),
      $attrib['id'],
      $JS_OBJECT_NAME), 'foot');
    rcube_add_label('checking');
    }
@@ -543,10 +553,10 @@
        "<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">From: </th><td>%s</td></tr>" .
        "<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">To: </th><td>%s</td></tr>" .
        "</tbody></table><br>",
                     rep_specialchars_output($MESSAGE['subject']),
                     rep_specialchars_output($MESSAGE['headers']->date),
                     rep_specialchars_output($IMAP->decode_header($MESSAGE['headers']->from)),
                     rep_specialchars_output($IMAP->decode_header($MESSAGE['headers']->to)));
                     Q($MESSAGE['subject']),
                     Q($MESSAGE['headers']->date),
                     Q($IMAP->decode_header($MESSAGE['headers']->from)),
                     Q($IMAP->decode_header($MESSAGE['headers']->to)));
  }
  // add attachments
@@ -683,9 +693,9 @@
                      $id,
                      $JS_OBJECT_NAME,
                      $id,
                      rcube_label('delete'),
                      Q(rcube_label('delete')),
                      $button,
                      rep_specialchars_output($a_prop['name']));
                      Q($a_prop['name']));
    }
  $OUTPUT->add_script(sprintf("%s.gui_object('attachmentlist', '%s');", $JS_OBJECT_NAME, $attrib['id']));  
@@ -787,8 +797,8 @@
  global $CONFIG, $MESSAGE, $compose_mode;
  $choices = array(
    'html'  => 'HTML',
    'plain' => 'Plain text'
    'html'  => 'htmltoggle',
    'plain' => 'plaintoggle'
  );
  // determine whether HTML or plain text should be checked 
@@ -806,15 +816,24 @@
    }
  $selector = '';
  $attrib['name'] = '_editorSelect';
  $attrib['onchange'] = 'return rcmail_toggle_editor(this)';
  foreach ($choices as $value => $text)
    {
    $checked = '';
    if ((($text == 'HTML') && $useHtml) ||
        (($text != 'HTML') && !$useHtml))
      $checked = 'checked';
    if ((($value == 'html') && $useHtml) ||
        (($value != 'html') && !$useHtml))
      $attrib['checked'] = 'true';
    else
      unset($attrib['checked']);
    $selector .= sprintf("<input type='radio' name='_editorSelect' value='%s' %s onclick='return rcmail_toggle_editor(this)'>%s</input>\n",
                          $value, $checked, $text);
    $attrib['id'] = '_' . $value;
    $rb = new radiobutton($attrib);
    $selector .= sprintf("<td>%s</td><td class=\"title\"><label for=\"%s\">%s</label></td>",
                         $rb->show($value),
                         $attrib['id'],
                         rcube_label($text));
    }
  return $selector;
@@ -877,7 +896,7 @@
  $a_contacts = array();
  while ($sql_arr = $DB->fetch_assoc($sql_result))
    if ($sql_arr['email'])
      $a_contacts[] = format_email_recipient($sql_arr['email'], rep_specialchars_output($sql_arr['name'], 'js'));
      $a_contacts[] = format_email_recipient($sql_arr['email'], JQ($sql_arr['name']));
  
  $OUTPUT->add_script(sprintf("$JS_OBJECT_NAME.set_env('contacts', %s);", array2js($a_contacts)));
  }