6 * Implementation of RFC 2369 for SquirrelMail.
7 * When viewing a message from a mailinglist complying with this RFC,
8 * this plugin displays a menu which gives the user a choice of mailinglist
9 * commands such as (un)subscribe, help and list archives.
11 * @copyright © 1999-2006 The SquirrelMail Project Team
12 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
15 * @subpackage listcommands
19 * internal function that builds mailing list links
21 function plugin_listcommands_menu_do() {
22 global $passed_id, $passed_ent_id, $color, $mailbox, $message, $startMessage;
25 * Array of commands we can deal with from the header. The Reply option
26 * is added later because we generate it using the Post information.
28 $fieldsdescr = listcommands_fieldsdescr();
31 foreach ($message->rfc822_header
->mlist
as $cmd => $actions) {
33 /* I don't know this action... skip it */
34 if ( !array_key_exists($cmd, $fieldsdescr) ) {
38 /* proto = {mailto,href} */
39 $aActions = array_keys($actions);
40 $proto = array_shift($aActions);
41 $act = array_shift($actions);
43 if ($proto == 'mailto') {
45 if (($cmd == 'post') ||
($cmd == 'owner')) {
46 $url = 'src/compose.php?'.
47 (isset($startMessage)?
'startMessage='.$startMessage.'&':'');
49 $url = "plugins/listcommands/mailout.php?action=$cmd&";
51 $url .= 'send_to=' . str_replace('?','&', $act);
53 $output[] = makeComposeLink($url, $fieldsdescr[$cmd]);
58 $url .= '&passed_id='.$passed_id.
59 '&mailbox='.urlencode($mailbox).
60 (isset($passed_ent_id)?
'&passed_ent_id='.$passed_ent_id:'');
61 $url .= '&smaction=reply';
63 $output[] = makeComposeLink($url, $fieldsdescr['reply']);
65 } else if ($proto == 'href') {
66 $output[] = '<a href="' . $act . '" target="_blank">'
67 . $fieldsdescr[$cmd] . '</a>';
71 if (count($output) > 0) {
73 html_tag('td', '<b>' . _("Mailing List") . ': </b>',
74 'right', '', 'valign="middle" width="20%"') . "\n" .
75 html_tag('td', '<small>' . implode(' | ', $output) . '</small>',
76 'left', $color[0], 'valign="middle" width="80%"') . "\n" .
82 * Returns an array with the actions as translated strings.
83 * @return array action as key, translated string as value
85 function listcommands_fieldsdescr() {
86 return array('post' => _("Post to List"),
87 'reply' => _("Reply to List"),
88 'subscribe' => _("Subscribe"),
89 'unsubscribe' => _("Unsubscribe"),
90 'archive' => _("List Archives"),
91 'owner' => _("Contact Listowner"),