793566f0 |
1 | <?php |
2 | |
3 | /** |
4 | * functions.php |
5 | * |
6 | * Copyright (c) 1999-2005 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 | * @version $Id$ |
15 | * @package plugins |
16 | * @subpackage listcommands |
17 | */ |
18 | |
19 | function plugin_listcommands_menu_do() { |
20 | global $passed_id, $passed_ent_id, $color, $mailbox, $message, $startMessage; |
21 | |
22 | /** |
23 | * Array of commands we can deal with from the header. The Reply option |
24 | * is added later because we generate it using the Post information. |
25 | */ |
26 | $fieldsdescr = listcommands_fieldsdescr(); |
27 | $output = array(); |
28 | |
29 | foreach ($message->rfc822_header->mlist as $cmd => $actions) { |
30 | |
31 | /* I don't know this action... skip it */ |
32 | if ( !array_key_exists($cmd, $fieldsdescr) ) { |
33 | continue; |
34 | } |
35 | |
36 | /* proto = {mailto,href} */ |
37 | $proto = array_shift(array_keys($actions)); |
38 | $act = array_shift($actions); |
39 | |
40 | if ($proto == 'mailto') { |
41 | |
42 | if (($cmd == 'post') || ($cmd == 'owner')) { |
43 | $url = 'src/compose.php?'. |
44 | (isset($startMessage)?'startMessage='.$startMessage.'&':''); |
45 | } else { |
46 | $url = "plugins/listcommands/mailout.php?action=$cmd&"; |
47 | } |
a74103dd |
48 | $url .= 'send_to=' . str_replace('?','&', $act); |
793566f0 |
49 | |
50 | $output[] = makeComposeLink($url, $fieldsdescr[$cmd]); |
51 | |
52 | if ($cmd == 'post') { |
53 | if (!isset($mailbox)) |
54 | $mailbox = 'INBOX'; |
55 | $url .= '&passed_id='.$passed_id. |
56 | '&mailbox='.urlencode($mailbox). |
57 | (isset($passed_ent_id)?'&passed_ent_id='.$passed_ent_id:''); |
58 | $url .= '&smaction=reply'; |
59 | |
60 | $output[] = makeComposeLink($url, $fieldsdescr['reply']); |
61 | } |
62 | } else if ($proto == 'href') { |
63 | $output[] = '<a href="' . $act . '" target="_blank">' |
64 | . $fieldsdescr[$cmd] . '</a>'; |
65 | } |
66 | } |
67 | |
68 | if (count($output) > 0) { |
69 | echo '<tr>' . |
70 | html_tag('td', '<b>' . _("Mailing List") . ': </b>', |
71 | 'right', '', 'valign="middle" width="20%"') . "\n" . |
72 | html_tag('td', '<small>' . implode(' | ', $output) . '</small>', |
73 | 'left', $color[0], 'valign="middle" width="80%"') . "\n" . |
74 | '</tr>'; |
75 | } |
76 | } |
77 | |
78 | /** |
79 | * Returns an array with the actions as translated strings. |
80 | * @return array action as key, translated string as value |
81 | */ |
82 | function listcommands_fieldsdescr() { |
83 | return array('post' => _("Post to List"), |
84 | 'reply' => _("Reply to List"), |
85 | 'subscribe' => _("Subscribe"), |
86 | 'unsubscribe' => _("Unsubscribe"), |
87 | 'archive' => _("List Archives"), |
88 | 'owner' => _("Contact Listowner"), |
89 | 'help' => _("Help")); |
90 | } |
91 | |
a74103dd |
92 | ?> |