X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fcompose.php;h=a5f1211c87b4ed30abd3cd5165e82a4d619b0779;hb=9ad07d9a69c04bc547a2ace06b6893ec9ead8cbe;hp=1a44f25bb9c2ff52a9e43a191ee428bc83724a13;hpb=856e58ef5660063838b0ad5e457dcfeea195f8a2;p=squirrelmail.git
diff --git a/src/compose.php b/src/compose.php
index 1a44f25b..a5f1211c 100644
--- a/src/compose.php
+++ b/src/compose.php
@@ -16,11 +16,21 @@
* @package squirrelmail
*/
+/** This is the compose page */
+define('PAGE_NAME', 'compose');
+
/**
* Include the SquirrelMail initialization file.
*/
require('../include/init.php');
+/* If email_address not set and admin wants us to ask user for it,
+ * redirect to options page. */
+if ( $ask_user_info && getPref($data_dir, $username,'email_address') == "" ) {
+ header("Location: " . get_location() . "/options.php?optpage=personal");
+ exit;
+}
+
/* SquirrelMail required files. */
require_once(SM_PATH . 'functions/imap_general.php');
require_once(SM_PATH . 'functions/imap_messages.php');
@@ -37,9 +47,14 @@ require_once(SM_PATH . 'functions/identity.php');
/** SESSION VARS */
sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
+sqgetGlobalVar('delayed_errors', $delayed_errors, SQ_SESSION);
sqgetGlobalVar('composesession', $composesession, SQ_SESSION);
sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION);
-sqgetGlobalVar('delayed_errors', $delayed_errors, SQ_SESSION);
+
+// compose_messages only useful in SESSION when a forward-as-attachment
+// has been preconstructed for us and passed in via that mechanism; once
+// we have it, we can clear it from the SESSION
+sqsession_unregister('compose_messages');
// Turn on delayed error handling in case we wind up redirecting below
$oErrorHandler->setDelayedErrors(true);
@@ -96,13 +111,12 @@ sqgetGlobalVar('addr_search_cancel', $html_addr_search_cancel, SQ_POST);
sqgetGlobalVar('send_to_search', $send_to_search, SQ_POST);
sqgetGlobalVar('do_delete', $do_delete, SQ_POST);
sqgetGlobalVar('delete', $delete, SQ_POST);
-sqgetGlobalVar('restoremessages', $restoremessages, SQ_POST);
+sqgetGlobalVar('attachments', $attachments, SQ_POST);
if ( sqgetGlobalVar('return', $temp, SQ_POST) ) {
$html_addr_search_done = 'Use Addresses';
}
/** GET VARS */
-sqgetGlobalVar('attachedmessages', $attachedmessages, SQ_GET);
if ( sqgetGlobalVar('account', $temp, SQ_GET) ) {
$iAccount = (int) $temp;
} else {
@@ -308,23 +322,22 @@ function getforwardHeader($orig_header) {
* If the session is expired during a post this restores the compose session
* vars.
*/
+$session_expired = false;
if (sqsession_is_registered('session_expired_post')) {
sqgetGlobalVar('session_expired_post', $session_expired_post, SQ_SESSION);
/*
* extra check for username so we don't display previous post data from
* another user during this session.
*/
- if ($session_expired_post['username'] != $username) {
- unset($session_expired_post);
- sqsession_unregister('session_expired_post');
- session_write_close();
- } else {
+ if (!empty($session_expired_post['username'])
+ && $session_expired_post['username'] == $username) {
// these are the vars that we can set from the expired composed session
- $compo_var_list = array ( 'send_to', 'send_to_cc','body','startMessage',
- 'passed_body','use_signature','signature','attachments','subject','newmail',
- 'send_to_bcc', 'passed_id', 'mailbox', 'from_htmladdr_search', 'identity',
- 'draft_id', 'delete_draft', 'mailprio', 'edit_as_new', 'compose_messsages',
- 'composesession', 'request_mdn', 'request_dr');
+ $compo_var_list = array ('send_to', 'send_to_cc', 'body',
+ 'startMessage', 'passed_body', 'use_signature', 'signature',
+ 'subject', 'newmail', 'send_to_bcc', 'passed_id', 'mailbox',
+ 'from_htmladdr_search', 'identity', 'draft_id', 'delete_draft',
+ 'mailprio', 'edit_as_new', 'attachments', 'composesession',
+ 'request_mdn', 'request_dr');
foreach ($compo_var_list as $var) {
if ( isset($session_expired_post[$var]) && !isset($$var) ) {
@@ -332,9 +345,11 @@ if (sqsession_is_registered('session_expired_post')) {
}
}
- $compose_messages = unserialize($restoremessages);
- sqsession_register($compose_messages,'compose_messages');
+ if (!empty($attachments))
+ $attachments = unserialize(urldecode($attachments));
+
sqsession_register($composesession,'composesession');
+
if (isset($send)) {
unset($send);
}
@@ -360,6 +375,7 @@ if (sqsession_is_registered('session_expired_post')) {
showInputForm($session, false);
exit();
}
+
if (!isset($composesession)) {
$composesession = 0;
sqsession_register(0,'composesession');
@@ -383,12 +399,19 @@ if (!isset($compose_messages[$session]) || ($compose_messages[$session] == NULL)
$composeMessage->rfc822_header = $rfc822_header;
$composeMessage->reply_rfc822_header = '';
$compose_messages[$session] = $composeMessage;
-
- sqsession_register($compose_messages,'compose_messages');
} else {
$composeMessage=$compose_messages[$session];
}
+// re-add attachments that were already in this message
+// FIXME: note that technically this is very bad form -
+// should never directly manipulate an object like this
+if (!empty($attachments)) {
+ $attachments = unserialize(urldecode($attachments));
+ if (!empty($attachments) && is_array($attachments))
+ $composeMessage->entities = $attachments;
+}
+
if (empty($mailbox)) {
$mailbox = 'INBOX';
}
@@ -399,12 +422,11 @@ if ($draft) {
* of language interface.
*/
set_my_charset();
- $composeMessage=$compose_messages[$session];
+ $composeMessage = $compose_messages[$session];
if (! deliverMessage($composeMessage, true)) {
showInputForm($session);
exit();
} else {
- unset($compose_messages[$session]);
$draft_message = _("Draft Email Saved");
/* If this is a resumed draft, then delete the original */
if(isset($delete_draft)) {
@@ -427,6 +449,7 @@ if ($draft) {
if ( !isset($pageheader_sent) || !$pageheader_sent ) {
Header("Location: $location/compose.php?saved_draft=yes&session=$composesession");
} else {
+//FIXME: DON'T ECHO HTML FROM CORE!
echo '