+require_once('../functions/display_messages.php');
+/* --------------------- Specific Functions ------------------------------ */
+
+function replyAllString($header) {
+ global $include_self_reply_all, $username, $data_dir;
+ $excl_arr = array();
+ /**
+ * 1) Remove the addresses we'll be sending the message 'to'
+ */
+ $url_replytoall_avoid_addrs = '';
+ if (isset($header->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) {
+ $email_address = trim(getPref($data_dir, $username, 'email_address'));
+ $excl_ar[$email_address] = '';
+
+ $idents = getPref($data_dir, $username, 'identities');
+ if ($idents != '' && $idents > 1) {
+ for ($i = 1; $i < $idents; $i ++) {
+ $cur_email_address = getPref($data_dir, $username,
+ 'email_address' . $i);
+ $cur_email_address = strtolower($cur_email_address);
+ $excl_ar[$cur_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) {
+ $url_replytoallcc .= ", \"$personal\" <$email>";
+ } else {
+ $url_replytoallcc .= ', '. $email;
+ }
+ }
+ $url_replytoallcc = substr($url_replytoallcc,2);
+ return $url_replytoallcc;
+}
+
+function getforwardHeader($orig_header) {
+ global $editor_size;
+
+ $display = array(
+ _("Subject") => strlen(_("Subject")),
+ _("From") => strlen(_("From")),
+ _("Date") => strlen(_("Date")),
+ _("To") => strlen(_("To")),
+ _("Cc") => strlen(_("Cc"))
+ );
+ $maxsize = max($display);
+ $indent = str_pad('',$maxsize+2);
+ foreach($display as $key => $val) {
+ $display[$key] = $key .': '. str_pad('', $maxsize - $val);
+ }
+ $bodyTop = str_pad(' '._("Original Message").' ',$editor_size -2,'-',STR_PAD_BOTH);
+ $bodyTop .= "\n". $display[_("Subject")] . decodeHeader($orig_header->subject) . "\n" .
+ $display[_("From")] . decodeHeader($orig_header->getAddr_s('from',"\n$indent")) . "\n" .
+ $display[_("Date")] . getLongDateString( $orig_header->date ). "\n" .
+ $display[_("To")] . decodeHeader($orig_header->getAddr_s('to',"\n$indent")) ."\n";
+ if ($orig_header->cc != array() && $orig_header->cc !='') {
+ $bodyTop .= $display[_("Cc")] . decodeHeader($orig_header->getAddr_s('cc',"\n$indent")) . "\n";
+ }
+ $bodyTop .= str_pad('', $editor_size -2 , '-');
+ $bodyTop .= "\n";
+ return $bodyTop;
+}
+/* ----------------------------------------------------------------------- */
+
+/*
+ * If the session is expired during a post this restores the compose session
+ * vars.
+ */
+//$session_expired = false;
+if (session_is_registered('session_expired_post')) {
+ global $session_expired_post, $session_expired;
+ /*
+ * extra check for username so we don't display previous post data from
+ * another user during this session.
+ */
+ if ($session_expired_post['username'] != $username) {
+ session_unregister('session_expired_post');
+ session_unregister('session_expired');
+ } else {
+ foreach ($session_expired_post as $postvar => $val) {
+ if (isset($val)) {
+ $$postvar = $val;
+ } else {
+ $$postvar = '';
+ }
+ }
+ if (isset($send)) {
+ unset($send);
+ }
+ $session_expired = true;
+ }
+ session_unregister('session_expired_post');
+ session_unregister('session_expired');
+ if (!isset($mailbox)) {
+ $mailbox = '';
+ }
+ if ($compose_new_win == '1') {
+ compose_Header($color, $mailbox);
+ } else {
+ displayPageHeader($color, $mailbox);
+ }
+ showInputForm($session, false);
+ exit();
+}