コード例 #1
0
ファイル: read_body.php プロジェクト: jprice/EHCP
function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee)
{
    global $default_use_mdn, $default_use_priority, $show_xmailer_default, $mdn_user_support, $PHP_SELF, $javascript_on, $squirrelmail_language;
    $header = $message->rfc822_header;
    $env = array();
    $env[_("Subject")] = decodeHeader($header->subject);
    $from_name = $header->getAddr_s('from');
    if (!$from_name) {
        $from_name = $header->getAddr_s('sender');
        if (!$from_name) {
            $from_name = _("Unknown sender");
        }
    }
    $env[_("From")] = decodeHeader($from_name);
    $env[_("Date")] = getLongDateString($header->date, $header->date_unparsed);
    $env[_("To")] = formatRecipientString($header->to, "to");
    $env[_("Cc")] = formatRecipientString($header->cc, "cc");
    $env[_("Bcc")] = formatRecipientString($header->bcc, "bcc");
    if ($default_use_priority) {
        $env[_("Priority")] = htmlspecialchars(getPriorityStr($header->priority));
    }
    if ($show_xmailer_default) {
        $env[_("Mailer")] = decodeHeader($header->xmailer);
    }
    if ($default_use_mdn) {
        if ($mdn_user_support) {
            if ($header->dnt) {
                if ($message->is_mdnsent) {
                    $env[_("Read receipt")] = _("sent");
                } else {
                    $env[_("Read receipt")] = _("requested");
                    if (!(handleAsSent($mailbox) || $message->is_deleted || $passed_ent_id)) {
                        $mdn_url = $PHP_SELF;
                        $mdn_url = set_url_var($mdn_url, 'mailbox', urlencode($mailbox));
                        $mdn_url = set_url_var($mdn_url, 'passed_id', $passed_id);
                        $mdn_url = set_url_var($mdn_url, 'passed_ent_id', $passed_ent_id);
                        $mdn_url = set_url_var($mdn_url, 'sendreceipt', 1);
                        if ($FirstTimeSee && $javascript_on) {
                            $script = '<script language="JavaScript" type="text/javascript">' . "\n";
                            $script .= '<!--' . "\n";
                            $script .= 'if(window.confirm("' . _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") . '")) {  ' . "\n" . '    sendMDN()' . '}' . "\n";
                            $script .= '// -->' . "\n";
                            $script .= '</script>' . "\n";
                            echo $script;
                        }
                        $env[_("Read receipt")] .= '&nbsp;<a href="' . $mdn_url . '">[' . _("Send read receipt now") . ']</a>';
                    }
                }
            }
        }
    }
    $s = '<table width="100%" cellpadding="0" cellspacing="2" border="0"';
    $s .= ' align="center" bgcolor="' . $color[0] . '">';
    foreach ($env as $key => $val) {
        if ($val) {
            $s .= '<tr>';
            $s .= html_tag('td', '<b>' . $key . ':&nbsp;&nbsp;</b>', 'right', '', 'valign="top" width="20%"') . "\n";
            $s .= html_tag('td', $val, 'left', '', 'valign="top" width="80%"') . "\n";
            $s .= '</tr>';
        }
    }
    echo '<table bgcolor="' . $color[9] . '" width="100%" cellpadding="1"' . ' cellspacing="0" border="0" align="center">' . "\n";
    echo '<tr><td height="5" colspan="2" bgcolor="' . $color[4] . '"></td></tr><tr><td align="center">' . "\n";
    echo $s;
    do_hook('read_body_header');
    formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color);
    echo '</table>';
    echo '</td></tr><tr><td height="5" colspan="2" bgcolor="' . $color[4] . '"></td></tr>' . "\n";
    echo '</table>';
}
コード例 #2
0
ファイル: functions.php プロジェクト: teammember8/roundcube
/**
 * internal function that builds mailing list links
 */
function plugin_listcommands_menu_do()
{
    global $passed_id, $passed_ent_id, $mailbox, $message, $startMessage, $oTemplate, $listcommands_allow_non_rfc_list_management;
    @(include_once SM_PATH . 'plugins/listcommands/config.php');
    /**
     * Array of commands we can deal with from the header. The Reply option
     * is added later because we generate it using the Post information.
     */
    $fieldsdescr = listcommands_fieldsdescr();
    $links = array();
    foreach ($message->rfc822_header->mlist as $cmd => $actions) {
        /* I don't know this action... skip it */
        if (!array_key_exists($cmd, $fieldsdescr)) {
            continue;
        }
        /* proto = {mailto,href} */
        $aActions = array_keys($actions);
        // note that we only use the first cmd/action, ignore the rest
        $proto = array_shift($aActions);
        $act = array_shift($actions);
        if ($proto == 'mailto') {
            $identity = '';
            if ($cmd == 'post' || $cmd == 'owner') {
                $url = 'src/compose.php?' . (isset($startMessage) ? 'startMessage=' . $startMessage . '&amp;' : '');
            } else {
                $url = "plugins/listcommands/mailout.php?action={$cmd}&amp;";
                // try to find which identity the mail should come from
                include_once SM_PATH . 'functions/identity.php';
                $idents = get_identities();
                // ripped from src/compose.php
                $identities = array();
                if (count($idents) > 1) {
                    foreach ($idents as $nr => $data) {
                        $enc_from_name = '"' . $data['full_name'] . '" <' . $data['email_address'] . '>';
                        $identities[] = $enc_from_name;
                    }
                    $identity_match = $message->rfc822_header->findAddress($identities);
                    if ($identity_match !== FALSE) {
                        $identity = $identity_match;
                    }
                }
            }
            // if things like subject are given, peel them off and give
            // them to src/compose.php as is (not encoded)
            if (strpos($act, '?') > 0) {
                list($act, $parameters) = explode('?', $act, 2);
                $parameters = '&amp;identity=' . $identity . '&amp;' . $parameters;
            } else {
                $parameters = '&amp;identity=' . $identity;
            }
            $url .= 'send_to=' . urlencode($act) . $parameters;
            $links[$cmd] = makeComposeLink($url, $fieldsdescr[$cmd]);
            if ($cmd == 'post') {
                if (!isset($mailbox)) {
                    $mailbox = 'INBOX';
                }
                $url .= '&amp;passed_id=' . $passed_id . '&amp;mailbox=' . urlencode($mailbox) . (isset($passed_ent_id) ? '&amp;passed_ent_id=' . $passed_ent_id : '');
                $url .= '&amp;smaction=reply';
                $links['reply'] = makeComposeLink($url, $fieldsdescr['reply']);
            }
        } else {
            if ($proto == 'href') {
                $links[$cmd] = create_hyperlink($act, $fieldsdescr[$cmd], '_blank');
            }
        }
    }
    // allow non-rfc reply link if admin allows and message is from
    // non-rfc list the user has configured
    //
    if ($listcommands_allow_non_rfc_list_management) {
        $non_rfc_lists = get_non_rfc_lists();
        $recipients = formatRecipientString($message->rfc822_header->to, "to") . ' ' . formatRecipientString($message->rfc822_header->cc, "cc") . ' ' . formatRecipientString($message->rfc822_header->bcc, "bcc");
        if (!in_array('post', array_keys($links))) {
            foreach ($non_rfc_lists as $non_rfc_list) {
                if (preg_match('/(^|,|<|\\s)' . preg_quote($non_rfc_list) . '($|,|>|\\s)/', $recipients)) {
                    $url = 'src/compose.php?' . (isset($startMessage) ? 'startMessage=' . $startMessage . '&amp;' : '') . 'send_to=' . str_replace('?', '&amp;', $non_rfc_list);
                    $links['post'] = makeComposeLink($url, $fieldsdescr['post']);
                    break;
                }
            }
        }
        if (!in_array('reply', array_keys($links))) {
            foreach ($non_rfc_lists as $non_rfc_list) {
                if (preg_match('/(^|,|\\s)' . preg_quote($non_rfc_list) . '($|,|\\s)/', $recipients)) {
                    if (!isset($mailbox)) {
                        $mailbox = 'INBOX';
                    }
                    $url = 'src/compose.php?' . (isset($startMessage) ? 'startMessage=' . $startMessage . '&amp;' : '') . 'send_to=' . str_replace('?', '&amp;', $non_rfc_list) . '&amp;passed_id=' . $passed_id . '&amp;mailbox=' . urlencode($mailbox) . (isset($passed_ent_id) ? '&amp;passed_ent_id=' . $passed_ent_id : '') . '&amp;smaction=reply';
                    $links['reply'] = makeComposeLink($url, $fieldsdescr['reply']);
                    break;
                }
            }
        }
    }
    if (count($links) > 0) {
        $oTemplate->assign('links', $links);
        $output = $oTemplate->fetch('plugins/listcommands/read_body_header.tpl');
        return array('read_body_header' => $output);
    }
}
コード例 #3
0
function obm_formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee)
{
    global $msn_user_support, $default_use_mdn, $default_use_priority, $show_xmailer_default, $mdn_user_support, $PHP_SELF, $javascript_on, $squirrelmail_language;
    $mailbox = $aMailbox['NAME'];
    $header = $message->rfc822_header;
    $env = array();
    $env[_("Subject")] = str_replace("&nbsp;", " ", decodeHeader($header->subject));
    $from_name = $header->getAddr_s('from');
    if (!$from_name) {
        $from_name = $header->getAddr_s('sender');
    }
    if (!$from_name) {
        $env[_("From")] = _("Unknown sender");
    } else {
        $env[_("From")] = decodeHeader($from_name);
    }
    $env[_("Date")] = getLongDateString($header->date);
    $env[_("To")] = formatRecipientString($header->to, "to");
    $env[_("Cc")] = formatRecipientString($header->cc, "cc");
    $env[_("Bcc")] = formatRecipientString($header->bcc, "bcc");
    if ($default_use_priority) {
        $env[_("Priority")] = htmlspecialchars(getPriorityStr($header->priority));
    }
    if ($show_xmailer_default) {
        $env[_("Mailer")] = decodeHeader($header->xmailer);
    }
    $s = '<table width="100%" cellpadding="0" cellspacing="2" border="0"';
    $s .= ' align="center" bgcolor="' . $color[0] . '">';
    foreach ($env as $key => $val) {
        if ($val) {
            $s .= '<tr>';
            $s .= html_tag('td', '<b>' . $key . ':&nbsp;&nbsp;</b>', 'right', '', 'valign="top" width="0%"') . "\n";
            $s .= html_tag('td', $val, 'left', '', 'valign="top" width="100%"') . "\n";
            $s .= '</tr>';
        }
    }
    echo '<table bgcolor="' . $color[9] . '" width="100%" cellpadding="1"' . ' cellspacing="0" border="0" align="center">' . "\n";
    echo '<tr><td height="5" colspan="2" bgcolor="' . $color[4] . '"></td></tr><tr><td align="center">' . "\n";
    echo $s;
    //do_hook('read_body_header');
    //formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color);
    echo '</table>';
    echo '</td></tr><tr><td height="5" colspan="2" bgcolor="' . $color[4] . '"></td></tr>' . "\n";
    echo '</table>';
}
コード例 #4
0
ファイル: read_body.php プロジェクト: teammember8/roundcube
function formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee)
{
    global $default_use_mdn, $default_use_priority, $show_xmailer_default, $mdn_user_support, $PHP_SELF, $squirrelmail_language, $oTemplate;
    $mailbox = $aMailbox['NAME'];
    $header = $message->rfc822_header;
    $env = array();
    $env[_("Subject")] = str_replace("&nbsp;", " ", decodeHeader($header->subject));
    $from_name = $header->getAddr_s('from');
    if (!$from_name) {
        $from_name = $header->getAddr_s('sender');
    }
    if (!$from_name) {
        $env[_("From")] = _("Unknown sender");
    } else {
        $env[_("From")] = decodeHeader($from_name);
    }
    $env[_("Date")] = getLongDateString($header->date, $header->date_unparsed);
    $env[_("To")] = formatRecipientString($header->to, "to");
    $env[_("Cc")] = formatRecipientString($header->cc, "cc");
    $env[_("Bcc")] = formatRecipientString($header->bcc, "bcc");
    if ($default_use_priority) {
        $oTemplate->assign('message_priority', $header->priority);
        $env[_("Priority")] = $oTemplate->fetch('read_message_priority.tpl');
    }
    if ($show_xmailer_default) {
        $oTemplate->assign('xmailer', decodeHeader($header->xmailer));
        $env[_("Mailer")] = $oTemplate->fetch('read_xmailer.tpl');
    }
    // this is used for both mdn and also general use for plugins, etc
    $oTemplate->assign('first_time_reading', $FirstTimeSee);
    if ($default_use_mdn) {
        if ($mdn_user_support) {
            if ($header->dnt) {
                $mdn_url = $PHP_SELF;
                $mdn_url = set_url_var($mdn_url, 'mailbox', urlencode($mailbox));
                $mdn_url = set_url_var($mdn_url, 'passed_id', $passed_id);
                $mdn_url = set_url_var($mdn_url, 'passed_ent_id', $passed_ent_id);
                $mdn_url = set_url_var($mdn_url, 'sendreceipt', 1);
                $oTemplate->assign('read_receipt_sent', $message->is_mdnsent);
                $oTemplate->assign('send_receipt_href', $mdn_url);
                $env[_("Read Receipt")] = $oTemplate->fetch('read_handle_receipt.tpl');
            }
        }
    }
    $statuses = array();
    if (isset($aMailbox['MSG_HEADERS'][$passed_id]['FLAGS'])) {
        if (isset($aMailbox['MSG_HEADERS'][$passed_id]['FLAGS']['\\deleted']) && $aMailbox['MSG_HEADERS'][$passed_id]['FLAGS']['\\deleted'] === true) {
            $statuses[] = _("deleted");
        }
        if (isset($aMailbox['MSG_HEADERS'][$passed_id]['FLAGS']['\\answered']) && $aMailbox['MSG_HEADERS'][$passed_id]['FLAGS']['\\answered'] === true) {
            $statuses[] = _("answered");
        }
        if (isset($aMailbox['MSG_HEADERS'][$passed_id]['FLAGS']['\\draft']) && $aMailbox['MSG_HEADERS'][$passed_id]['FLAGS']['\\draft'] === true) {
            $statuses[] = _("draft");
        }
        if (isset($aMailbox['MSG_HEADERS'][$passed_id]['FLAGS']['\\flagged']) && $aMailbox['MSG_HEADERS'][$passed_id]['FLAGS']['\\flagged'] === true) {
            $statuses[] = _("flagged");
        }
        if (count($statuses)) {
            $env[_("Status")] = implode(', ', $statuses);
        }
    }
    $env[_("Options")] = formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color);
    $oTemplate->assign('headers_to_display', $env);
    $oTemplate->display('read_headers.tpl');
}