X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=src%2Fcompose.php;h=059fd8f7b9b9278921d40fc231f3dd5b355a9975;hp=eab20f32332609b035e2502ff9230b22e1a85952;hb=61e96f7e0c720e3bdf7df5b42f991bf1e2ed8efd;hpb=a2b193bc8c1cefe3db9f4b38ce346f0527a0ec0e diff --git a/src/compose.php b/src/compose.php index eab20f32..059fd8f7 100644 --- a/src/compose.php +++ b/src/compose.php @@ -3,9 +3,6 @@ /** * compose.php * - * Copyright (c) 1999-2005 The SquirrelMail Project Team - * Licensed under the GNU GPL. For full terms see the file COPYING. - * * This code sends a mail. * * There are 4 modes of operation: @@ -14,24 +11,22 @@ * - Send mail * - Save As Draft * + * @copyright © 1999-2006 The SquirrelMail Project Team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id$ * @package squirrelmail */ /** - * Path for SquirrelMail required files. - * @ignore + * Include the SquirrelMail initialization file. */ -define('SM_PATH','../'); +require('../include/init.php'); /* SquirrelMail required files. */ -require_once(SM_PATH . 'include/validate.php'); -require_once(SM_PATH . 'functions/global.php'); -require_once(SM_PATH . 'functions/imap.php'); +require_once(SM_PATH . 'functions/imap_general.php'); +require_once(SM_PATH . 'functions/imap_messages.php'); require_once(SM_PATH . 'functions/date.php'); require_once(SM_PATH . 'functions/mime.php'); -require_once(SM_PATH . 'functions/plugin.php'); -require_once(SM_PATH . 'functions/display_messages.php'); require_once(SM_PATH . 'class/deliver/Deliver.class.php'); require_once(SM_PATH . 'functions/addressbook.php'); require_once(SM_PATH . 'functions/forms.php'); @@ -49,6 +44,11 @@ sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); sqgetGlobalVar('composesession', $composesession, SQ_SESSION); sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION); +sqgetGlobalVar('delayed_errors', $delayed_errors, SQ_SESSION); +if (is_array($delayed_errors)) { + $oErrorHandler->AssignDelayedErrors($delayed_errors); + sqsession_unregister("delayed_errors"); +} /** SESSION/POST/GET VARS */ sqgetGlobalVar('session',$session); @@ -77,7 +77,12 @@ sqgetGlobalVar('draft_id',$draft_id); sqgetGlobalVar('ent_num',$ent_num); sqgetGlobalVar('saved_draft',$saved_draft); sqgetGlobalVar('delete_draft',$delete_draft); -sqgetGlobalVar('startMessage',$startMessage); +if ( sqgetGlobalVar('startMessage',$startMessage) ) { + $startMessage = (int)$startMessage; +} else { + $startMessage = 1; +} + /** POST VARS */ sqgetGlobalVar('sigappend', $sigappend, SQ_POST); @@ -93,6 +98,12 @@ if ( sqgetGlobalVar('return', $temp, SQ_POST) ) { /** GET VARS */ sqgetGlobalVar('attachedmessages', $attachedmessages, SQ_GET); +if ( sqgetGlobalVar('account', $temp, SQ_GET) ) { + $iAccount = (int) $temp; +} else { + $iAccount = 0; +} + /** get smaction */ if ( !sqgetGlobalVar('smaction',$action) ) @@ -169,22 +180,19 @@ function replyAllString($header) { function getReplyCitation($orig_from, $orig_date) { global $reply_citation_style, $reply_citation_start, $reply_citation_end; - // FIXME: why object is rewritten with string. if (!is_object($orig_from)) { - $orig_from = ''; + $sOrig_from = ''; } else { - $orig_from = decodeHeader($orig_from->getAddress(false),false,false,true); + $sOrig_from = decodeHeader($orig_from->getAddress(false),false,false,true); } -// $from = decodeHeader($orig_header->getAddr_s('from',"\n$indent"),false,false); - /* First, return an empty string when no citation style selected. */ if (($reply_citation_style == '') || ($reply_citation_style == 'none')) { return ''; } /* Make sure our final value isn't an empty string. */ - if ($orig_from == '') { + if ($sOrig_from == '') { return ''; } @@ -194,13 +202,12 @@ function getReplyCitation($orig_from, $orig_date) { /** * To translators: %s is for author's name */ - $full_reply_citation = sprintf(_("%s wrote:"),$orig_from); + $full_reply_citation = sprintf(_("%s wrote:"),$sOrig_from); break; case 'quote_who': - // FIXME: do we have to translate xml formating? - $start = '<' . _("quote") . ' ' . _("who") . '="'; + $start = ''; - $full_reply_citation = $start . $orig_from . $end; + $full_reply_citation = $start . $sOrig_from . $end; break; case 'date_time_author': /** @@ -212,13 +219,13 @@ function getReplyCitation($orig_from, $orig_date) { * If you have to put author's name in front of date string, check comments about * argument swapping at http://www.php.net/sprintf */ - $full_reply_citation = sprintf(_("On %s, %s wrote:"), getLongDateString($orig_date), $orig_from); + $full_reply_citation = sprintf(_("On %s, %s wrote:"), getLongDateString($orig_date), $sOrig_from); break; case 'user-defined': $start = $reply_citation_start . ($reply_citation_start == '' ? '' : ' '); $end = $reply_citation_end; - $full_reply_citation = $start . $orig_from . $end; + $full_reply_citation = $start . $sOrig_from . $end; break; default: return ''; @@ -288,13 +295,19 @@ if (sqsession_is_registered('session_expired_post')) { sqsession_unregister('session_expired_post'); session_write_close(); } else { - foreach ($session_expired_post as $postvar => $val) { - if (isset($val)) { - $$postvar = $val; - } else { - $$postvar = ''; + // 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'); + + foreach ($compo_var_list as $var) { + if ( isset($session_expired_post[$var]) && !isset($$var) ) { + $$var = $session_expired_post[$var]; } } + $compose_messages = unserialize(urldecode($restoremessages)); sqsession_register($compose_messages,'compose_messages'); sqsession_register($composesession,'composesession'); @@ -339,7 +352,6 @@ if (!isset($compose_messages)) { } if (!isset($compose_messages[$session]) || ($compose_messages[$session] == NULL)) { - /* if (!array_key_exists($session, $compose_messages)) { /* We can only do this in PHP >= 4.1 */ $composeMessage = new Message(); $rfc822_header = new Rfc822Header(); $composeMessage->rfc822_header = $rfc822_header; @@ -381,25 +393,29 @@ if ($draft) { } sqimap_logout($imap_stream); } + if (count($oErrorHandler->aErrors)) { + sqsession_register($oErrorHandler->aErrors,"delayed_errors"); + } + session_write_close(); if ($compose_new_win == '1') { if ( !isset($pageheader_sent) || !$pageheader_sent ) { Header("Location: $location/compose.php?saved_draft=yes&session=$composesession"); } else { - echo '

' - . _("Return") . '
'; - } + . _("Return") . ''; + } exit(); } else { if ( !isset($pageheader_sent) || !$pageheader_sent ) { Header("Location: $location/right_main.php?mailbox=" . urlencode($draft_folder) . "&startMessage=1¬e=".urlencode($draft_message)); } else { - echo '

' - . _("Return") . '
'; - } + . _("Return") . ''; + } exit(); } } @@ -414,7 +430,7 @@ if ($send) { if (checkInput(false) && !isset($AttachFailure)) { if ($mailbox == "All Folders") { /* We entered compose via the search results page */ - $mailbox="INBOX"; /* Send 'em to INBOX, that's safe enough */ + $mailbox = 'INBOX'; /* Send 'em to INBOX, that's safe enough */ } $urlMailbox = urlencode (trim($mailbox)); if (! isset($passed_id)) { @@ -455,11 +471,14 @@ if ($send) { $composeMessage=$compose_messages[$session]; $Result = deliverMessage($composeMessage); + + do_hook('compose_send_after', $Result, $composeMessage); if (! $Result) { showInputForm($session); exit(); } unset($compose_messages[$session]); + /* if it is resumed draft, delete draft message */ if ( isset($delete_draft)) { $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, false); @@ -473,13 +492,20 @@ if ($send) { } sqimap_logout($imap_stream); } + /* + * Store the error array in the session because they will be lost on a redirect + */ + if (count($oErrorHandler->aErrors)) { + sqsession_register($oErrorHandler->aErrors,"delayed_errors"); + } + session_write_close(); if ($compose_new_win == '1') { if ( !isset($pageheader_sent) || !$pageheader_sent ) { Header("Location: $location/compose.php?mail_sent=yes"); } else { - echo '

' - . _("Return") . '
'; + . _("Return") . ''; } exit(); } else { @@ -487,10 +513,10 @@ if ($send) { Header("Location: $location/right_main.php?mailbox=$urlMailbox". "&startMessage=$startMessage&mail_sent=yes"); } else { - echo '

" - . _("Return") . '
'; + . _("Return") . ''; } exit(); } @@ -545,7 +571,7 @@ if ($send) { $_FILES['attachfile']['tmp_name'] && $_FILES['attachfile']['tmp_name'] != 'none') { if(saveAttachedFiles($session)) { - plain_error_message(_("Could not move/copy file. File not attached"), $color); + plain_error_message(_("Could not move/copy file. File not attached")); } } /* @@ -554,14 +580,14 @@ if ($send) { */ include_once('./addrbook_search_html.php'); } elseif (isset($attach)) { - if (saveAttachedFiles($session)) { - plain_error_message(_("Could not move/copy file. File not attached"), $color); - } if ($compose_new_win == '1') { compose_Header($color, $mailbox); } else { displayPageHeader($color, $mailbox); } + if (saveAttachedFiles($session)) { + plain_error_message(_("Could not move/copy file. File not attached")); + } showInputForm($session); } elseif (isset($sigappend)) { @@ -584,9 +610,10 @@ elseif (isset($sigappend)) { if (isset($delete) && is_array($delete)) { $composeMessage = $compose_messages[$session]; foreach($delete as $index) { - $attached_file = $composeMessage->entities[$index]->att_local_name; - unlink ($attached_file); - unset ($composeMessage->entities[$index]); + if (!empty($composeMessage->entities) && isset($composeMessage->entities[$index])) { + $composeMessage->entities[$index]->purgeAttachments(); + unset ($composeMessage->entities[$index]); + } } $new_entities = array(); foreach ($composeMessage->entities as $entity) { @@ -660,7 +687,7 @@ function getforwardSubject($subject) function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $session='') { global $editor_size, $default_use_priority, $body, $idents, $use_signature, $data_dir, $username, - $username, $key, $imapServerAddress, $imapPort, $compose_messages, + $key, $imapServerAddress, $imapPort, $compose_messages, $composeMessage, $body_quote; global $languages, $squirrelmail_language, $default_charset; @@ -731,6 +758,7 @@ function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $se } } + // charset encoding in compose form stuff if (isset($body_part_entity->header->parameters['charset'])) { $actual = $body_part_entity->header->parameters['charset']; } else { @@ -740,6 +768,7 @@ function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $se if ( $actual && is_conversion_safe($actual) && $actual != $default_charset){ $bodypart = charset_convert($actual,$bodypart,$default_charset,false); } + // end of charset encoding in compose $body .= $bodypart; } @@ -751,7 +780,6 @@ function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $se } else { $mailprio = ''; } - //ClearAttachments($session); $identity = ''; $from_o = $orig_header->from; @@ -1013,8 +1041,17 @@ function showInputForm ($session, $values=false) { $from_htmladdr_search, $location_of_buttons, $attachment_dir, $username, $data_dir, $identity, $idents, $delete_draft, $mailprio, $compose_new_win, $saved_draft, $mail_sent, $sig_first, - $username, $compose_messages, $composesession, $default_charset; + $compose_messages, $composesession, $default_charset, + $compose_onsubmit, $oTemplate; + if (checkForJavascript()) { + $onfocus = ' onfocus="alreadyFocused=true;"'; + $onfocus_array = array('onfocus' => 'alreadyFocused=true;'); + } + else { + $onfocus = ''; + $onfocus_array = array(); + } $composeMessage = $compose_messages[$session]; if ($values) { @@ -1032,7 +1069,7 @@ function showInputForm ($session, $values=false) { } if ($use_javascript_addr_book) { - echo "\n". '