From 73ee43b174ceb16e6143d0c8feb512e53eee3042 Mon Sep 17 00:00:00 2001 From: philippe_mingo Date: Tue, 22 Jan 2002 08:28:29 +0000 Subject: [PATCH] List Commands plugin by "Thijs Kinkhorst" git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2197 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- plugins/listcommands/README | 52 +++++++++++++++ plugins/listcommands/mailout.php | 86 +++++++++++++++++++++++++ plugins/listcommands/setup.php | 105 +++++++++++++++++++++++++++++++ 3 files changed, 243 insertions(+) create mode 100644 plugins/listcommands/README create mode 100644 plugins/listcommands/mailout.php create mode 100644 plugins/listcommands/setup.php diff --git a/plugins/listcommands/README b/plugins/listcommands/README new file mode 100644 index 00000000..a5a597c3 --- /dev/null +++ b/plugins/listcommands/README @@ -0,0 +1,52 @@ +List Commands plugin -- v1.2 + +This plugin gives the user a menu of mailinglist options such as +(un)subscribe, help and archives when viewing messages from compliant +mailinglists. + + +Description +=========== + +The plugin is an implementation of RFC 2369, "The Use of URLs as Meta-Syntax +for Core Mail List Commands and their Transport through Message Header Fields", +to be found at ftp://nis.nsf.net/internet/documents/rfc/rfc2369.txt. + +Compliant mailinglistservers add extra headers with each message they send out +with information about how to (un)subscribe, get help or contact the list +owner. This can either be a web location or an emailaddress. In the latter +case, one needs to send an email to that address in order to complete an action +like subscribing. + +The information in these headers is used to generate an extra menuline on +messages containing one or more of these headers to help users taking advantage +of the features offered. + + +Installation +============ + +As with other plugins, just uncompress the archive in the plugins +directory, go back to the main directory, run configure and add the plugin. + +Questions/comments/flames/etc can be sent to + Thijs Kinkhorst + + +Changes +======= +1.0 + * Initial version +1.1 + * Added 'Reply to list' option + * Support for identities when sending mail + * Miscelaneous minor improvements +1.2 + * Fixed too greedy regexp; changed to PCRE. + * Fixed IMAP session id handling. + + +Acknowledgements +================ +I'd like to thank Peter Walker, Wouter Teepe and Jason Edwards for their +useful contributions to this plugin. diff --git a/plugins/listcommands/mailout.php b/plugins/listcommands/mailout.php new file mode 100644 index 00000000..97e71c1b --- /dev/null +++ b/plugins/listcommands/mailout.php @@ -0,0 +1,86 @@ + +

+ + +
' . _("Mailinglist") . ' ' . _($action); ?>
+'; + +/* + * Identity support (RFC 2369 sect. B.1.) + * + * I had to copy this from compose.php because there doesn't + * seem to exist a function to get the identities. + */ + +$defaultmail = htmlspecialchars(getPref($data_dir, $username, 'full_name')); +$em = getPref($data_dir, $username, 'email_address'); +if ($em != '') { + $defaultmail .= htmlspecialchars(' <' . $em . '>') . "\n"; +} +echo '

' . _("From:"); + +$idents = getPref($data_dir, $username, 'identities'); +if ($idents != '' && $idents > 1) +{ + echo ' ' . "\n" ; + +} +else +{ + echo $defaultmail; +} +?> +
+ + + + +">

+ +
+

+ + \ No newline at end of file diff --git a/plugins/listcommands/setup.php b/plugins/listcommands/setup.php new file mode 100644 index 00000000..31077297 --- /dev/null +++ b/plugins/listcommands/setup.php @@ -0,0 +1,105 @@ + + * + */ +function squirrelmail_plugin_init_listcommands () +{ + global $squirrelmail_plugin_hooks; + + $squirrelmail_plugin_hooks['read_body_header']['listcommands'] = 'plugin_listcommands_menu'; +} + + +function plugin_listcommands_menu () { + + global $imapConnection, $passed_id, $color, $mailbox, $subject; + + /* Array of commands we can deal with from the header. The Reply option is + * added later because we generate it using the Post information. + */ + $fieldsdescr = array( 'Help' => _("Help"), + 'Unsubscribe' => _("Unsubscribe"), + 'Subscribe' => _("Subscribe"), + 'Post' => _("Post to the list"), + 'Archive' => _("List Archives"), + 'Owner' => _("Contact Listowner") ); + $fields = array_keys ($fieldsdescr); + $fieldsdescr['Reply'] = 'Reply to the list'; + + $cmds = array(); + $output = array(); + + $lfields = 'List-' . implode (' List-', $fields); + + $sid = sqimap_session_id(); + fputs ($imapConnection, "$sid FETCH $passed_id BODY.PEEK[HEADER.FIELDS ($lfields)]\r\n"); + $read = sqimap_read_data ($imapConnection, $sid, true, $response, $emessage); + + for ($i = 1; $i < count($read); $i++) + { + foreach ($fields as $field) + { + if ( preg_match("/^List-$field: *<(.+?)>/i", $read[$i], $match) ) + { + $cmds[$field] = $match[1]; + } + } + } + + foreach ($cmds as $cmd => $url) + { + if ( eregi('mailto:(.+)', $url, $regs) ) + { + $purl = parse_url($url); + + if ( $cmd == 'Post' || $cmd == 'Owner' ) + { + $url = 'compose.php?'; + } + else + { + $url = '../plugins/listcommands/mailout.php?action=' . $cmd . '&'; + } + + $url .= 'mailbox=' . urlencode($mailbox) . '&send_to=' . $purl['path']; + + if ( isset($purl['query']) ) + { + $url .= '&' . $purl['query']; + } + + $output[] = '' . $fieldsdescr[$cmd] . ''; + + if ( $cmd == 'Post' ) + { + $url .= '&reply_subj=' . urlencode($subject) . '&reply_id=' . $passed_id; + $output[] = '' . $fieldsdescr['Reply'] . ''; + } + } + elseif ( eregi('^(http|ftp)', $url) ) + { + $output[] = '' . $fieldsdescr[$cmd] . ''; + } + + + } + + + if (count($output) > 0) { + echo "". + '' . _("Mailinglist options:") . ' ' . implode (' | ', $output) . + ''. + ''; + } + +} +?> \ No newline at end of file -- 2.25.1