Strings fix
[squirrelmail.git] / plugins / listcommands / setup.php
CommitLineData
73ee43b1 1<?php
2/*
050722c4 3 * Listcommands plugin v1.3
73ee43b1 4 *
5 * Implementation of RFC 2369 for SquirrelMail.
6 * When viewing a message from a mailinglist complying with this RFC,
7 * this plugin displays a menu which gives the user a choice of mailinglist
8 * commands such as (un)subscribe, help and list archives.
9 *
050722c4 10 * last modified: 2002/01/21 by Thijs Kinkhorst
73ee43b1 11 * please send bug reports to <thijs@kinkhorst.com>
12 *
13 */
14function squirrelmail_plugin_init_listcommands ()
15{
16 global $squirrelmail_plugin_hooks;
17
18 $squirrelmail_plugin_hooks['read_body_header']['listcommands'] = 'plugin_listcommands_menu';
19}
20
21
22function plugin_listcommands_menu () {
23
050722c4 24 global $imapConnection, $passed_id, $color, $mailbox,
25 $subject, $ent_num, $priority_level;
73ee43b1 26
27 /* Array of commands we can deal with from the header. The Reply option is
28 * added later because we generate it using the Post information.
29 */
050722c4 30 $fieldsdescr = array( 'Help' => _("Help"),
73ee43b1 31 'Unsubscribe' => _("Unsubscribe"),
050722c4 32 'Subscribe' => _("Subscribe"),
73ee43b1 33 'Post' => _("Post to the list"),
050722c4 34 'Archive' => _("List Archives"),
73ee43b1 35 'Owner' => _("Contact Listowner") );
36 $fields = array_keys ($fieldsdescr);
050722c4 37 $fieldsdescr['Reply'] = _("Reply to the list");
38
73ee43b1 39 $cmds = array();
40 $output = array();
41
42 $lfields = 'List-' . implode (' List-', $fields);
43
44 $sid = sqimap_session_id();
45 fputs ($imapConnection, "$sid FETCH $passed_id BODY.PEEK[HEADER.FIELDS ($lfields)]\r\n");
46 $read = sqimap_read_data ($imapConnection, $sid, true, $response, $emessage);
47
050722c4 48 for ($i = 1; $i < count($read); $i++) {
49 foreach ($fields as $field) {
50 if ( preg_match("/^List-$field: *<(.+?)>/i", $read[$i], $match) ) {
73ee43b1 51 $cmds[$field] = $match[1];
52 }
53 }
54 }
55
050722c4 56 foreach ($cmds as $cmd => $url) {
57 if ( eregi('mailto:(.+)', $url, $regs) ) {
73ee43b1 58 $purl = parse_url($url);
050722c4 59
60 if ( $cmd == 'Post' || $cmd == 'Owner' ) {
73ee43b1 61 $url = 'compose.php?';
050722c4 62 } else {
73ee43b1 63 $url = '../plugins/listcommands/mailout.php?action=' . $cmd . '&';
64 }
65
66 $url .= 'mailbox=' . urlencode($mailbox) . '&send_to=' . $purl['path'];
050722c4 67
68 if ( isset($purl['query']) ) {
73ee43b1 69 $url .= '&' . $purl['query'];
70 }
71
72 $output[] = '<A HREF="' . $url . '">' . $fieldsdescr[$cmd] . '</A>';
73
050722c4 74 if ( $cmd == 'Post' ) {
75 $url .= '&reply_subj=' . urlencode($subject) .
76 '&reply_id=' . $passed_id .
77 '&ent_num=' . $ent_num .
78 '&mailprio=' . $priority_level;
73ee43b1 79 $output[] = '<A HREF="' . $url . '">' . $fieldsdescr['Reply'] . '</A>';
80 }
050722c4 81 } elseif ( eregi('^(http|ftp)', $url) ) {
73ee43b1 82 $output[] = '<A HREF="' . $url . '" TARGET="_blank">' . $fieldsdescr[$cmd] . '</A>';
83 }
73ee43b1 84 }
85
73ee43b1 86 if (count($output) > 0) {
87 echo "<tr><td BGCOLOR=\"$color[0]\" WIDTH=\"100%\" colspan=\"3\">".
88 '<SMALL>' . _("Mailinglist options:") . ' ' . implode ('&nbsp;|&nbsp;', $output) .
89 '</SMALL>'.
90 '</td></tr>';
91 }
050722c4 92}
73ee43b1 93?>