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