6 * Copyright (c) 1999-2003 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 ( ( function_exists('array_key_exists') && /* PHP >= 4.1 */
44 !array_key_exists($cmd, $fieldsdescr) ) ||
45 ( function_exists('key_exists') &&
46 !key_exists($cmd, $fieldsdescr) ) /* PHP == 4.0.6 */
51 /* proto = {mailto,href} */
52 $proto = array_shift(array_keys($actions));
53 $act = array_shift($actions);
55 if ($proto == 'mailto') {
57 if (($cmd == 'post') ||
($cmd == 'owner')) {
58 $url = 'compose.php?';
60 $url = "../plugins/listcommands/mailout.php?action=$cmd&";
62 $url .= 'send_to=' . strtr($act,'?','&');
64 if ($compose_new_win == '1') {
65 $output[] = "<a href=\"javascript:void(0)\" onclick=\"comp_in_new('$url')\">" . $fieldsdescr[$cmd] . '</a>';
68 $output[] = '<a href="' . $url . '">' . $fieldsdescr[$cmd] . '</a>';
71 $url .= '&passed_id='.$passed_id.
72 '&mailbox='.urlencode($mailbox).
73 (isset($passed_ent_id)?
'&passed_ent_id='.$passed_ent_id:'');
74 $url .= '&action=reply';
75 if ($compose_new_win == '1') {
76 $output[] = "<a href=\"javascript:void(0)\" onclick=\"comp_in_new('$url')\">" . $fieldsdescr['reply'] . '</a>';
78 $output[] = '<a href="' . $url . '">' . $fieldsdescr['reply'] . '</a>';
81 } else if ($proto == 'href') {
82 $output[] = '<a href="' . $act . '" target="_blank">'
83 . $fieldsdescr[$cmd] . '</a>';
87 if (count($output) > 0) {
89 echo html_tag('td', '<b>' . _("Mailing List") . ': </b>',
90 'right', '', 'valign="middle" width="20%"') . "\n";
91 echo html_tag('td', '<small>' . implode(' | ', $output) . '</small>',
92 'left', $color[0], 'valign="middle" width="80%"') . "\n";