Changeset f0f98fb in github


Ignore:
Timestamp:
Jul 24, 2006 2:41:27 PM (7 years ago)
Author:
svncommit <devs@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
24053e0
Parents:
d52676e
Message:

Improvements to Draft handling

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    rbaf1355 rf0f98fb  
    11CHANGELOG RoundCube Webmail 
    22--------------------------- 
     3 
     42006/07/24 (richs) 
     5---------- 
     6- Draft window no longer reloads. It saves to an iframe in the background instead (fixes bug #1483869) 
     7- Draft timer now part of program/js/app.js instead of skins/default/templates/compose.inc 
     8- Draft saving now properly returns an error when saving fails 
     9- Draft timer stops and resets properly when attachments are uploaded, or when saving manually 
     10- Old compose session/attachments are now cleaned up when a new/forward/reply/draft is made/opened 
     11 
    312 
    4132006/07/19 (thomasb) 
  • index.php

    rbac7d17 rf0f98fb  
    292292 
    293293  // kill compose entry from session 
    294   if (isset($_SESSION['compose'])) 
    295     rcmail_compose_cleanup(); 
     294//  if (isset($_SESSION['compose'])) 
     295//    rcmail_compose_cleanup(); 
    296296     
    297297  // make sure the message count is refreshed 
  • program/js/app.js

    rf07394f rf0f98fb  
    1818var SHIFT_KEY = 2; 
    1919var CONTROL_SHIFT_KEY = 3; 
     20var DRAFT_AUTOSAVE = 10; // Minutes 
    2021 
    2122var rcube_webmail_client; 
     23var rcube_save_timer; 
    2224 
    2325function rcube_webmail() 
     
    4042  this.message_time = 5000; 
    4143  this.request_timeout = 180000; 
    42   this.kepp_alive_interval = 60000; 
     44  this._interval = 60000; 
    4345  this.mbox_expression = new RegExp('[^0-9a-z\-_]', 'gi'); 
    4446  this.env.blank_img = 'skins/default/images/blank.gif'; 
     
    255257       
    256258    // start interval for keep-alive/recent_check signal 
    257     if (this.kepp_alive_interval && this.task=='mail' && this.gui_objects.messagelist) 
    258       this.kepp_alive_int = setInterval(this.ref+'.check_for_recent()', this.kepp_alive_interval); 
     259    if (this._interval && this.task=='mail' && this.gui_objects.messagelist) 
     260      this._int = setInterval(this.ref+'.check_for_recent()', this.keep_alive_interval); 
    259261    else if (this.task!='login') 
    260       this.kepp_alive_int = setInterval(this.ref+'.send_keep_alive()', this.kepp_alive_interval); 
     262      this._int = setInterval(this.ref+'.send_keep_alive()', this.keep_alive_interval); 
    261263    }; 
    262264 
     
    437439    // get summary of all field values 
    438440    this.cmp_hash = this.compose_field_hash(); 
    439     }; 
    440  
     441  
     442    // start the auto-save timer 
     443    this.auto_save_start(); 
     444     
     445    }; 
    441446 
    442447  this.init_address_input_events = function(obj) 
     
    914919 
    915920      case 'savedraft': 
     921        // Reset the auto-save timer 
     922        self.clearTimeout(rcube_save_timer); 
     923 
    916924        if (!this.gui_objects.messageform) 
    917925          break; 
    918          
     926 
    919927        // if saving Drafts is disabled in main.inc.php 
    920928        if (!this.env.drafts_mailbox) 
    921929          break; 
    922   
     930 
    923931        this.set_busy(true, 'savingmessage'); 
    924932        var form = this.gui_objects.messageform; 
     933        form.target = "savetarget"; 
    925934        form.submit(); 
    926935        break; 
     
    944953         
    945954      case 'send-attachment': 
     955        // Reset the auto-save timer 
     956        self.clearTimeout(rcube_save_timer); 
     957 
    946958        this.upload_file(props)       
    947959        break; 
     
    19531965    }; 
    19541966     
    1955      
     1967  this.auto_save_start = function() 
     1968    { 
     1969    rcube_save_timer = self.setTimeout('rcmail.command("savedraft","",this)',DRAFT_AUTOSAVE * 60000); 
     1970    } 
     1971  
    19561972  this.compose_field_hash = function() 
    19571973    { 
     
    20532069  this.upload_file = function(form) 
    20542070    { 
     2071     
    20552072    if (!form) 
    20562073      return false; 
     
    29532970  this.display_message = function(msg, type, hold) 
    29542971    { 
     2972    this.set_busy(false); 
    29552973    if (!this.loaded)  // save message in order to display after page loaded 
    29562974      { 
     
    29582976      return true; 
    29592977      } 
    2960      
     2978   
    29612979    if (!this.gui_objects.message) 
    29622980      return false; 
    2963        
     2981      
    29642982    if (this.message_timer) 
    29652983      clearTimeout(this.message_timer); 
     
    29722990    this.gui_objects.message.innerHTML = cont; 
    29732991    this.gui_objects.message.style.display = 'block'; 
    2974      
     2992  
    29752993    if (type!='loading') 
    29762994      this.gui_objects.message.onmousedown = function(){ this._rcube.hide_message(); return true; }; 
  • program/steps/mail/compose.inc

    r66e2bfa rf0f98fb  
    2323require_once('Mail/mimeDecode.php'); 
    2424 
    25  
    26 $MESSAGE_FORM = NULL; 
    27 $REPLY_MESSAGE = NULL; 
    28 $FORWARD_MESSAGE = NULL; 
    29 $DRAFT_MESSAGE = NULL; 
    30  
    31  
    32 if (!is_array($_SESSION['compose'])) 
    33   $_SESSION['compose'] = array('id' => uniqid(rand())); 
    34  
    3525// remove an attachment 
    3626if ($_action=='remove-attachment' && !empty($_GET['_filename'])) 
     
    4737        } 
    4838  } 
     39 
     40$MESSAGE_FORM = NULL; 
     41$REPLY_MESSAGE = NULL; 
     42$FORWARD_MESSAGE = NULL; 
     43$DRAFT_MESSAGE = NULL; 
     44 
     45// nothing below is called during message composition, only at "new/forward/reply/draft" initialization 
     46// since there are many ways to leave the compose page improperly, it seems necessary to clean-up an old 
     47// compose when a "new/forward/reply/draft" is called - otherwise the old session attachments will appear 
     48 
     49rcmail_compose_cleanup(); 
     50$_SESSION['compose'] = array('id' => uniqid(rand())); 
    4951 
    5052// add some labels to client 
     
    377379  $out = $form_start ? "$form_start\n" : ''; 
    378380 
    379   // Check if a previous save was done so we can delete it upon the next save 
    380   if (!empty($_POST['_draft_newsaveid'])) 
    381     $saveid = new hiddenfield(array('name' => '_draft_saveid', 'value' => $_POST['_draft_newsaveid'])); 
    382   else if (strlen($DRAFT_MESSAGE['headers']->messageID) > 6) 
    383     $saveid = new hiddenfield(array('name' => '_draft_saveid', 'value' => str_replace(array('<','>'),"",$DRAFT_MESSAGE['headers']->messageID) )); 
    384  
    385   if ($saveid)  
    386     $out .= $saveid->show(); 
    387  
    388   $newsaveid = new hiddenfield(array('name' => '_draft_newsaveid', 'value' => sprintf('%s@%s', md5(uniqid('rcmail'.rand(),true)), $_SESSION['imap_host']) )); 
    389   $out .= $newsaveid->show(); 
    390   
     381  $saveid = new hiddenfield(array('name' => '_draft_saveid', 'value' => str_replace(array('<','>'),"",$DRAFT_MESSAGE['headers']->messageID) )); 
     382  $out .= $saveid->show(); 
     383 
    391384  $drafttoggle = new hiddenfield(array('name' => '_draft', 'value' => 'yes')); 
    392385  $out .= $drafttoggle->show(); 
     
    418411    rcube_add_label('checking'); 
    419412    } 
    420    
     413  
     414  $out .= '<iframe name="savetarget" src="program/blank.gif" style="width:0;height:0;visibility:hidden;"></iframe>'; 
     415  
    421416  return $out; 
    422417  } 
  • program/steps/mail/sendmail.inc

    r5084427 rf0f98fb  
    6666  $olddraftmessageid = get_input_value('_draft_saveid', RCUBE_INPUT_POST); 
    6767 
    68 if (strlen($_POST['_draft_newsaveid']) > 3) 
    69   $newdraftmessageid = get_input_value('_draft_newsaveid', RCUBE_INPUT_POST); 
     68$message_id = sprintf('<%s@%s>', md5(uniqid('rcmail'.rand(),true)), $_SESSION['imap_host']); 
    7069 
    7170$savedraft = !empty($_POST['_draft']) ? TRUE : FALSE; 
    7271 
    73   
    7472/****** check submission and compose message ********/ 
    7573 
     
    9795$identity_arr = rcmail_get_identity(get_input_value('_from', RCUBE_INPUT_POST)); 
    9896 
    99  
    10097$from = $identity_arr['mailto']; 
    10198$first_to = is_array($to_address_arr[0]) ? $to_address_arr[0]['mailto'] : $mailto; 
    10299 
    103  
    104 // try the message-id submitted by the compose form 
    105 if ($newdraftmessageid) 
    106   $message_id = sprintf('<%s>',$newdraftmessageid); 
    107 else 
    108   $message_id = sprintf('<%s@%s>', md5(uniqid('rcmail'.rand(),true)), $_SESSION['imap_host']); 
    109    
    110100if (empty($identity_arr['string'])) 
    111101  $identity_arr['string'] = $from; 
    112  
    113102 
    114103// compose headers array 
     
    322311  // raise error if saving failed 
    323312  if (!$saved) 
     313    { 
     314    // clear the "saving message" busy status, and display failure 
     315    $errorout = sprintf("parent.%s.display_message('%s', '%s');", 
     316                       $JS_OBJECT_NAME, 
     317                       addslashes(rep_specialchars_output(rcube_label(array('name' => 'errorsaving', 'vars' => NULL)))), 
     318                       'error'); 
     319    print "<html><script type=\"text/javascript\">$errorout</script></html>"; 
    324320    raise_error(array('code' => 800, 
    325321                      'type' => 'imap', 
    326322                      'file' => __FILE__, 
    327323                      'message' => "Could not save message in $CONFIG[$store_target]"), TRUE, FALSE); 
     324    exit; 
     325    } 
    328326 
    329327  if ($olddraftmessageid) 
     
    333331    $deleted = $IMAP->delete_message($IMAP->get_uid($a_deleteid[0],$CONFIG['drafts_mbox']),$CONFIG['drafts_mbox']); 
    334332 
     333    // raise error if deletion of old draft failed 
    335334    if (!$deleted) 
    336335      raise_error(array('code' => 800, 
     
    343342if ($savedraft) 
    344343  { 
    345   show_message('messagesaved', 'confirmation'); 
    346   rcmail_overwrite_action('compose'); 
     344  // clear the "saving message" busy status, and display success 
     345  $frameout = sprintf("parent.%s.display_message('%s', '%s');", 
     346                     $JS_OBJECT_NAME, 
     347                     addslashes(rep_specialchars_output(rcube_label(array('name' => 'messagesaved', 'vars' => NULL)))), 
     348                     'confirmation'); 
     349 
     350  // update "_draft_saveid" on the page, which is used to delete a previous draft 
     351  $frameout .= 'var foundid = parent.rcube_find_object("_draft_saveid",parent.document);'; 
     352  $frameout .= sprintf('foundid.value = "%s";',str_replace(array('<','>'),"",$message_id)); 
     353 
     354  // update the "cmp_hash" to prevent "Unsaved changes" warning 
     355  $frameout .= sprintf("parent.%s.cmp_hash = parent.%s.compose_field_hash();",$JS_OBJECT_NAME,$JS_OBJECT_NAME); 
     356   
     357  // start the auto-save timer again 
     358  $frameout .= sprintf("parent.%s.auto_save_start();",$JS_OBJECT_NAME); 
     359 
     360  // send html page with JS calls as response 
     361  print "<html><script type=\"text/javascript\">$frameout</script></html>"; 
     362  exit; 
    347363  } 
    348364else 
  • program/steps/mail/upload.inc

    r5084427 rf0f98fb  
    6161$response 
    6262parent.$JS_OBJECT_NAME.show_attachment_form(false); 
     63parent.$JS_OBJECT_NAME.auto_save_start(); 
    6364} 
    6465</script> 
  • skins/default/templates/compose.html

    rd52676e rf0f98fb  
    2121  } 
    2222 
    23 function rcmail_auto_save() 
    24   { 
    25   rcmail.command('savedraft','',this); 
    26   self.setTimeout('rcmail_auto_save()',300000); 
    27   } 
    28 self.setTimeout('rcmail_auto_save()',300000); 
    29   
    3023//--> 
    3124</script> 
Note: See TracChangeset for help on using the changeset viewer.