Changeset 4591de7 in github


Ignore:
Timestamp:
Mar 10, 2011 3:21:21 PM (2 years ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
3e63a0b8
Parents:
8381ec1
Message:

Prepare for multiple concurrent compose windows

Files:
10 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    r8381ec1 r4591de7  
    22=========================== 
    33 
     4- Allow multiple concurrent compose sessions 
    45- Force names of unique constraints in PostgreSQL DDL 
    56- Add code for prevention from IMAP connection hangs when server closes socket unexpectedly 
  • program/include/rcmail.php

    rae39c47 r4591de7  
    10791079 
    10801080    // before closing the database connection, write session data 
    1081     if ($_SERVER['REMOTE_ADDR']) 
     1081    if ($_SERVER['REMOTE_ADDR']) { 
     1082      $this->session->cleanup(); 
    10821083      session_write_close(); 
     1084    } 
    10831085 
    10841086    // write performance stats to logs/console 
  • program/include/rcube_session.php

    rc294eaa r4591de7  
    189189 
    190190    return true; 
     191  } 
     192 
     193 
     194  /** 
     195   * Cleanup session data before saving 
     196   */ 
     197  public function cleanup() 
     198  { 
     199    // current compose information is stored in $_SESSION['compose'], move it to $_SESSION['compose_data'] 
     200    if ($_SESSION['compose']) { 
     201      $_SESSION['compose_data'][$_SESSION['compose']['id']] = $_SESSION['compose']; 
     202      $this->remove('compose'); 
     203    } 
    191204  } 
    192205 
  • program/js/app.js

    rd7167e9 r4591de7  
    228228        } 
    229229        else if (this.env.action == 'compose') { 
    230           this.env.compose_commands = ['send-attachment', 'remove-attachment', 'send', 'toggle-editor']; 
     230          this.env.compose_commands = ['send-attachment', 'remove-attachment', 'send', 'cancel', 'toggle-editor']; 
    231231 
    232232          if (this.env.drafts_mailbox) 
     
    32713271  { 
    32723272    if (name && this.env.attachments[name]) 
    3273       this.http_post('remove-attachment', '_file='+urlencode(name)); 
     3273      this.http_post('remove-attachment', { _id:this.env.compose_id, _file:name }); 
    32743274 
    32753275    return true; 
     
    54095409 
    54105410    form.target = frame_name; 
    5411     form.action = this.url(action, { _uploadid:ts }); 
     5411    form.action = this.url(action, { _id:this.env.compose_id||'', _uploadid:ts }); 
    54125412    form.setAttribute('enctype', 'multipart/form-data'); 
    54135413    form.submit(); 
  • program/js/editor_images.js

    r01ffe03 r4591de7  
    88      var att = rc_client.env.attachments[id]; 
    99      if (att.complete && att.mimetype.indexOf('image/') == 0) 
    10         tinyMCEImageList.push([att.name, rc_client.env.comm_path+'&_action=display-attachment&_file='+id]); 
     10        tinyMCEImageList.push([att.name, rc_client.env.comm_path+'&_action=display-attachment&_file='+id+'&_id='+rc_client.env.compose_id]); 
    1111   } 
    1212}; 
  • program/steps/addressbook/save.inc

    rb8f14ce r4591de7  
    5858                'name' => $_FILES['_photo']['name'], 
    5959                'mimetype' => 'image/' . $imageprop['type'], 
     60                'group' => 'contact', 
    6061            )); 
    6162        } 
     
    157158     
    158159    // cleanup session data 
    159     $RCMAIL->plugins->exec_hook('attachments_cleanup', array()); 
     160    $RCMAIL->plugins->exec_hook('attachments_cleanup', array('group' => 'contact')); 
    160161    $RCMAIL->session->remove('contacts'); 
    161162} 
  • program/steps/mail/attachments.inc

    rf5e7b353 r4591de7  
    2020*/ 
    2121 
     22 
     23$COMPOSE_ID = get_input_value('_id', RCUBE_INPUT_GPC); 
     24$_SESSION['compose'] = $_SESSION['compose_data'][$COMPOSE_ID]; 
    2225 
    2326if (!$_SESSION['compose']) { 
     
    8588      'size' => $_FILES['_attachments']['size'][$i], 
    8689      'name' => $_FILES['_attachments']['name'][$i], 
    87       'mimetype' => rc_mime_content_type($filepath, $_FILES['_attachments']['name'][$i], $_FILES['_attachments']['type'][$i]) 
     90      'mimetype' => rc_mime_content_type($filepath, $_FILES['_attachments']['name'][$i], $_FILES['_attachments']['type'][$i]), 
     91      'group' => $COMPOSE_ID, 
    8892    ); 
    8993 
  • program/steps/mail/compose.inc

    rda142bb r4591de7  
    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")) : ''; 
  • program/steps/mail/func.inc

    r29c5422 r4591de7  
    14201420 * clear message composing settings 
    14211421 */ 
    1422 function rcmail_compose_cleanup() 
    1423 { 
    1424   if (!isset($_SESSION['compose'])) 
     1422function rcmail_compose_cleanup($id) 
     1423{ 
     1424  if (!isset($_SESSION['compose_data'][$id])) 
    14251425    return; 
    14261426 
    14271427  $rcmail = rcmail::get_instance(); 
    1428   $rcmail->plugins->exec_hook('attachments_cleanup', array()); 
    1429   $rcmail->session->remove('compose'); 
     1428  $rcmail->plugins->exec_hook('attachments_cleanup', array('group' => $id)); 
     1429  unset($_SESSION['compose_data'][$id]); 
    14301430} 
    14311431 
  • program/steps/mail/sendmail.inc

    re8d5bdc r4591de7  
    2626 
    2727$savedraft = !empty($_POST['_draft']) ? true : false; 
     28 
     29$COMPOSE_ID = get_input_value('_id', RCUBE_INPUT_GPC); 
     30$_SESSION['compose'] = $_SESSION['compose_data'][$COMPOSE_ID]; 
    2831 
    2932/****** checks ********/ 
     
    703706  // remember new draft-uid 
    704707  $draftuids = $IMAP->search_once($CONFIG['drafts_mbox'], 'HEADER Message-ID '.$msgid, true); 
    705   $_SESSION['compose']['param']['_draft_uid'] = $draftuids[0]; 
     708  $_SESSION['compose']['param']['draft_uid'] = $draftuids[0]; 
    706709 
    707710  // display success 
     
    719722else 
    720723  { 
    721   rcmail_compose_cleanup(); 
     724  rcmail_compose_cleanup($COMPOSE_ID); 
    722725 
    723726  if ($store_folder && !$saved) 
Note: See TracChangeset for help on using the changeset viewer.