6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Implementation of RFC 2369 for SquirrelMail.
10 * When viewing a message from a mailinglist complying with this RFC,
11 * this plugin displays a menu which gives the user a choice of mailinglist
12 * commands such as (un)subscribe, help and list archives.
17 function squirrelmail_plugin_init_listcommands () {
18 global $squirrelmail_plugin_hooks;
20 $squirrelmail_plugin_hooks['read_body_header']['listcommands'] = 'plugin_listcommands_menu';
23 function plugin_listcommands_menu() {
24 global $passed_id, $passed_ent_id, $color, $mailbox,
25 $message, $compose_new_win;
28 * Array of commands we can deal with from the header. The Reply option
29 * is added later because we generate it using the Post information.
31 $fieldsdescr = array('post' => _("Post to List"),
32 'reply' => _("Reply to List"),
33 'subscribe' => _("Subscribe"),
34 'unsubscribe' => _("Unsubscribe"),
35 'archive' => _("List Archives"),
36 'owner' => _("Contact Listowner"),
40 foreach ($message->rfc822_header
->mlist
as $cmd => $actions) {
42 /* I don't know this action... skip it */
43 if(!array_key_exists($cmd, $fieldsdescr)) {
47 /* proto = {mailto,href} */
48 $proto = array_shift(array_keys($actions));
49 $act = array_shift($actions);
51 if ($proto == 'mailto') {
53 if (($cmd == 'post') ||
($cmd == 'owner')) {
54 $url = 'compose.php?';
56 $url = "../plugins/listcommands/mailout.php?action=$cmd&";
58 $url .= 'send_to=' . strtr($act,'?','&');
60 if ($compose_new_win == '1') {
61 $output[] = "<a href=\"javascript:void(0)\" onclick=\"comp_in_new('$url')\">" . $fieldsdescr[$cmd] . '</A>';
64 $output[] = '<A HREF="' . $url . '">' . $fieldsdescr[$cmd] . '</A>';
67 $url .= '&passed_id='.$passed_id.
68 '&mailbox='.urlencode($mailbox).
69 (isset($passed_ent_id)?
'&passed_ent_id='.$passed_ent_id:'');
70 $url .= '&action=reply';
71 if ($compose_new_win == '1') {
72 $output[] = "<A HREF=\"javascript:void(0)\" onClick=\"comp_in_new('$url')\">" . $fieldsdescr['reply'] . '</A>';
74 $output[] = '<A HREF="' . $url . '">' . $fieldsdescr['reply'] . '</A>';
77 } else if ($proto == 'href') {
78 $output[] = '<A HREF="' . $act . '" TARGET="_blank">'
79 . $fieldsdescr[$cmd] . '</A>';
83 if (count($output) > 0) {
85 echo html_tag('TD', '<B>' . _("Mailing List") . ': </B>',
86 'right', '', 'VALIGN="MIDDLE" WIDTH="20%"') . "\n";
87 echo html_tag('TD', '<SMALL>' . implode(' | ', $output) . '</small>',
88 'left', $color[0], 'VALIGN="MIDDLE" WIDTH="80%"') . "\n";