8d816a8de301d0f9bd0a0736e9660c3462aa5d24
6 * Copyright (c) 1999-2004 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.
16 * @subpackage listcommands
20 * Initialize the listcommands plugin
22 function squirrelmail_plugin_init_listcommands () {
23 global $squirrelmail_plugin_hooks;
25 $squirrelmail_plugin_hooks['read_body_header']['listcommands'] = 'plugin_listcommands_menu';
28 function plugin_listcommands_menu() {
29 global $passed_id, $passed_ent_id, $color, $mailbox, $message;
32 * Array of commands we can deal with from the header. The Reply option
33 * is added later because we generate it using the Post information.
35 $fieldsdescr = array('post' => _("Post to List"),
36 'reply' => _("Reply to List"),
37 'subscribe' => _("Subscribe"),
38 'unsubscribe' => _("Unsubscribe"),
39 'archive' => _("List Archives"),
40 'owner' => _("Contact Listowner"),
44 foreach ($message->rfc822_header
->mlist
as $cmd => $actions) {
46 /* I don't know this action... skip it */
47 if ( ( function_exists('array_key_exists') && /* PHP >= 4.1 */
48 !array_key_exists($cmd, $fieldsdescr) ) ||
49 ( function_exists('key_exists') &&
50 !key_exists($cmd, $fieldsdescr) ) /* PHP == 4.0.6 */
55 /* proto = {mailto,href} */
56 $proto = array_shift(array_keys($actions));
57 $act = array_shift($actions);
59 if ($proto == 'mailto') {
61 if (($cmd == 'post') ||
($cmd == 'owner')) {
62 $url = 'src/compose.php?';
64 $url = "plugins/listcommands/mailout.php?action=$cmd&";
66 $url .= 'send_to=' . strtr($act,'?','&');
68 $output[] = makeComposeLink($url, $fieldsdescr[$cmd]);
73 $url .= '&passed_id='.$passed_id.
74 '&mailbox='.urlencode($mailbox).
75 (isset($passed_ent_id)?
'&passed_ent_id='.$passed_ent_id:'');
76 $url .= '&smaction=reply';
78 $output[] = makeComposeLink($url, $fieldsdescr['reply']);
80 } else if ($proto == 'href') {
81 $output[] = '<a href="' . $act . '" target="_blank">'
82 . $fieldsdescr[$cmd] . '</a>';
86 if (count($output) > 0) {
88 echo html_tag('td', '<b>' . _("Mailing List") . ': </b>',
89 'right', '', 'valign="middle" width="20%"') . "\n";
90 echo html_tag('td', '<small>' . implode(' | ', $output) . '</small>',
91 'left', $color[0], 'valign="middle" width="80%"') . "\n";