Ignore:
Timestamp:
Mar 10, 2011 3:21:21 PM (2 years ago)
Author:
thomasb
Message:

Prepare for multiple concurrent compose windows

File:
1 edited

Legend:

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

    r4542 r4604  
    2929$MESSAGE = NULL; 
    3030 
     31$COMPOSE_ID = get_input_value('_id', RCUBE_INPUT_GET); 
     32$_SESSION['compose'] = $_SESSION['compose_data'][$COMPOSE_ID]; 
     33 
    3134// Nothing below is called during message composition, only at "new/forward/reply/draft" initialization or 
    3235// if a compose-ID is given (i.e. when the compose step is opened in a new window/tab). 
    33 // Since there are many ways to leave the compose page improperly, it seems necessary to clean-up an old 
    34 // compose when a "new/forward/reply/draft" is called - otherwise the old session attachments will appear 
    35  
    36 $MESSAGE_ID = get_input_value('_id', RCUBE_INPUT_GET); 
    37 if (!is_array($_SESSION['compose']) || $_SESSION['compose']['id'] != $MESSAGE_ID) 
    38 { 
    39   rcmail_compose_cleanup(); 
    40  
     36if (!is_array($_SESSION['compose'])) 
     37{ 
    4138  // Infinite redirect prevention in case of broken session (#1487028) 
    42   if ($MESSAGE_ID) 
     39  if ($COMPOSE_ID) 
    4340    raise_error(array('code' => 500, 'type' => 'php', 
    4441      'file' => __FILE__, 'line' => __LINE__, 
     
    8279        $filename = basename($attach); 
    8380        $attachment = array( 
     81          'group' => $COMPOSE_ID, 
    8482          'name' => $filename, 
    8583          'mimetype' => rc_mime_content_type($attach, $filename), 
    86           'path' => $attach 
     84          'path' => $attach, 
    8785        ); 
    8886      } 
     
    116114    'autocompletechars'); 
    117115 
     116$OUTPUT->set_env('compose_id', $COMPOSE_ID); 
     117 
    118118// add config parameters to client script 
    119119if (!empty($CONFIG['drafts_mbox'])) { 
     
    128128 
    129129// get reference message and set compose mode 
    130 if ($msg_uid = $_SESSION['compose']['param']['reply_uid']) 
     130if ($msg_uid = $_SESSION['compose']['param']['draft_uid']) { 
     131  $RCMAIL->imap->set_mailbox($CONFIG['drafts_mbox']); 
     132  $compose_mode = RCUBE_COMPOSE_DRAFT; 
     133} 
     134else if ($msg_uid = $_SESSION['compose']['param']['reply_uid']) 
    131135  $compose_mode = RCUBE_COMPOSE_REPLY; 
    132136else if ($msg_uid = $_SESSION['compose']['param']['forward_uid']) 
     
    134138else if ($msg_uid = $_SESSION['compose']['param']['uid']) 
    135139  $compose_mode = RCUBE_COMPOSE_EDIT; 
    136 else if ($msg_uid = $_SESSION['compose']['param']['draft_uid']) { 
    137   $RCMAIL->imap->set_mailbox($CONFIG['drafts_mbox']); 
    138   $compose_mode = RCUBE_COMPOSE_DRAFT; 
    139 } 
    140140 
    141141$config_show_sig = $RCMAIL->config->get('show_sig', 1); 
     
    621621      $_SESSION['compose']['attachments'][$attachment['id']] = $attachment; 
    622622      $body = preg_replace('#\./program/blocked\.gif#', 
    623         $RCMAIL->comm_path.'&_action=display-attachment&_file=rcmfile'.$attachment['id'], 
     623        $RCMAIL->comm_path.'&_action=display-attachment&_file=rcmfile'.$attachment['id'].'&_id='.$_SESSION['compose']['id'], 
    624624        $body); 
    625625    } 
     
    922922        $_SESSION['compose']['attachments'][$attachment['id']] = $attachment; 
    923923        if ($bodyIsHtml && ($part->content_id || $part->content_location)) { 
    924           $url = $RCMAIL->comm_path.'&_action=display-attachment&_file=rcmfile'.$attachment['id']; 
     924          $url = $RCMAIL->comm_path.'&_action=display-attachment&_file=rcmfile'.$attachment['id'].'&_id='.$_SESSION['compose']['id']; 
    925925          if ($part->content_id) 
    926926            $cid_map['cid:'.$part->content_id] = $url; 
     
    947947      if ($attachment = rcmail_save_attachment($message, $pid)) { 
    948948        $_SESSION['compose']['attachments'][$attachment['id']] = $attachment; 
    949         $url = $RCMAIL->comm_path.'&_action=display-attachment&_file=rcmfile'.$attachment['id']; 
     949        $url = $RCMAIL->comm_path.'&_action=display-attachment&_file=rcmfile'.$attachment['id'].'&_id='.$_SESSION['compose']['id']; 
    950950        if ($part->content_id) 
    951951          $cid_map['cid:'.$part->content_id] = $url; 
     
    981981 
    982982  $attachment = array( 
     983    'group' => $_SESSION['compose']['id'], 
    983984    'name' => $part->filename ? $part->filename : 'Part_'.$pid.'.'.$part->ctype_secondary, 
    984985    'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, 
     
    10071008 
    10081009  $attachment = array( 
     1010    'group' => $_SESSION['compose']['id'], 
    10091011    'name' => rcmail_basename($path), 
    10101012    'mimetype' => $mimetype ? $mimetype : rc_mime_content_type($path, $name), 
     
    13241326    $hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $RCMAIL->task)); 
    13251327    $hiddenfields->add(array('name' => '_action', 'value' => 'send')); 
     1328    $hiddenfields->add(array('name' => '_id', 'value' => $_SESSION['compose']['id'])); 
    13261329 
    13271330    $form_start = empty($attrib['form']) ? $RCMAIL->output->form_tag(array('name' => "form", 'method' => "post")) : ''; 
Note: See TracChangeset for help on using the changeset viewer.