Ignore:
Timestamp:
Aug 18, 2006 8:48:33 AM (7 years ago)
Author:
thomasb
Message:

Re-built message parsing (Bug #1327068)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/steps/mail/compose.inc

    r297 r320  
    2020*/ 
    2121 
    22  
    2322require_once('Mail/mimeDecode.php'); 
     23 
     24// define constants for message compose mode 
     25define('RCUBE_COMPOSE_REPLY', 0x0106); 
     26define('RCUBE_COMPOSE_FORWARD', 0x0107); 
     27define('RCUBE_COMPOSE_DRAFT', 0x0108); 
     28 
    2429 
    2530// remove an attachment 
     
    3944 
    4045$MESSAGE_FORM = NULL; 
    41 $REPLY_MESSAGE = NULL; 
    42 $FORWARD_MESSAGE = NULL; 
    43 $DRAFT_MESSAGE = NULL; 
     46$MESSAGE = NULL; 
    4447 
    4548// nothing below is called during message composition, only at "new/forward/reply/draft" initialization 
     
    5457 
    5558 
    56 if ($_GET['_reply_uid'] || $_GET['_forward_uid'] || $_GET['_draft_uid']) 
    57   { 
    58   $msg_uid = ($_GET['_reply_uid'] ? $_GET['_reply_uid'] : ($_GET['_forward_uid'] ? $_GET['_forward_uid'] : $_GET['_draft_uid'])); 
    59  
     59// get reference message and set compose mode 
     60if ($msg_uid = get_input_value('_reply_uid', RCUBE_INPUT_GET)) 
     61  $compose_mode = RCUBE_COMPOSE_REPLY; 
     62else if ($msg_uid = get_input_value('_forward_uid', RCUBE_INPUT_GET)) 
     63  $compose_mode = RCUBE_COMPOSE_FORWARD; 
     64else if ($msg_uid = get_input_value('_draft_uid', RCUBE_INPUT_GET)) 
     65  $compose_mode = RCUBE_COMPOSE_DRAFT; 
     66 
     67 
     68if (!empty($msg_uid)) 
     69  { 
    6070  // similar as in program/steps/mail/show.inc 
    61   $MESSAGE = array(); 
    62   $MESSAGE['headers'] = $IMAP->get_headers($msg_uid); 
    63    
    64   $MESSAGE['source'] = rcmail_message_source($msg_uid); 
    65    
    66   $mmd = new Mail_mimeDecode($MESSAGE['source']); 
    67   $MESSAGE['structure'] = $mmd->decode(array('include_bodies' => TRUE, 
    68                                              'decode_headers' => TRUE, 
    69                                              'decode_bodies' => FALSE)); 
    70  
     71  $MESSAGE = array('UID' => $msg_uid); 
     72  $MESSAGE['headers'] = &$IMAP->get_headers($msg_uid); 
     73  $MESSAGE['structure'] = &$IMAP->get_structure($msg_uid);   
    7174  $MESSAGE['subject'] = $IMAP->decode_header($MESSAGE['headers']->subject); 
    72   $MESSAGE['parts'] = $mmd->getMimeNumbers($MESSAGE['structure']); 
    73  
    74   if ($_GET['_reply_uid']) 
    75     { 
    76     $REPLY_MESSAGE = &$MESSAGE; 
    77     $_SESSION['compose']['reply_uid'] = $_GET['_reply_uid']; 
    78     $_SESSION['compose']['reply_msgid'] = $REPLY_MESSAGE['headers']->messageID; 
    79     $_SESSION['compose']['references']  = $REPLY_MESSAGE['headers']->reference; 
    80     $_SESSION['compose']['references'] .= !empty($REPLY_MESSAGE['headers']->reference) ? ' ' : ''; 
    81     $_SESSION['compose']['references'] .= $REPLY_MESSAGE['headers']->messageID; 
    82  
    83     if ($_GET['_all']) 
    84       $REPLY_MESSAGE['reply_all'] = 1; 
    85  
    86     } 
    87   else if ($_GET['_forward_uid']) 
    88     { 
    89     $FORWARD_MESSAGE = $MESSAGE; 
    90     $_SESSION['compose']['forward_uid'] = $_GET['_forward_uid']; 
    91     } 
    92   else 
    93     { 
    94     $DRAFT_MESSAGE = $MESSAGE; 
    95     $_SESSION['compose']['draft_uid'] = $_GET['_draft_uid']; 
     75  $MESSAGE['parts'] = $IMAP->get_mime_numbers($MESSAGE['structure']); 
     76 
     77  if ($compose_mode == RCUBE_COMPOSE_REPLY) 
     78    { 
     79    $_SESSION['compose']['reply_uid'] = $msg_uid; 
     80    $_SESSION['compose']['reply_msgid'] = $MESSAGE['headers']->messageID; 
     81    $_SESSION['compose']['references']  = $MESSAGE['headers']->reference; 
     82    $_SESSION['compose']['references'] .= !empty($MESSAGE['headers']->reference) ? ' ' : ''; 
     83    $_SESSION['compose']['references'] .= $MESSAGE['headers']->messageID; 
     84 
     85    if (!empty($_GET['_all'])) 
     86      $MESSAGE['reply_all'] = 1; 
     87    } 
     88  else if ($compose_mode == RCUBE_COMPOSE_FORWARD) 
     89    { 
     90    $_SESSION['compose']['forward_uid'] = $msg_uid; 
     91    } 
     92  else if ($compose_mode == RCUBE_COMPOSE_DRAFT) 
     93    { 
     94    $_SESSION['compose']['draft_uid'] = $msg_uid; 
    9695    } 
    9796 
     
    103102function rcmail_compose_headers($attrib) 
    104103  { 
    105   global $IMAP, $REPLY_MESSAGE, $DRAFT_MESSAGE, $DB; 
     104  global $IMAP, $MESSAGE, $DB, $compose_mode; 
    106105  static $sa_recipients = array(); 
    107106 
     
    138137        } 
    139138      else if (!empty($_GET['_to'])) 
    140         $fvalue = $_GET['_to']; 
     139        $fvalue = get_input_value('_to', RCUBE_INPUT_GET); 
    141140         
    142141    case 'cc': 
     
    165164  if ($fname && !empty($_POST[$fname])) 
    166165    $fvalue = get_input_value($fname, RCUBE_INPUT_POST, TRUE); 
    167   else if ($header && is_object($REPLY_MESSAGE['headers'])) 
     166 
     167  else if ($header && $compose_mode == RCUBE_COMPOSE_REPLY) 
    168168    { 
    169169    // get recipent address(es) out of the message headers 
    170     if ($header=='to' && $REPLY_MESSAGE['headers']->replyto) 
    171       $fvalue = $IMAP->decode_header($REPLY_MESSAGE['headers']->replyto); 
    172  
    173     else if ($header=='to' && $REPLY_MESSAGE['headers']->from) 
    174       $fvalue = $IMAP->decode_header($REPLY_MESSAGE['headers']->from); 
     170    if ($header=='to' && !empty($MESSAGE['headers']->replyto)) 
     171      $fvalue = $IMAP->decode_header($MESSAGE['headers']->replyto); 
     172 
     173    else if ($header=='to' && !empty($MESSAGE['headers']->from)) 
     174      $fvalue = $IMAP->decode_header($MESSAGE['headers']->from); 
    175175 
    176176    // add recipent of original message if reply to all 
    177     else if ($header=='cc' && $REPLY_MESSAGE['reply_all']) 
     177    else if ($header=='cc' && !empty($MESSAGE['reply_all'])) 
    178178      { 
    179       if ($IMAP->decode_header($REPLY_MESSAGE['headers']->to)) 
    180         $fvalue .= $IMAP->decode_header($REPLY_MESSAGE['headers']->to); 
    181  
    182       if ($IMAP->decode_header($REPLY_MESSAGE['headers']->cc)) 
    183         { 
    184         if($fvalue) 
    185           $fvalue .= ', '; 
    186  
    187         $fvalue .= $IMAP->decode_header($REPLY_MESSAGE['headers']->cc); 
    188         } 
     179      if ($v = $IMAP->decode_header($MESSAGE['headers']->to)) 
     180        $fvalue .= $v; 
     181 
     182      if ($v = $IMAP->decode_header($MESSAGE['headers']->cc)) 
     183        $fvalue .= (!empty($fvalue) ? ', ' : '') . $v; 
    189184      } 
    190185 
     
    196191      foreach ($to_addresses as $addr_part) 
    197192        { 
    198         if (!in_array($addr_part['mailto'], $sa_recipients) && (!$REPLY_MESSAGE['FROM'] || !in_array($addr_part['mailto'], $REPLY_MESSAGE['FROM']))) 
     193        if (!in_array($addr_part['mailto'], $sa_recipients) && (!$MESSAGE['FROM'] || !in_array($addr_part['mailto'], $MESSAGE['FROM']))) 
    199194          { 
    200195          $fvalue .= (strlen($fvalue) ? ', ':'').$addr_part['string']; 
     
    204199      } 
    205200    } 
    206   else if ($header && is_object($DRAFT_MESSAGE['headers'])) 
     201  else if ($header && $compose_mode == RCUBE_COMPOSE_DRAFT) 
    207202    { 
    208203    // get drafted headers 
    209     if ($header=='to' && $DRAFT_MESSAGE['headers']->to) 
    210       $fvalue = $IMAP->decode_header($DRAFT_MESSAGE['headers']->to); 
    211  
    212     if ($header=='cc' && $DRAFT_MESSAGE['headers']->cc) 
    213       $fvalue = $IMAP->decode_header($DRAFT_MESSAGE['headers']->cc); 
    214  
    215     if ($header=='bcc' && $DRAFT_MESSAGE['headers']->bcc) 
    216       $fvalue = $IMAP->decode_header($DRAFT_MESSAGE['headers']->bcc); 
     204    if ($header=='to' && !empty($MESSAGE['headers']->to)) 
     205      $fvalue = $IMAP->decode_header($MESSAGE['headers']->to); 
     206 
     207    if ($header=='cc' && !empty($MESSAGE['headers']->cc)) 
     208      $fvalue = $IMAP->decode_header($MESSAGE['headers']->cc); 
     209 
     210    if ($header=='bcc' && !empty($MESSAGE['headers']->bcc)) 
     211      $fvalue = $IMAP->decode_header($MESSAGE['headers']->bcc); 
    217212 
    218213    } 
     
    242237function rcmail_compose_header_from($attrib) 
    243238  { 
    244   global $IMAP, $REPLY_MESSAGE, $DRAFT_MESSAGE, $DB, $OUTPUT, $JS_OBJECT_NAME; 
     239  global $IMAP, $MESSAGE, $DB, $OUTPUT, $JS_OBJECT_NAME, $compose_mode; 
    245240     
    246241  // pass the following attributes to the form class 
     
    252247  // extract all recipients of the reply-message 
    253248  $a_recipients = array(); 
    254   if ($REPLY_MESSAGE && is_object($REPLY_MESSAGE['headers'])) 
    255     { 
    256     $REPLY_MESSAGE['FROM'] = array(); 
    257  
    258     $a_to = $IMAP->decode_address_list($REPLY_MESSAGE['headers']->to);         
     249  if ($compose_mode == RCUBE_COMPOSE_REPLY && is_object($MESSAGE['headers'])) 
     250    { 
     251    $MESSAGE['FROM'] = array(); 
     252 
     253    $a_to = $IMAP->decode_address_list($MESSAGE['headers']->to);         
    259254    foreach ($a_to as $addr) 
    260255      { 
     
    263258      } 
    264259 
    265     if (!empty($REPLY_MESSAGE['headers']->cc)) 
     260    if (!empty($MESSAGE['headers']->cc)) 
    266261      { 
    267       $a_cc = $IMAP->decode_address_list($REPLY_MESSAGE['headers']->cc); 
     262      $a_cc = $IMAP->decode_address_list($MESSAGE['headers']->cc); 
    268263      foreach ($a_cc as $addr) 
    269264        { 
     
    302297        $from_id = $sql_arr['identity_id']; 
    303298         
    304       if ($REPLY_MESSAGE && is_array($REPLY_MESSAGE['FROM'])) 
    305         $REPLY_MESSAGE['FROM'][] = $sql_arr['email']; 
    306  
    307       if (strstr($DRAFT_MESSAGE['headers']->from,$sql_arr['email'])) 
     299      if ($compose_mode == RCUBE_COMPOSE_REPLY && is_array($MESSAGE['FROM'])) 
     300        $MESSAGE['FROM'][] = $sql_arr['email']; 
     301 
     302      if ($compose_mode == RCUBE_COMPOSE_DRAFT && strstr($MESSAGE['headers']->from, $sql_arr['email'])) 
    308303        $from_id = $sql_arr['identity_id']; 
    309304 
     
    312307    // overwrite identity selection with post parameter 
    313308    if (isset($_POST['_from'])) 
    314       $from_id = $_POST['_from']; 
     309      $from_id = get_input_value('_from', RCUBE_INPUT_POST); 
    315310 
    316311    $out = $select_from->show($from_id); 
     
    336331function rcmail_compose_body($attrib) 
    337332  { 
    338   global $CONFIG, $OUTPUT, $REPLY_MESSAGE, $FORWARD_MESSAGE, $DRAFT_MESSAGE, $JS_OBJECT_NAME; 
     333  global $CONFIG, $OUTPUT, $MESSAGE, $JS_OBJECT_NAME, $compose_mode; 
    339334   
    340335  list($form_start, $form_end) = get_form_tags($attrib); 
     
    354349     
    355350  // compose reply-body 
    356   else if (is_array($REPLY_MESSAGE['parts'])) 
    357     { 
    358     $body = rcmail_first_text_part($REPLY_MESSAGE['parts']); 
     351  else if ($compose_mode == RCUBE_COMPOSE_REPLY) 
     352    { 
     353    $body = rcmail_first_text_part($MESSAGE); 
    359354    if (strlen($body)) 
    360355      $body = rcmail_create_reply_body($body); 
     
    362357 
    363358  // forward message body inline 
    364   else if (is_array($FORWARD_MESSAGE['parts'])) 
    365     { 
    366     $body = rcmail_first_text_part($FORWARD_MESSAGE['parts']); 
     359  else if ($compose_mode == RCUBE_COMPOSE_FORWARD) 
     360    { 
     361    $body = rcmail_first_text_part($MESSAGE); 
    367362    if (strlen($body)) 
    368363      $body = rcmail_create_forward_body($body); 
     
    370365 
    371366  // forward message body inline 
    372   else if (is_array($DRAFT_MESSAGE['parts'])) 
    373     { 
    374     $body = rcmail_first_text_part($DRAFT_MESSAGE['parts']); 
     367  else if ($compose_mode == RCUBE_COMPOSE_DRAFT) 
     368    { 
     369    $body = rcmail_first_text_part($MESSAGE); 
    375370    if (strlen($body)) 
    376371      $body = rcmail_create_draft_body($body); 
     
    379374  $out = $form_start ? "$form_start\n" : ''; 
    380375 
    381   $saveid = new hiddenfield(array('name' => '_draft_saveid', 'value' => str_replace(array('<','>'),"",$DRAFT_MESSAGE['headers']->messageID) )); 
     376  $saveid = new hiddenfield(array('name' => '_draft_saveid', 'value' => str_replace(array('<','>'),"",$MESSAGE['headers']->messageID) )); 
    382377  $out .= $saveid->show(); 
    383378 
     
    420415function rcmail_create_reply_body($body) 
    421416  { 
    422   global $IMAP, $REPLY_MESSAGE; 
     417  global $IMAP, $MESSAGE; 
    423418 
    424419  // soft-wrap message first 
     
    441436  // add title line 
    442437  $pefix = sprintf("\n\n\nOn %s, %s wrote:\n", 
    443            $REPLY_MESSAGE['headers']->date, 
    444            $IMAP->decode_header($REPLY_MESSAGE['headers']->from)); 
     438           $MESSAGE['headers']->date, 
     439           $IMAP->decode_header($MESSAGE['headers']->from)); 
    445440            
    446441 
     
    458453function rcmail_create_forward_body($body) 
    459454  { 
    460   global $IMAP, $FORWARD_MESSAGE; 
     455  global $IMAP, $MESSAGE; 
    461456 
    462457  // soft-wrap message first 
     
    464459   
    465460  $prefix = sprintf("\n\n\n-------- Original Message --------\nSubject: %s\nDate: %s\nFrom: %s\nTo: %s\n\n", 
    466                    $FORWARD_MESSAGE['subject'], 
    467                    $FORWARD_MESSAGE['headers']->date, 
    468                    $IMAP->decode_header($FORWARD_MESSAGE['headers']->from), 
    469                    $IMAP->decode_header($FORWARD_MESSAGE['headers']->to)); 
    470  
     461                   $MESSAGE['subject'], 
     462                   $MESSAGE['headers']->date, 
     463                   $IMAP->decode_header($MESSAGE['headers']->from), 
     464                   $IMAP->decode_header($MESSAGE['headers']->to)); 
     465                    
    471466  // add attachments 
    472   if (!isset($_SESSION['compose']['forward_attachments']) && is_array($FORWARD_MESSAGE['parts']) && sizeof($FORWARD_MESSAGE['parts'])>1) 
    473     { 
    474     $temp_dir = rcmail_create_compose_tempdir(); 
    475  
    476     if (!is_array($_SESSION['compose']['attachments'])) 
    477       $_SESSION['compose']['attachments'] = array(); 
    478    
    479     foreach ($FORWARD_MESSAGE['parts'] as $part) 
     467  if (!isset($_SESSION['compose']['forward_attachments']) && 
     468      is_array($MESSAGE['parts']) && sizeof($MESSAGE['parts'])>1) 
     469    rcmail_write_compose_attachments($MESSAGE); 
     470 
     471  return $prefix.$body; 
     472  } 
     473 
     474 
     475function rcmail_create_draft_body($body) 
     476  { 
     477  global $IMAP, $MESSAGE; 
     478     
     479  // add attachments 
     480  if (!isset($_SESSION['compose']['forward_attachments']) && 
     481      is_array($MESSAGE['parts']) && sizeof($MESSAGE['parts'])>1) 
     482    rcmail_write_compose_attachments($MESSAGE); 
     483 
     484  return $body; 
     485  } 
     486   
     487   
     488function rcmail_write_compose_attachments(&$message) 
     489  { 
     490  global $IMAP; 
     491     
     492  $temp_dir = rcmail_create_compose_tempdir(); 
     493 
     494  if (!is_array($_SESSION['compose']['attachments'])) 
     495    $_SESSION['compose']['attachments'] = array(); 
     496   
     497  foreach ($message['parts'] as $pid => $part) 
     498    { 
     499    if ($part->ctype_primary != 'message' && $part->ctype_primary != 'text' && 
     500        ($part->disposition=='attachment' || $part->disposition=='inline' || $part->headers['content-id'] || 
     501         (empty($part->disposition) && ($part->d_parameters['filename'] || $part->ctype_parameters['name'])))) 
    480502      { 
    481       if ($part->disposition=='attachment' || $part->disposition=='inline' || $part->headers['content-id'] || 
    482                (empty($part->disposition) && ($part->d_parameters['filename'] || $part->ctype_parameters['name']))) 
     503      $tmp_path = tempnam($temp_dir, 'rcmAttmnt'); 
     504      if ($fp = fopen($tmp_path, 'w')) 
    483505        { 
    484         $tmp_path = tempnam($temp_dir, 'rcmAttmnt'); 
    485         if ($fp = fopen($tmp_path, 'w')) 
    486           { 
    487           fwrite($fp, $IMAP->mime_decode($part->body, $part->headers['content-transfer-encoding'])); 
    488           fclose($fp); 
    489  
    490           if ($part->d_parameters['filename']) 
    491             $_SESSION['compose']['attachments'][] = array('name' => $part->d_parameters['filename'], 
    492                                                           'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, 
    493                                                           'path' => $tmp_path); 
    494                                     
    495           else if ($part->ctype_parameters['name']) 
    496             $_SESSION['compose']['attachments'][] = array('name' => $part->ctype_parameters['name'], 
    497                                                           'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, 
    498                                                           'path' => $tmp_path); 
    499                                                            
    500           else if ($part->headers['content-description']) 
    501             $_SESSION['compose']['attachments'][] = array('name' => $part->headers['content-description'], 
    502                                                           'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, 
    503                                                           'path' => $tmp_path); 
    504           } 
    505         } 
    506       } 
    507  
    508     $_SESSION['compose']['forward_attachments'] = TRUE; 
    509     } 
    510  
    511   return $prefix.$body; 
    512   } 
    513  
    514 function rcmail_create_draft_body($body) 
    515   { 
    516   global $IMAP, $DRAFT_MESSAGE; 
    517      
    518   // add attachments 
    519   if (!isset($_SESSION['compose']['forward_attachments']) && is_array($DRAFT_MESSAGE['parts']) && sizeof($DRAFT_MESSAGE['parts'])>1) 
    520     {  
    521     $temp_dir = rcmail_create_compose_tempdir(); 
    522  
    523     if (!is_array($_SESSION['compose']['attachments'])) 
    524       $_SESSION['compose']['attachments'] = array(); 
    525    
    526     foreach ($DRAFT_MESSAGE['parts'] as $part) 
    527       { 
    528       if ($part->disposition=='attachment' || $part->disposition=='inline' || $part->headers['content-id'] || 
    529                (empty($part->disposition) && ($part->d_parameters['filename'] || $part->ctype_parameters['name']))) 
    530         { 
    531         $tmp_path = tempnam($temp_dir, 'rcmAttmnt'); 
    532         if ($fp = fopen($tmp_path, 'w')) 
    533           {                      
    534           fwrite($fp, $IMAP->mime_decode($part->body, $part->headers['content-transfer-encoding'])); 
    535           fclose($fp);           
    536                                  
    537           if ($part->d_parameters['filename']) 
    538             $_SESSION['compose']['attachments'][] = array('name' => $part->d_parameters['filename'], 
    539                                                           'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, 
    540                                                           'path' => $tmp_path); 
    541  
    542           else if ($part->ctype_parameters['name']) 
    543             $_SESSION['compose']['attachments'][] = array('name' => $part->ctype_parameters['name'], 
    544                                                           'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, 
    545                                                           'path' => $tmp_path); 
    546  
    547           else if ($part->headers['content-description']) 
    548             $_SESSION['compose']['attachments'][] = array('name' => $part->headers['content-description'], 
    549                                                           'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, 
    550                                                           'path' => $tmp_path); 
    551           } 
     506        fwrite($fp, $IMAP->get_message_part($message['UID'], $pid, $part->encoding)); 
     507        fclose($fp); 
     508         
     509        $filename = !empty($part->d_parameters['filename']) ? $part->d_parameters['filename'] : 
     510                     (!empty($part->ctype_parameters['name']) ? $part->ctype_parameters['name'] : 
     511                      (!empty($part->headers['content-description']) ? $part->headers['content-description'] : 'file')); 
     512 
     513        $_SESSION['compose']['attachments'][] = array( 
     514          'name' => rcube_imap::decode_mime_string($filename), 
     515          'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, 
     516          'path' => $tmp_path 
     517          ); 
    552518        } 
    553519      } 
    554  
    555     $_SESSION['compose']['forward_attachments'] = TRUE; 
    556     } 
    557  
    558   return $body; 
     520    } 
     521         
     522  $_SESSION['compose']['forward_attachments'] = TRUE; 
    559523  } 
    560524 
     
    562526function rcmail_compose_subject($attrib) 
    563527  { 
    564   global $CONFIG, $REPLY_MESSAGE, $FORWARD_MESSAGE, $DRAFT_MESSAGE; 
     528  global $CONFIG, $MESSAGE, $compose_mode; 
    565529   
    566530  list($form_start, $form_end) = get_form_tags($attrib); 
     
    577541     
    578542  // create a reply-subject 
    579   else if (isset($REPLY_MESSAGE['subject'])) 
    580     { 
    581     if (eregi('^re:', $REPLY_MESSAGE['subject'])) 
    582       $subject = $REPLY_MESSAGE['subject']; 
     543  else if ($compose_mode == RCUBE_COMPOSE_REPLY) 
     544    { 
     545    if (eregi('^re:', $MESSAGE['subject'])) 
     546      $subject = $MESSAGE['subject']; 
    583547    else 
    584       $subject = 'Re: '.$REPLY_MESSAGE['subject']; 
     548      $subject = 'Re: '.$MESSAGE['subject']; 
    585549    } 
    586550 
    587551  // create a forward-subject 
    588   else if (isset($FORWARD_MESSAGE['subject'])) 
    589     { 
    590     if (eregi('^fwd:', $REPLY_MESSAGE['subject'])) 
    591       $subject = $FORWARD_MESSAGE['subject']; 
     552  else if ($compose_mode == RCUBE_COMPOSE_FORWARD) 
     553    { 
     554    if (eregi('^fwd:', $MESSAGE['subject'])) 
     555      $subject = $MESSAGE['subject']; 
    592556    else 
    593       $subject = 'Fwd: '.$FORWARD_MESSAGE['subject']; 
     557      $subject = 'Fwd: '.$MESSAGE['subject']; 
    594558    } 
    595559 
    596560  // creeate a draft-subject 
    597   else if (isset($DRAFT_MESSAGE['subject'])) 
    598     $subject = $DRAFT_MESSAGE['subject']; 
     561  else if ($compose_mode == RCUBE_COMPOSE_DRAFT) 
     562    $subject = $MESSAGE['subject']; 
    599563   
    600564  $out = $form_start ? "$form_start\n" : ''; 
Note: See TracChangeset for help on using the changeset viewer.