/**
* draft_actions.php
*
- * Copyright (c) 1999-2001 The Squirrelmail Development Team
+ * Copyright (c) 1999-2002 The SquirrelMail Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* $Id$
require_once ('../src/validate.php');
/* Print all the needed RFC822 headers */
-function write822HeaderForDraft ($fp, $t, $c, $b, $subject, $more_headers) {
+function write822HeaderForDraft ($fp, $t, $c, $b, $subject, $more_headers, $session) {
global $REMOTE_ADDR, $SERVER_NAME, $REMOTE_PORT;
global $data_dir, $username, $popuser, $domain, $version, $useSendmail;
global $default_charset, $HTTP_VIA, $HTTP_X_FORWARDED_FOR;
/* Do the MIME-stuff */
$header .= "MIME-Version: 1.0\r\n";
- if (isMultipart()) {
+ if (isMultipart($session)) {
$header .= 'Content-Type: multipart/mixed; boundary="';
$header .= mimeBoundary();
$header .= "\"\r\n";
}
/* Send the body */
-function writeBodyForDraft ($fp, $passedBody) {
+function writeBodyForDraft ($fp, $passedBody, $session) {
global $default_charset;
$attachmentlength = 0;
- if (isMultipart()) {
+ if (isMultipart($session)) {
$body = '--'.mimeBoundary()."\r\n";
if ($default_charset != ""){
$body .= $passedBody . "\r\n\r\n";
fputs ($fp, $body);
- $attachmentlength = attachFiles($fp);
+ $attachmentlength = attachFiles($fp, $session);
if (!isset($postbody)) $postbody = "";
$postbody .= "\r\n--".mimeBoundary()."--\r\n\r\n";
}
-function saveMessageAsDraft($t, $c, $b, $subject, $body, $reply_id) {
- global $useSendmail, $msg_id, $is_reply, $mailbox, $onetimepad;
- global $data_dir, $username, $domain, $key, $version, $sent_folder, $imapServerAddress, $imapPort;
- global $draft_folder, $attachment_dir;
+function saveMessageAsDraft($t, $c, $b, $subject, $body, $reply_id, $prio = 3, $session) {
+ global $useSendmail, $msg_id, $is_reply, $mailbox, $onetimepad,
+ $data_dir, $username, $domain, $key, $version, $sent_folder,
+ $imapServerAddress, $imapPort, $draft_folder, $attachment_dir,
+ $default_use_priority;
$more_headers = Array();
+ if ($default_use_priority) {
+ $more_headers = array_merge($more_headers, createPriorityHeaders($prio));
+ }
+
$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 1);
+ $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
+
$tmpDraftFile = "draft-" . GenerateRandomString(32, '', 7);
- while ( file_exists($attachment_dir .$tmpDraftFile)){
+ $full_tmpDraftFile = "$hashed_attachment_dir/$tmpDraftFile";
+ while (file_exists($full_tmpDraftFile)){
$tmpDraftFile = "draft-" . GenerateRandomString(32, '', 7);
+ $full_tmpDraftFile = "$hashed_attachment_dir/$tmpDraftFile";
}
- $fp = fopen($attachment_dir . $tmpDraftFile, 'w');
+ $fp = fopen($full_tmpDraftFile, 'w');
- $headerlength = write822HeaderForDraft ($fp, $t, $c, $b, $subject, $more_headers, FALSE);
- $bodylength = writeBodyForDraft ($fp, $body, FALSE);
+ $headerlength = write822HeaderForDraft
+ ($fp, $t, $c, $b, $subject, $more_headers, $session);
+ $bodylength = writeBodyForDraft ($fp, $body, $session);
fclose($fp);
$length = ($headerlength + $bodylength);
if (sqimap_mailbox_exists ($imap_stream, $draft_folder)) {
sqimap_append ($imap_stream, $draft_folder, $length);
- write822HeaderForDraft ($imap_stream, $t, $c, $b, $subject, $more_headers, TRUE);
- writeBodyForDraft ($imap_stream, $body, TRUE);
+ write822HeaderForDraft
+ ($imap_stream, $t, $c, $b, $subject, $more_headers, $session);
+ writeBodyForDraft ($imap_stream, $body, $session);
sqimap_append_done ($imap_stream);
}
sqimap_logout($imap_stream);
if ($length){
- ClearAttachments();
+ ClearAttachments($session);
}
- if (file_exists($attachment_dir . $tmpDraftFile)){
- unlink ($attachment_dir . $tmpDraftFile);
+ if (file_exists($full_tmpDraftFile)){
+ unlink ($full_tmpDraftFile);
}
return $length;
}
-?>
+
+?>
\ No newline at end of file