d333c479ebe4d17e9ea2b06a1d402f9b6c1f0cd3
3 * Listcommands plugin v1.3
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.
10 * last modified: 2002/01/21 by Thijs Kinkhorst
11 * please send bug reports to <thijs@kinkhorst.com>
14 function squirrelmail_plugin_init_listcommands ()
16 global $squirrelmail_plugin_hooks;
18 $squirrelmail_plugin_hooks['read_body_header']['listcommands'] = 'plugin_listcommands_menu';
22 function plugin_listcommands_menu () {
24 global $imapConnection, $passed_id, $color, $mailbox,
25 $subject, $ent_num, $priority_level;
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.
30 $fieldsdescr = array( 'Help' => _("Help"),
31 'Unsubscribe' => _("Unsubscribe"),
32 'Subscribe' => _("Subscribe"),
33 'Post' => _("Post to the list"),
34 'Archive' => _("List Archives"),
35 'Owner' => _("Contact Listowner") );
36 $fields = array_keys ($fieldsdescr);
37 $fieldsdescr['Reply'] = _("Reply to the list");
42 $lfields = 'List-' . implode (' List-', $fields);
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);
48 for ($i = 1; $i < count($read); $i++
) {
49 foreach ($fields as $field) {
50 if ( preg_match("/^List-$field: *<(.+?)>/i", $read[$i], $match) ) {
51 $cmds[$field] = $match[1];
56 foreach ($cmds as $cmd => $url) {
57 if ( eregi('mailto:(.+)', $url, $regs) ) {
58 $purl = parse_url($url);
60 if ( $cmd == 'Post' ||
$cmd == 'Owner' ) {
61 $url = 'compose.php?';
63 $url = '../plugins/listcommands/mailout.php?action=' . $cmd . '&';
66 $url .= 'mailbox=' . urlencode($mailbox) . '&send_to=' . $purl['path'];
68 if ( isset($purl['query']) ) {
69 $url .= '&' . $purl['query'];
72 $output[] = '<A HREF="' . $url . '">' . $fieldsdescr[$cmd] . '</A>';
74 if ( $cmd == 'Post' ) {
75 $url .= '&reply_subj=' . urlencode($subject) .
76 '&reply_id=' . $passed_id .
77 '&ent_num=' . $ent_num .
78 '&mailprio=' . $priority_level;
79 $output[] = '<A HREF="' . $url . '">' . $fieldsdescr['Reply'] . '</A>';
81 } elseif ( eregi('^(http|ftp)', $url) ) {
82 $output[] = '<A HREF="' . $url . '" TARGET="_blank">' . $fieldsdescr[$cmd] . '</A>';
86 if (count($output) > 0) {
87 echo "<tr><td BGCOLOR=\"$color[0]\" WIDTH=\"100%\" colspan=\"3\">".
88 '<SMALL>' . _("Mailinglist options:") . ' ' . implode (' | ', $output) .