Make listcommands plugin work again w.r.t. smaction
[squirrelmail.git] / plugins / listcommands / setup.php
CommitLineData
73ee43b1 1<?php
519f07d7 2
3/**
4 * setup.php
5 *
76911253 6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
519f07d7 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
73ee43b1 8 *
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.
13 *
519f07d7 14 * $Id$
73ee43b1 15 */
519f07d7 16
17function squirrelmail_plugin_init_listcommands () {
73ee43b1 18 global $squirrelmail_plugin_hooks;
19
20 $squirrelmail_plugin_hooks['read_body_header']['listcommands'] = 'plugin_listcommands_menu';
21}
22
d54c9a9c 23function plugin_listcommands_menu() {
d62c4938 24 global $passed_id, $passed_ent_id, $color, $mailbox, $message;
73ee43b1 25
d54c9a9c 26 /**
27 * Array of commands we can deal with from the header. The Reply option
28 * is added later because we generate it using the Post information.
73ee43b1 29 */
83feb57a 30 $fieldsdescr = array('post' => _("Post to List"),
31 'reply' => _("Reply to List"),
32 'subscribe' => _("Subscribe"),
33 'unsubscribe' => _("Unsubscribe"),
34 'archive' => _("List Archives"),
35 'owner' => _("Contact Listowner"),
36 'help' => _("Help"));
ff5d0719 37 $output = array();
83feb57a 38
39 foreach ($message->rfc822_header->mlist as $cmd => $actions) {
40
41 /* I don't know this action... skip it */
b1784aaf 42 if ( ( function_exists('array_key_exists') && /* PHP >= 4.1 */
43 !array_key_exists($cmd, $fieldsdescr) ) ||
8f41ffa2 44 ( function_exists('key_exists') &&
45 !key_exists($cmd, $fieldsdescr) ) /* PHP == 4.0.6 */
b1784aaf 46 ) {
83feb57a 47 continue;
d54c9a9c 48 }
d54c9a9c 49
83feb57a 50 /* proto = {mailto,href} */
51 $proto = array_shift(array_keys($actions));
52 $act = array_shift($actions);
73ee43b1 53
83feb57a 54 if ($proto == 'mailto') {
050722c4 55
83feb57a 56 if (($cmd == 'post') || ($cmd == 'owner')) {
d62c4938 57 $url = 'src/compose.php?';
050722c4 58 } else {
d62c4938 59 $url = "plugins/listcommands/mailout.php?action=$cmd&amp;";
73ee43b1 60 }
83feb57a 61 $url .= 'send_to=' . strtr($act,'?','&');
050722c4 62
d62c4938 63 $output[] = makeComposeLink($url, $fieldsdescr[$cmd]);
64
83feb57a 65 if ($cmd == 'post') {
d6ba3a2d 66 $url .= '&amp;passed_id='.$passed_id.
67 '&amp;mailbox='.urlencode($mailbox).
68 (isset($passed_ent_id)?'&amp;passed_ent_id='.$passed_ent_id:'');
84d12179 69 $url .= '&amp;smaction=reply';
d62c4938 70
71 $output[] = makeComposeLink($url, $fieldsdescr['reply']);
9c3e6cd4 72 }
9feb4369 73 } else if ($proto == 'href') {
b1379bdf 74 $output[] = '<a href="' . $act . '" target="_blank">'
75 . $fieldsdescr[$cmd] . '</a>';
73ee43b1 76 }
73ee43b1 77 }
78
73ee43b1 79 if (count($output) > 0) {
b1379bdf 80 echo '<tr>';
81 echo html_tag('td', '<b>' . _("Mailing List") . ':&nbsp;&nbsp;</b>',
82 'right', '', 'valign="middle" width="20%"') . "\n";
83 echo html_tag('td', '<small>' . implode('&nbsp;|&nbsp;', $output) . '</small>',
84 'left', $color[0], 'valign="middle" width="80%"') . "\n";
85 echo '</tr>';
73ee43b1 86 }
050722c4 87}
d54c9a9c 88
89?>