summaryrefslogtreecommitdiff
path: root/program/steps
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps')
-rw-r--r--program/steps/mail/compose.inc39
-rw-r--r--program/steps/mail/sendmail.inc44
-rw-r--r--program/steps/mail/upload.inc1
3 files changed, 48 insertions, 36 deletions
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 7e6d306bd..877948c53 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -22,16 +22,6 @@
require_once('Mail/mimeDecode.php');
-
-$MESSAGE_FORM = NULL;
-$REPLY_MESSAGE = NULL;
-$FORWARD_MESSAGE = NULL;
-$DRAFT_MESSAGE = NULL;
-
-
-if (!is_array($_SESSION['compose']))
- $_SESSION['compose'] = array('id' => uniqid(rand()));
-
// remove an attachment
if ($_action=='remove-attachment' && !empty($_GET['_filename']))
{
@@ -47,6 +37,18 @@ if ($_action=='remove-attachment' && !empty($_GET['_filename']))
}
}
+$MESSAGE_FORM = NULL;
+$REPLY_MESSAGE = NULL;
+$FORWARD_MESSAGE = NULL;
+$DRAFT_MESSAGE = NULL;
+
+// nothing below is called during message composition, only at "new/forward/reply/draft" initialization
+// since there are many ways to leave the compose page improperly, it seems necessary to clean-up an old
+// compose when a "new/forward/reply/draft" is called - otherwise the old session attachments will appear
+
+rcmail_compose_cleanup();
+$_SESSION['compose'] = array('id' => uniqid(rand()));
+
// add some labels to client
rcube_add_label('nosubject', 'norecipientwarning', 'nosubjectwarning', 'nobodywarning', 'notsentwarning', 'savingmessage', 'savingmessage', 'messagesaved');
@@ -376,18 +378,9 @@ function rcmail_compose_body($attrib)
$out = $form_start ? "$form_start\n" : '';
- // Check if a previous save was done so we can delete it upon the next save
- if (!empty($_POST['_draft_newsaveid']))
- $saveid = new hiddenfield(array('name' => '_draft_saveid', 'value' => $_POST['_draft_newsaveid']));
- else if (strlen($DRAFT_MESSAGE['headers']->messageID) > 6)
- $saveid = new hiddenfield(array('name' => '_draft_saveid', 'value' => str_replace(array('<','>'),"",$DRAFT_MESSAGE['headers']->messageID) ));
+ $saveid = new hiddenfield(array('name' => '_draft_saveid', 'value' => str_replace(array('<','>'),"",$DRAFT_MESSAGE['headers']->messageID) ));
+ $out .= $saveid->show();
- if ($saveid)
- $out .= $saveid->show();
-
- $newsaveid = new hiddenfield(array('name' => '_draft_newsaveid', 'value' => sprintf('%s@%s', md5(uniqid('rcmail'.rand(),true)), $_SESSION['imap_host']) ));
- $out .= $newsaveid->show();
-
$drafttoggle = new hiddenfield(array('name' => '_draft', 'value' => 'yes'));
$out .= $drafttoggle->show();
@@ -417,7 +410,9 @@ function rcmail_compose_body($attrib)
rcube_add_label('checking');
}
-
+
+ $out .= '<iframe name="savetarget" src="program/blank.gif" style="width:0;height:0;visibility:hidden;"></iframe>';
+
return $out;
}
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 33c1a405e..d0e0f784e 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -65,12 +65,10 @@ function rcmail_get_identity($id)
if (strlen($_POST['_draft_saveid']) > 3)
$olddraftmessageid = get_input_value('_draft_saveid', RCUBE_INPUT_POST);
-if (strlen($_POST['_draft_newsaveid']) > 3)
- $newdraftmessageid = get_input_value('_draft_newsaveid', RCUBE_INPUT_POST);
+$message_id = sprintf('<%s@%s>', md5(uniqid('rcmail'.rand(),true)), $_SESSION['imap_host']);
$savedraft = !empty($_POST['_draft']) ? TRUE : FALSE;
-
/****** check submission and compose message ********/
@@ -96,21 +94,12 @@ $mailto = preg_replace($mailto_regexp, $mailto_replace, get_input_value('_to', R
$to_address_arr = $IMAP->decode_address_list($mailto);
$identity_arr = rcmail_get_identity(get_input_value('_from', RCUBE_INPUT_POST));
-
$from = $identity_arr['mailto'];
$first_to = is_array($to_address_arr[0]) ? $to_address_arr[0]['mailto'] : $mailto;
-
-// try the message-id submitted by the compose form
-if ($newdraftmessageid)
- $message_id = sprintf('<%s>',$newdraftmessageid);
-else
- $message_id = sprintf('<%s@%s>', md5(uniqid('rcmail'.rand(),true)), $_SESSION['imap_host']);
-
if (empty($identity_arr['string']))
$identity_arr['string'] = $from;
-
// compose headers array
$headers = array('Date' => date('D, j M Y G:i:s O'),
'From' => $identity_arr['string'],
@@ -321,10 +310,19 @@ if ($CONFIG[$store_target])
// raise error if saving failed
if (!$saved)
+ {
+ // clear the "saving message" busy status, and display failure
+ $errorout = sprintf("parent.%s.display_message('%s', '%s');",
+ $JS_OBJECT_NAME,
+ addslashes(rep_specialchars_output(rcube_label(array('name' => 'errorsaving', 'vars' => NULL)))),
+ 'error');
+ print "<html><script type=\"text/javascript\">$errorout</script></html>";
raise_error(array('code' => 800,
'type' => 'imap',
'file' => __FILE__,
'message' => "Could not save message in $CONFIG[$store_target]"), TRUE, FALSE);
+ exit;
+ }
if ($olddraftmessageid)
{
@@ -332,6 +330,7 @@ if ($CONFIG[$store_target])
$a_deleteid = $IMAP->search($CONFIG['drafts_mbox'],'HEADER Message-ID',$olddraftmessageid);
$deleted = $IMAP->delete_message($IMAP->get_uid($a_deleteid[0],$CONFIG['drafts_mbox']),$CONFIG['drafts_mbox']);
+ // raise error if deletion of old draft failed
if (!$deleted)
raise_error(array('code' => 800,
'type' => 'imap',
@@ -342,8 +341,25 @@ if ($CONFIG[$store_target])
if ($savedraft)
{
- show_message('messagesaved', 'confirmation');
- rcmail_overwrite_action('compose');
+ // clear the "saving message" busy status, and display success
+ $frameout = sprintf("parent.%s.display_message('%s', '%s');",
+ $JS_OBJECT_NAME,
+ addslashes(rep_specialchars_output(rcube_label(array('name' => 'messagesaved', 'vars' => NULL)))),
+ 'confirmation');
+
+ // update "_draft_saveid" on the page, which is used to delete a previous draft
+ $frameout .= 'var foundid = parent.rcube_find_object("_draft_saveid",parent.document);';
+ $frameout .= sprintf('foundid.value = "%s";',str_replace(array('<','>'),"",$message_id));
+
+ // update the "cmp_hash" to prevent "Unsaved changes" warning
+ $frameout .= sprintf("parent.%s.cmp_hash = parent.%s.compose_field_hash();",$JS_OBJECT_NAME,$JS_OBJECT_NAME);
+
+ // start the auto-save timer again
+ $frameout .= sprintf("parent.%s.auto_save_start();",$JS_OBJECT_NAME);
+
+ // send html page with JS calls as response
+ print "<html><script type=\"text/javascript\">$frameout</script></html>";
+ exit;
}
else
{
diff --git a/program/steps/mail/upload.inc b/program/steps/mail/upload.inc
index 39164bb46..0af8eed46 100644
--- a/program/steps/mail/upload.inc
+++ b/program/steps/mail/upload.inc
@@ -60,6 +60,7 @@ if (parent.$JS_OBJECT_NAME)
{
$response
parent.$JS_OBJECT_NAME.show_attachment_form(false);
+parent.$JS_OBJECT_NAME.auto_save_start();
}
</script>
</html>