73ee43b1 |
1 | <?php |
519f07d7 |
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. |
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 | |
17 | function 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 |
23 | function plugin_listcommands_menu() { |
83feb57a |
24 | global $passed_id, $passed_ent_id, $color, $mailbox, |
25 | $message, $compose_new_win; |
73ee43b1 |
26 | |
d54c9a9c |
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. |
73ee43b1 |
30 | */ |
83feb57a |
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")); |
ff5d0719 |
38 | $output = array(); |
83feb57a |
39 | |
40 | foreach ($message->rfc822_header->mlist as $cmd => $actions) { |
41 | |
42 | /* I don't know this action... skip it */ |
43 | if(!array_key_exists($cmd, $fieldsdescr)) { |
44 | continue; |
d54c9a9c |
45 | } |
d54c9a9c |
46 | |
83feb57a |
47 | /* proto = {mailto,href} */ |
48 | $proto = array_shift(array_keys($actions)); |
49 | $act = array_shift($actions); |
73ee43b1 |
50 | |
83feb57a |
51 | if ($proto == 'mailto') { |
050722c4 |
52 | |
83feb57a |
53 | if (($cmd == 'post') || ($cmd == 'owner')) { |
73ee43b1 |
54 | $url = 'compose.php?'; |
050722c4 |
55 | } else { |
f6f50b4d |
56 | $url = "../plugins/listcommands/mailout.php?action=$cmd&"; |
73ee43b1 |
57 | } |
83feb57a |
58 | $url .= 'send_to=' . strtr($act,'?','&'); |
050722c4 |
59 | |
9c3e6cd4 |
60 | if ($compose_new_win == '1') { |
d6ba3a2d |
61 | $output[] = "<a href=\"javascript:void(0)\" onclick=\"comp_in_new('$url')\">" . $fieldsdescr[$cmd] . '</A>'; |
9c3e6cd4 |
62 | } |
63 | else { |
64 | $output[] = '<A HREF="' . $url . '">' . $fieldsdescr[$cmd] . '</A>'; |
65 | } |
83feb57a |
66 | if ($cmd == 'post') { |
d6ba3a2d |
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'; |
91e33f2c |
71 | if ($compose_new_win == '1') { |
83feb57a |
72 | $output[] = "<A HREF=\"javascript:void(0)\" onClick=\"comp_in_new('$url')\">" . $fieldsdescr['reply'] . '</A>'; |
91e33f2c |
73 | } |
74 | else { |
83feb57a |
75 | $output[] = '<A HREF="' . $url . '">' . $fieldsdescr['reply'] . '</A>'; |
91e33f2c |
76 | } |
9c3e6cd4 |
77 | } |
83feb57a |
78 | } elseif ($proto == 'href') { |
79 | $output[] = '<A HREF="' . $act . '" TARGET="_blank">' |
d54c9a9c |
80 | . $fieldsdescr[$cmd] . '</A>'; |
73ee43b1 |
81 | } |
73ee43b1 |
82 | } |
83 | |
73ee43b1 |
84 | if (count($output) > 0) { |
d6ba3a2d |
85 | echo '<table width="100%" cellpadding="3" cellspacing="0" align="center"'. |
86 | ' border="0" bgcolor="'.$color[0].'">'. "\n"; |
87 | echo '<tr>'; |
88 | echo html_tag( 'td', '<b>'._("Mailing List").': </b>', 'right', $color[0], 'valign="top" width="20%"') . "\n"; |
89 | echo html_tag( 'td', |
90 | '<small>' . implode(' | ', $output) . '</small>', 'left', $color[0], 'valign="top" width="80%"'); |
91 | echo "\n</tr>"; |
92 | echo '</table>'."\n"; |
73ee43b1 |
93 | } |
050722c4 |
94 | } |
d54c9a9c |
95 | |
96 | ?> |