replyto)) {
$excl_ar = $header->getAddr_a('replyto');
}
/**
* 2) Remove our identities from the CC list (they still can be in the
* TO list) only if $include_self_reply_all is turned off
*/
if (!$include_self_reply_all) {
foreach($idents as $id) {
$excl_ar[strtolower(trim($id['email_address']))] = '';
}
}
/**
* 3) get the addresses.
*/
$url_replytoall_ar = $header->getAddr_a(array('to','cc'), $excl_ar);
/**
* 4) generate the string.
*/
$url_replytoallcc = '';
foreach( $url_replytoall_ar as $email => $personal) {
if ($personal) {
// if personal name contains address separator then surround
// the personal name with double quotes.
if (strpos($personal,',') !== false) {
$personal = '"'.$personal.'"';
}
$url_replytoallcc .= ", $personal <$email>";
} else {
$url_replytoallcc .= ', '. $email;
}
}
$url_replytoallcc = substr($url_replytoallcc,2);
return $url_replytoallcc;
}
/**
* creates top line in reply citations
*
* Line style depends on user preferences.
* $orig_date argument is available only from 1.4.3 and 1.5.1 version.
* @param object $orig_from From: header object.
* @param integer $orig_date email's timestamp
* @return string reply citation
*/
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 = '';
} else {
$orig_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 == '') {
return '';
}
/* Otherwise, try to select the desired citation style. */
switch ($reply_citation_style) {
case 'author_said':
/**
* To translators: %s is for author's name
*/
$full_reply_citation = sprintf(_("%s wrote:"),$orig_from);
break;
case 'quote_who':
// FIXME: do we have to translate xml formating?
$start = '<' . _("quote") . ' ' . _("who") . '="';
$end = '">';
$full_reply_citation = $start . $orig_from . $end;
break;
case 'date_time_author':
/**
* To translators:
* first %s is for date string, second %s is for author's name. Date uses
* formating from "D, F j, Y g:i a" and "D, F j, Y H:i" translations.
* Example string:
* "On Sat, December 24, 2004 23:59, Santa wrote:"
* 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);
break;
case 'user-defined':
$start = $reply_citation_start .
($reply_citation_start == '' ? '' : ' ');
$end = $reply_citation_end;
$full_reply_citation = $start . $orig_from . $end;
break;
default:
return '';
}
/* Add line feed and return the citation string. */
return ($full_reply_citation . "\n");
}
/**
* Creates header fields in forwarded email body
*
* $default_charset global must be set correctly before you call this function.
* @param object $orig_header
* @return $string
*/
function getforwardHeader($orig_header) {
global $editor_size, $default_charset;
// using own strlen function in order to detect correct string length
$display = array( _("Subject") => sq_strlen(_("Subject"),$default_charset),
_("From") => sq_strlen(_("From"),$default_charset),
_("Date") => sq_strlen(_("Date"),$default_charset),
_("To") => sq_strlen(_("To"),$default_charset),
_("Cc") => sq_strlen(_("Cc"),$default_charset) );
$maxsize = max($display);
$indent = str_pad('',$maxsize+2);
foreach($display as $key => $val) {
$display[$key] = $key .': '. str_pad('', $maxsize - $val);
}
$from = decodeHeader($orig_header->getAddr_s('from',"\n$indent"),false,false,true);
$from = str_replace(' ',' ',$from);
$to = decodeHeader($orig_header->getAddr_s('to',"\n$indent"),false,false,true);
$to = str_replace(' ',' ',$to);
$subject = decodeHeader($orig_header->subject,false,false,true);
$subject = str_replace(' ',' ',$subject);
// using own str_pad function in order to create correct string pad
$bodyTop = sq_str_pad(' '._("Original Message").' ',$editor_size -2,'-',STR_PAD_BOTH,$default_charset) .
"\n". $display[_("Subject")] . $subject . "\n" .
$display[_("From")] . $from . "\n" .
$display[_("Date")] . getLongDateString( $orig_header->date ). "\n" .
$display[_("To")] . $to . "\n";
if ($orig_header->cc != array() && $orig_header->cc !='') {
$cc = decodeHeader($orig_header->getAddr_s('cc',"\n$indent"),false,false,true);
$cc = str_replace(' ',' ',$cc);
$bodyTop .= $display[_("Cc")] .$cc . "\n";
}
$bodyTop .= str_pad('', $editor_size -2 , '-') .
"\n\n";
return $bodyTop;
}
/* ----------------------------------------------------------------------- */
/*
* If the session is expired during a post this restores the compose session
* vars.
*/
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 {
foreach ($session_expired_post as $postvar => $val) {
if (isset($val)) {
$$postvar = $val;
} else {
$$postvar = '';
}
}
$compose_messages = unserialize(urldecode($restoremessages));
sqsession_register($compose_messages,'compose_messages');
sqsession_register($composesession,'composesession');
if (isset($send)) {
unset($send);
}
$session_expired = true;
}
unset($session_expired_post);
sqsession_unregister('session_expired_post');
session_write_close();
if (!isset($mailbox)) {
$mailbox = '';
}
if ($compose_new_win == '1') {
compose_Header($color, $mailbox);
} else {
$sHeaderJs = (isset($sHeaderJs)) ? $sHeaderJs : '';
if (strpos($action, 'reply') !== false && $reply_focus) {
$sBodyTagJs = 'onload="checkForm(\''.$replyfocus.'\');"';
} else {
$sBodyTagJs = 'onload="checkForm();"';
}
displayPageHeader($color, $mailbox,$sHeaderJs,$sBodyTagJs);
}
showInputForm($session, false);
exit();
}
if (!isset($composesession)) {
$composesession = 0;
sqsession_register(0,'composesession');
}
if (!isset($session) || (isset($newmessage) && $newmessage)) {
sqsession_unregister('composesession');
$session = "$composesession" +1;
$composesession = $session;
sqsession_register($composesession,'composesession');
}
if (!isset($compose_messages)) {
$compose_messages = array();
}
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;
$composeMessage->reply_rfc822_header = '';
$compose_messages[$session] = $composeMessage;
sqsession_register($compose_messages,'compose_messages');
} else {
$composeMessage=$compose_messages[$session];
}
if (!isset($mailbox) || $mailbox == '' || ($mailbox == 'None')) {
$mailbox = 'INBOX';
}
if ($draft) {
/*
* Set $default_charset to correspond with the user's selection
* of language interface.
*/
set_my_charset();
$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)) {
$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, false);
sqimap_mailbox_select($imap_stream, $draft_folder);
// force bypass_trash=true because message should be saved when deliverMessage() returns true.
// in current implementation of sqimap_msgs_list_flag() single message id can
// be submitted as string. docs state that it should be array.
sqimap_msgs_list_delete($imap_stream, $draft_folder, $delete_draft, true);
if ($auto_expunge) {
sqimap_mailbox_expunge($imap_stream, $draft_folder, true);
}
sqimap_logout($imap_stream);
}
if ($compose_new_win == '1') {
if ( !isset($pageheader_sent) || !$pageheader_sent ) {
Header("Location: $location/compose.php?saved_draft=yes&session=$composesession");
} else {
echo '
' . _("Because PHP file uploads are turned off, you can not attach files to this message. Please see your system administrator for details.") . "
\r\n"; } do_hook('compose_bottom'); echo '