displayPageHeader($color, $mailbox); switch ($action) { case 'help': $out_string = _("This will send a message to %s requesting help for this list. You will receive an emailed response at the address below."); break; case 'subscribe': $out_string = _("This will send a message to %s requesting that you will be subscribed to this list. You will be subscribed with the address below."); break; case 'unsubscribe': $out_string = _("This will send a message to %s requesting that you will be unsubscribed from this list. It will try to unsubscribe the adress below."); break; default: error_box(sprintf(_("Unknown action: %s"), sm_encode_html_special_chars($action))); // display footer (closes html tags) and stop script execution $oTemplate->display('footer.tpl'); exit; } $out_string = sprintf($out_string, '"' . sm_encode_html_special_chars($send_to) . '"'); $idents = get_identities(); $fieldsdescr = listcommands_fieldsdescr(); $fielddescr = $fieldsdescr[$action]; $oTemplate->assign('out_string', $out_string); $oTemplate->assign('fielddescr', $fielddescr); $oTemplate->assign('send_to', $send_to); $oTemplate->assign('subject', $subject); $oTemplate->assign('body', $body); $oTemplate->assign('mailbox', $mailbox); $oTemplate->assign('idents', $idents); $oTemplate->assign('identity', $identity); $oTemplate->display('plugins/listcommands/mailout.tpl'); $oTemplate->display('footer.tpl');
/** * 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 . '&' : ''); } else { $url = "plugins/listcommands/mailout.php?action={$cmd}&"; // 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 = '&identity=' . $identity . '&' . $parameters; } else { $parameters = '&identity=' . $identity; } $url .= 'send_to=' . urlencode($act) . $parameters; $links[$cmd] = makeComposeLink($url, $fieldsdescr[$cmd]); if ($cmd == 'post') { if (!isset($mailbox)) { $mailbox = 'INBOX'; } $url .= '&passed_id=' . $passed_id . '&mailbox=' . urlencode($mailbox) . (isset($passed_ent_id) ? '&passed_ent_id=' . $passed_ent_id : ''); $url .= '&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 . '&' : '') . 'send_to=' . str_replace('?', '&', $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 . '&' : '') . 'send_to=' . str_replace('?', '&', $non_rfc_list) . '&passed_id=' . $passed_id . '&mailbox=' . urlencode($mailbox) . (isset($passed_ent_id) ? '&passed_ent_id=' . $passed_ent_id : '') . '&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); } }