X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fread_body.php;h=1139ea45df2ba8d029c3511c841dae417c6c2ec5;hb=19d470aa121cacdd916319ec6b55af180562805e;hp=c2a4c84cb8a27719dc7c5bb71e4a59a34e805c80;hpb=91d95c42e4560508f3b4a32701ab40053ccade0a;p=squirrelmail.git
diff --git a/src/read_body.php b/src/read_body.php
index c2a4c84c..1139ea45 100644
--- a/src/read_body.php
+++ b/src/read_body.php
@@ -18,6 +18,7 @@ require_once('../functions/mime.php');
require_once('../functions/date.php');
require_once('../functions/url_parser.php');
require_once('../functions/smtp.php');
+require_once('../functions/html.php');
/**
* Given an IMAP message id number, this will look it up in the cached
@@ -26,8 +27,8 @@ require_once('../functions/smtp.php');
*
* @return the index of the next valid message from the array
*/
-function findNextMessage() {
- global $msort, $currentArrayIndex, $msgs, $sort,
+function findNextMessage($passed_id) {
+ global $msort, $msgs, $sort,
$thread_sort_messages, $allow_server_sort,
$server_sort_array;
if (!is_array($server_sort_array)) {
@@ -35,10 +36,10 @@ function findNextMessage() {
$allow_server_sort = FALSE;
}
$result = -1;
- if ($thread_sort_messages == 1 || $allow_server_sort == TRUE) {
+ if ($thread_sort_messages || $allow_server_sort) {
reset($server_sort_array);
while(list($key, $value) = each ($server_sort_array)) {
- if ($currentArrayIndex == $value) {
+ if ($passed_id == $value) {
if ($key == (count($server_sort_array) - 1)) {
$result = -1;
break;
@@ -47,19 +48,17 @@ function findNextMessage() {
break;
}
}
- }
- elseif ($sort == 6 && $allow_server_sort != TRUE &&
- $thread_sort_messages != 1) {
- if ($currentArrayIndex != 1) {
- $result = $currentArrayIndex - 1;
+ } else if ($sort == 6 && !$allow_server_sort &&
+ !$thread_sort_messages ) {
+ if ($passed_id != 1) {
+ $result = $passed_id - 1;
}
- }
- elseif ($allow_server_sort != TRUE && $thread_sort_messages != 1 ) {
+ } else if (!$allow_server_sort && !$thread_sort_messages ) {
if (!is_array($msort)) {
return -1;
}
for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
- if ($currentArrayIndex == $msgs[$key]['ID']) {
+ if ($passed_id == $msgs[$key]['ID']) {
next($msort);
$key = key($msort);
if (isset($key)){
@@ -72,35 +71,20 @@ function findNextMessage() {
return ($result);
}
-/**
- * Removes just one address from the list of addresses.
- *
- * @param &$addr_list a by-ref array of addresses
- * @param $addr an address to remove
- * @return void, since it operates on a by-ref param
- */
-function RemoveAddress(&$addr_list, $addr) {
- if ($addr != '') {
- foreach (array_keys($addr_list, $addr) as $key_to_delete) {
- unset($addr_list[$key_to_delete]);
- }
- }
-}
-
/** returns the index of the previous message from the array. */
-function findPreviousMessage() {
- global $msort, $currentArrayIndex, $sort, $msgs, $imapConnection,
- $mailbox, $data_dir, $username, $thread_sort_messages,
+function findPreviousMessage($numMessages, $passed_id) {
+ global $msort, $sort, $msgs,
+ $thread_sort_messages,
$allow_server_sort, $server_sort_array;
$result = -1;
if (!is_array($server_sort_array)) {
$thread_sort_messages = 0;
$allow_server_sort = FALSE;
}
- if ($thread_sort_messages == 1 || $allow_server_sort == TRUE) {
+ if ($thread_sort_messages || $allow_server_sort ) {
reset($server_sort_array);
while(list($key, $value) = each ($server_sort_array)) {
- if ($currentArrayIndex == $value) {
+ if ($passed_id == $value) {
if ($key == 0) {
$result = -1;
break;
@@ -109,23 +93,21 @@ function findPreviousMessage() {
break;
}
}
- }
- elseif ($sort == 6 && $allow_server_sort != TRUE &&
- $thread_sort_messages != 1) {
- $numMessages = sqimap_get_num_messages($imapConnection, $mailbox);
- if ($currentArrayIndex != $numMessages) {
- $result = $currentArrayIndex + 1;
+ } else if ($sort == 6 && !$allow_server_sort &&
+ !$thread_sort_messages) {
+ if ($passed_id != $numMessages) {
+ $result = $passed_id + 1;
}
- }
- elseif ($thread_sort_messages != 1 && $allow_server_sort != TRUE) {
+ } else if (!$thread_sort_messages && !$allow_server_sort) {
if (!is_array($msort)) {
return -1;
}
for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
- if ($currentArrayIndex == $msgs[$key]['ID']) {
+ if ($passed_id == $msgs[$key]['ID']) {
prev($msort);
$key = key($msort);
if (isset($key)) {
+ //echo $msort[$key]; /* Why again were we echoing here? */
$result = $msgs[$key]['ID'];
break;
}
@@ -139,32 +121,16 @@ function findPreviousMessage() {
* Displays a link to a page where the message is displayed more
* "printer friendly".
*/
-function printer_friendly_link() {
- global $passed_id, $mailbox, $ent_num, $color,
- $pf_subtle_link,
- $javascript_on;
-
- if (strlen(trim($mailbox)) < 1) {
- $mailbox = 'INBOX';
- }
+function printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color) {
+ global $javascript_on;
- $params = '?passed_ent_id=' . $ent_num .
+ $params = '?passed_ent_id=' . $passed_ent_id .
'&mailbox=' . urlencode($mailbox) .
'&passed_id=' . $passed_id;
$print_text = _("View Printable Version");
- if (!$pf_subtle_link) {
- /* The link is large, on the bottom of the header panel. */
- $result = '
' .
- '' .
- ' ' .
- ' | '."\n";
- } else {
- /* The link is subtle, below "view full header". */
- $result = " \n";
- }
-
+ $result = '';
/* Output the link. */
if ($javascript_on) {
$result .= '\n" .
- "$print_text\n";
+ "$print_text\n";
} else {
- $result .= '$print_text\n";
- }
-
- if (!$pf_subtle_link) {
- /* The link is large, on the bottom of the header panel. */
- $result .= ' |
' . "\n";
+ $result .= '$print_text\n";
}
-
return ($result);
}
@@ -195,12 +155,15 @@ function ServerMDNSupport( $read ) {
return ( $ret );
}
-function SendMDN ( $recipient , $sender) {
- global $imapConnection, $mailbox, $username, $attachment_dir, $SERVER_NAME,
- $version, $attachments, $identity, $data_dir, $passed_id;
+function SendMDN ( $mailbox, $passed_id, $sender, $message) {
+ global $username, $attachment_dir, $SERVER_NAME,
+ $version, $attachments, $squirrelmail_language;
- $header = sqimap_get_message_header($imapConnection, $passed_id, $mailbox);
+ $header = $message->rfc822_header;
$hashed_attachment_dir = getHashedDir($username, $attachment_dir);
+
+ $recipient_o = $header->dnt;
+ $recipient = $recipient_o->getAddress(true);
// part 1 (RFC2298)
@@ -208,7 +171,7 @@ function SendMDN ( $recipient , $sender) {
$to_array = $header->to;
$to = '';
foreach ($to_array as $line) {
- $to .= " $line ";
+ $to .= ' '.$line->getAddress();
}
$subject = $header->subject;
@@ -223,8 +186,11 @@ function SendMDN ( $recipient , $sender) {
"\r\n" .
sprintf( _("Was displayed on %s"), $now );
+ if (function_exists($languages[$squrrelmail_language]['XTRA_CODE'])) {
+ $body = $languages[$squirrelmail_language]['XTRA_CODE']('encode', $body);
+ }
+
// part2 (RFC2298)
-
$original_recipient = $to;
$original_message_id = $header->message_id;
@@ -237,7 +203,6 @@ function SendMDN ( $recipient , $sender) {
"Original-Message-ID : $original_message_id\r\n" .
"Disposition: manual-action/MDN-sent-manually; displayed\r\n";
-
$localfilename = GenerateRandomString(32, 'FILE', 7);
$full_localfilename = "$hashed_attachment_dir/$localfilename";
@@ -250,21 +215,17 @@ function SendMDN ( $recipient , $sender) {
$newAttachment['type'] = "message/disposition-notification";
$newAttachment['session']=-1;
$attachments[] = $newAttachment;
- $MDN_to = trim($recipient);
- $reply_id = 0;
- return (SendMessage($MDN_to, '', '', _("Read:") . ' ' . $subject,
- $body, $reply_id, True, 3, -1) );
+ return (SendMessage($recipient, '', '', _("Read:") . ' ' . $subject,
+ $body, 0, True, 3, -1) );
}
-function ToggleMDNflag ( $set ) {
- global $imapConnection, $passed_id, $mailbox;
- sqimap_mailbox_select($imapConnection, $mailbox);
+function ToggleMDNflag ( $set ,$imapConnection, $mailbox, $passed_id, $uid_support) {
$sg = $set?'+':'-';
$cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
$read = sqimap_run_command ($imapConnection, $cmd, true, $response,
- $readmessage);
+ $readmessage, $uid_support);
}
function ClearAttachments() {
@@ -287,865 +248,464 @@ function ClearAttachments() {
}
function formatRecipientString($recipients, $item ) {
- global $base_uri, $passed_id, $urlMailbox, $startMessage, $show_more_cc,
- $echo_more, $echo_less, $show_more, $show_more_bcc, $sort;
+ global $show_more_cc, $show_more, $show_more_bcc,
+ $PHP_SELF;
- $i = 0;
- $url_string = '';
-
- if (isset ($recipients[0]) && trim($recipients[0])) {
+ if ((is_array($recipients)) && (isset($recipients[0]))) {
$string = '';
$ary = $recipients;
+ $show = false;
+
+ if ($item == 'to') {
+ if ($show_more) {
+ $show = true;
+ $url = set_url_var($PHP_SELF, 'show_more',0);
+ } else {
+ $url = set_url_var($PHP_SELF, 'show_more',1);
+ }
+ } else if ($item == 'cc') {
+ if ($show_more_cc) {
+ $url = set_url_var($PHP_SELF, 'show_more_cc',0);
+ $show = true;
+ } else {
+ $url = set_url_var($PHP_SELF, 'show_more_cc',1);
+ }
+ } else if ($item == 'bcc') {
+ if ($show_more_bcc) {
+ $url = set_url_var($PHP_SELF, 'show_more_bcc',0);
+ $show = true;
+ } else {
+ $url = set_url_var($PHP_SELF, 'show_more_bcc',1);
+ }
+ }
- switch ($item) {
- case 'to':
- $show = "&show_more=1&show_more_cc=$show_more_cc&".
- "show_more_bcc=$show_more_bcc";
- $show_n = "&show_more=0&show_more_cc=$show_more_cc&".
- "show_more_bcc=$show_more_bcc";
- break;
- case 'cc':
- $show = "&show_more=$show_more&show_more_cc=1&".
- "show_more_bcc=$show_more_bcc";
- $show_n = "&show_more=$show_more&show_more_cc=0&".
- "show_more_bcc=$show_more_bcc";
- $show_more = $show_more_cc;
- break;
- case 'bcc':
- $show = "&show_more=$show_more&show_more_cc=$show_more_cc".
- "&show_more_bcc=1";
- $show_n = "&show_more=$show_more&show_more_cc=".
- "$show_more_cc&show_more_bcc=0";
- $show_more = $show_more_bcc;
- break;
- default:
- $break;
- }
-
- while ($i < count($ary)) {
- $ary[$i] = decodeHeader(htmlspecialchars($ary[$i]));
- $url_string .= $ary[$i];
+ $cnt = count($ary);
+ $i = 0;
+ while ($i < $cnt) {
+ $ary[$i] = htmlspecialchars($ary[$i]->getAddress());
if ($string) {
- $string = "$string
$ary[$i]";
+ $string .= '
'.$ary[$i];
} else {
- $string = "$ary[$i]";
+ $string = $ary[$i];
+ if ($cnt>1) {
+ $string .= ' ('._("less").')';
+ } else {
+ $string .= '">'._("more").')';
+ break;
+ }
+ }
}
-
$i++;
- if (count($ary) > 1) {
- if ($show_more == false) {
- if ($i == 1) {
- /* From a search... */
- $string .= ' ($echo_more)";
- } else {
- $string .= "sort=$sort&startMessage=".
- "$startMessage"."$show\">$echo_more)";
- }
- $i = count($ary);
- }
- } else if ($i == 1) {
- /* From a search... */
- $string .= ' ($echo_less)";
- } else {
- $string .= "sort=$sort&startMessage=$startMessage".
- "$show_n\">$echo_less)";
- }
- }
- }
}
}
else {
$string = '';
}
- $url_string = urlencode($url_string);
- $result = array();
- $result['str'] = $string;
- $result['url_str'] = $url_string;
- return $result;
-}
-
-
-
-/*
- * Main of read_boby.php --------------------------------------------------
- */
-
-/*
- Urled vars
- ----------
- $passed_id
-*/
-
-if (isset($mailbox)){
- $mailbox = urldecode( $mailbox );
-}
-$imapConnection = sqimap_login($username, $key, $imapServerAddress,
- $imapPort, 0);
-$read = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
-
-do_hook('html_top');
-
-/*
- * The following code sets necesarry stuff for the MDN thing
- */
-if($default_use_mdn &&
- ($mdn_user_support = getPref($data_dir, $username, 'mdn_user_support',
- $default_use_mdn))) {
-
- $supportMDN = ServerMDNSupport($read["PERMANENTFLAGS"]);
- $flags = sqimap_get_flags ($imapConnection, $passed_id);
- $FirstTimeSee = !(in_array( 'Seen', $flags ));
-}
-
-displayPageHeader($color, $mailbox);
-
-
-/*
- * The following code shows the header of the message and then exit
- */
-if (isset($view_hdr)) {
- $read=sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[HEADER]",
- true, $a, $b);
-
- echo '
' .
- '\n".
- "\n".
- '';
-
- $cnum = 0;
- for ($i=1; $i < count($read); $i++) {
- $line = htmlspecialchars($read[$i]);
- if (eregi("^>", $line)) {
- $second[$i] = $line;
- $first[$i] = ' ';
- $cnum++;
- } else if (eregi("^[ |\t]", $line)) {
- $second[$i] = $line;
- $first[$i] = '';
- } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
- $first[$i] = $regs[1] . ':';
- $second[$i] = $regs[2];
- $cnum++;
- } else {
- $second[$i] = trim($line);
- $first[$i] = '';
- }
- }
- for ($i=0; $i < count($second); $i = $j) {
- if (isset($first[$i])) {
- $f = $first[$i];
- }
- if (isset($second[$i])) {
- $s = nl2br($second[$i]);
- }
- $j = $i + 1;
- while (($first[$j] == '') && ($j < count($first))) {
- $s .= ' ' . nl2br($second[$j]);
- $j++;
- }
- if(strtolower($f) != 'message-id:') {
- parseEmail($s); /* Find and linkify emailaddresses except msgid */
- }
- if (isset($f)) {
- echo "$f$s";
- }
- }
- echo " |
\n" .
- '