793566f0 |
1 | <?php |
2 | |
3 | /** |
4 | * functions.php |
5 | * |
793566f0 |
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. |
10 | * |
47ccfad4 |
11 | * @copyright © 1999-2006 The SquirrelMail Project Team |
4b4abf93 |
12 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
793566f0 |
13 | * @version $Id$ |
14 | * @package plugins |
15 | * @subpackage listcommands |
16 | */ |
17 | |
f4f2d73f |
18 | /** |
19 | * internal function that builds mailing list links |
20 | */ |
793566f0 |
21 | function plugin_listcommands_menu_do() { |
f7b996c3 |
22 | global $passed_id, $passed_ent_id, $color, $mailbox, $message, $startMessage, $oTemplate; |
793566f0 |
23 | |
24 | /** |
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. |
27 | */ |
28 | $fieldsdescr = listcommands_fieldsdescr(); |
2e58d6af |
29 | $links = array(); |
793566f0 |
30 | |
31 | foreach ($message->rfc822_header->mlist as $cmd => $actions) { |
32 | |
33 | /* I don't know this action... skip it */ |
34 | if ( !array_key_exists($cmd, $fieldsdescr) ) { |
35 | continue; |
36 | } |
37 | |
38 | /* proto = {mailto,href} */ |
ba17b6c7 |
39 | $aActions = array_keys($actions); |
40 | $proto = array_shift($aActions); |
2253d920 |
41 | $act = array_shift($actions); |
793566f0 |
42 | |
6aef76f3 |
43 | if ($proto == 'mailto') { |
793566f0 |
44 | |
45 | if (($cmd == 'post') || ($cmd == 'owner')) { |
46 | $url = 'src/compose.php?'. |
47 | (isset($startMessage)?'startMessage='.$startMessage.'&':''); |
48 | } else { |
49 | $url = "plugins/listcommands/mailout.php?action=$cmd&"; |
50 | } |
a74103dd |
51 | $url .= 'send_to=' . str_replace('?','&', $act); |
793566f0 |
52 | |
2e58d6af |
53 | $links[] = makeComposeLink($url, $fieldsdescr[$cmd]); |
793566f0 |
54 | |
55 | if ($cmd == 'post') { |
56 | if (!isset($mailbox)) |
57 | $mailbox = 'INBOX'; |
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'; |
62 | |
2e58d6af |
63 | $links[] = makeComposeLink($url, $fieldsdescr['reply']); |
793566f0 |
64 | } |
65 | } else if ($proto == 'href') { |
f7b996c3 |
66 | $oTemplate->assign('uri', $act); |
67 | $oTemplate->assign('target', '_blank'); |
68 | $oTemplate->assign('text', $fieldsdescr[$cmd]); |
170883a4 |
69 | $oTemplate->assign('class', ''); |
522a2253 |
70 | $oTemplate->assign('id', ''); |
170883a4 |
71 | $oTemplate->assign('onclick', ''); |
f7b996c3 |
72 | $output = $oTemplate->fetch('hyperlink.tpl'); |
73 | $links[] = $output; |
793566f0 |
74 | } |
75 | } |
76 | |
2e58d6af |
77 | if (count($links) > 0) { |
2e58d6af |
78 | $oTemplate->assign('links', $links); |
79 | $output = $oTemplate->fetch('plugins/listcommands/read_body_header.tpl'); |
80 | return array('read_body_header' => $output); |
793566f0 |
81 | } |
2e58d6af |
82 | |
793566f0 |
83 | } |
84 | |
85 | /** |
86 | * Returns an array with the actions as translated strings. |
87 | * @return array action as key, translated string as value |
88 | */ |
89 | function listcommands_fieldsdescr() { |
90 | return array('post' => _("Post to List"), |
91 | 'reply' => _("Reply to List"), |
92 | 'subscribe' => _("Subscribe"), |
93 | 'unsubscribe' => _("Unsubscribe"), |
94 | 'archive' => _("List Archives"), |
95 | 'owner' => _("Contact Listowner"), |
96 | 'help' => _("Help")); |
97 | } |
98 | |