A small start in making Sqm XHTML 1.0 valid
[squirrelmail.git] / plugins / listcommands / setup.php
1 <?php
2
3 /**
4 * setup.php
5 *
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
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 *
14 * $Id$
15 */
16
17 function squirrelmail_plugin_init_listcommands () {
18 global $squirrelmail_plugin_hooks;
19
20 $squirrelmail_plugin_hooks['read_body_header']['listcommands'] = 'plugin_listcommands_menu';
21 }
22
23 function plugin_listcommands_menu() {
24 global $passed_id, $passed_ent_id, $color, $mailbox,
25 $message, $compose_new_win;
26
27 /**
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.
30 */
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"),
37 'help' => _("Help"));
38 $output = array();
39
40 foreach ($message->rfc822_header->mlist as $cmd => $actions) {
41
42 /* I don't know this action... skip it */
43 /* grrr PHP keeps changing their syntax... */
44 if( function_exists('array_key_exists') ) {
45 if(!array_key_exists($cmd, $fieldsdescr)) {
46 continue;
47 }
48 } elseif ( !key_exists($cmd, $fieldsdescr) ) {
49 continue;
50 }
51
52 /* proto = {mailto,href} */
53 $proto = array_shift(array_keys($actions));
54 $act = array_shift($actions);
55
56 if ($proto == 'mailto') {
57
58 if (($cmd == 'post') || ($cmd == 'owner')) {
59 $url = 'compose.php?';
60 } else {
61 $url = "../plugins/listcommands/mailout.php?action=$cmd&amp;";
62 }
63 $url .= 'send_to=' . strtr($act,'?','&');
64
65 if ($compose_new_win == '1') {
66 $output[] = "<a href=\"javascript:void(0)\" onclick=\"comp_in_new('$url')\">" . $fieldsdescr[$cmd] . '</A>';
67 }
68 else {
69 $output[] = '<A HREF="' . $url . '">' . $fieldsdescr[$cmd] . '</A>';
70 }
71 if ($cmd == 'post') {
72 $url .= '&amp;passed_id='.$passed_id.
73 '&amp;mailbox='.urlencode($mailbox).
74 (isset($passed_ent_id)?'&amp;passed_ent_id='.$passed_ent_id:'');
75 $url .= '&amp;action=reply';
76 if ($compose_new_win == '1') {
77 $output[] = "<A HREF=\"javascript:void(0)\" onClick=\"comp_in_new('$url')\">" . $fieldsdescr['reply'] . '</A>';
78 } else {
79 $output[] = '<A HREF="' . $url . '">' . $fieldsdescr['reply'] . '</A>';
80 }
81 }
82 } else if ($proto == 'href') {
83 $output[] = '<A HREF="' . $act . '" TARGET="_blank">'
84 . $fieldsdescr[$cmd] . '</A>';
85 }
86 }
87
88 if (count($output) > 0) {
89 echo '<TR>';
90 echo html_tag('TD', '<B>' . _("Mailing List") . ':&nbsp;&nbsp;</B>',
91 'right', '', 'VALIGN="MIDDLE" WIDTH="20%"') . "\n";
92 echo html_tag('TD', '<SMALL>' . implode('&nbsp;|&nbsp;', $output) . '</small>',
93 'left', $color[0], 'VALIGN="MIDDLE" WIDTH="80%"') . "\n";
94 echo "</TR>";
95 }
96 }
97
98 ?>