b33ababf379b78584e942becbfe76e57d11eb02c
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
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.
17 function squirrelmail_plugin_init_listcommands () {
18 global $squirrelmail_plugin_hooks;
20 $squirrelmail_plugin_hooks['read_body_header']['listcommands'] = 'plugin_listcommands_menu';
23 function plugin_listcommands_menu() {
24 global $imapConnection, $passed_id, $color, $mailbox,
25 $message, $ent_num, $priority_level, $compose_new_win, $uid_support;
27 $subject = trim($message->header
->subject
);
30 * Array of commands we can deal with from the header. The Reply option
31 * is added later because we generate it using the Post information.
33 $fieldsdescr = array('Post' => _("Post to List"),
34 'Reply' => _("Reply to List"),
35 'Subscribe' => _("Subscribe"),
36 'Unsubscribe' => _("Unsubscribe"),
37 'Archive' => _("List Archives"),
38 'Owner' => _("Contact Listowner"),
40 $fields = array_keys($fieldsdescr);
42 $sorted_cmds = array();
43 $unsorted_cmds = array();
46 $lfields = 'List-' . implode (' List-', $fields);
48 $sid = sqimap_session_id($uid_support);
49 fputs ($imapConnection, "$sid FETCH $passed_id BODY.PEEK[HEADER.FIELDS ($lfields)]\r\n");
50 $read = sqimap_read_data($imapConnection, $sid, true, $response, $emessage);
52 for ($i = 1; $i < count($read); $i++
) {
53 foreach ($fields as $field) {
54 if ( preg_match("/^List-$field: *<(.+?)>/i", $read[$i], $match) ) {
55 $unsorted_cmds[$field] = $match[1];
60 if (count($unsorted_cmds) == 0) {
64 foreach ($fields as $field) {
65 foreach ($unsorted_cmds as $cmd => $url) {
72 foreach ($cmds as $cmd => $url) {
73 if (eregi('mailto:(.+)', $url, $regs)) {
74 $purl = parse_url($url);
76 if (($cmd == 'Post') ||
($cmd == 'Owner')) {
77 $url = 'compose.php?';
79 $url = "../plugins/listcommands/mailout.php?action=$cmd&";
82 $url .= 'mailbox=' . urlencode($mailbox)
83 . '&send_to=' . $purl['path'];
85 if (isset($purl['query'])) {
86 $url .= '&' . $purl['query'];
88 if ($compose_new_win == '1') {
89 $output[] = "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$url')\">" . $fieldsdescr[$cmd] . '</A>';
92 $output[] = '<A HREF="' . $url . '">' . $fieldsdescr[$cmd] . '</A>';
95 $url .= '&reply_subj=' . urlencode($subject)
96 . '&reply_id=' . $passed_id
97 . '&ent_num=' . $ent_num
98 . '&mailprio=' . $priority_level;
99 if ($compose_new_win == '1') {
100 $output[] = "<A HREF=\"javascript:void(0)\" onClick=\"comp_in_new(false,'$url')\">" . $fieldsdescr['Reply'] . '</A>';
103 $output[] = '<A HREF="' . $url . '">' . $fieldsdescr['Reply'] . '</A>';
106 } else if (eregi('^(http|ftp)', $url)) {
107 $output[] = '<A HREF="' . $url . '" TARGET="_blank">'
108 . $fieldsdescr[$cmd] . '</A>';
112 if (count($output) > 0) {
114 html_tag( 'td', str_replace(' ', ' ', _("Mailing List:")), 'right', $color[0]) .
116 '<small>' . implode(' | ', $output) . '</small>' ,
117 'left', $color[0], 'width="100%" colspan="2"')