3 ** setup.php -- SpamCop plugin
5 ** Copyright (c) 1999-2002 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
11 /* Initialize the plugin */
12 function squirrelmail_plugin_init_spamcop() {
13 global $squirrelmail_plugin_hooks, $data_dir, $username,
14 $spamcop_is_composing;
16 $squirrelmail_plugin_hooks['optpage_register_block']['spamcop'] =
18 $squirrelmail_plugin_hooks['loading_prefs']['spamcop'] =
20 $squirrelmail_plugin_hooks['read_body_header_right']['spamcop'] =
23 sqextractGlobalVar('spamcop_is_composing');
25 if (isset($spamcop_is_composing)) {
26 $squirrelmail_plugin_hooks['compose_send']['spamcop'] =
27 'spamcop_while_sending';
33 // Validate some of it (make '' into 'default', etc.)
34 function spamcop_load() {
35 global $username, $data_dir, $spamcop_enabled, $spamcop_delete,
36 $spamcop_method, $spamcop_id;
38 $spamcop_enabled = getPref($data_dir, $username, 'spamcop_enabled');
39 $spamcop_delete = getPref($data_dir, $username, 'spamcop_delete');
40 $spamcop_method = getPref($data_dir, $username, 'spamcop_method');
41 $spamcop_id = getPref($data_dir, $username, 'spamcop_id');
42 if ($spamcop_method == '') {
43 if (getPref($data_dir, $username, 'spamcop_form'))
44 $spamcop_method = 'web_form';
46 $spamcop_method = 'thorough_email';
47 setPref($data_dir, $username, 'spamcop_method', $spamcop_method);
49 if ($spamcop_id == '')
54 // Show the link on the read-a-message screen
55 function spamcop_show_link() {
56 global $spamcop_enabled, $spamcop_method;
58 if (! $spamcop_enabled)
62 $passed_id = $_GET['passed_id'];
63 $mailbox = $_GET['mailbox'];
64 $startMessage = $_GET['startMessage'];
69 if ($spamcop_method == 'web_form') {
70 ?
><script language
=javascript
>
71 document
.write('<a href="../plugins/spamcop/spamcop.php?passed_id=<?PHP
72 echo urlencode($passed_id); ?>&js_web=1&mailbox=<?PHP
73 echo urlencode($mailbox); ?>" target="_blank">');
74 document
.write("<?PHP echo _("Report
as Spam
"); ?>");
75 document
.write("</a>");
77 <a href
="../plugins/spamcop/spamcop.php?passed_id=<?PHP
78 echo urlencode($passed_id); ?>&mailbox=<?PHP
79 echo urlencode($mailbox); ?>&startMessage=<?PHP
80 echo urlencode($startMessage); ?>"><?PHP
81 echo _("Report as Spam"); ?
></a
>
84 ?
><a href
="../plugins/spamcop/spamcop.php?passed_id=<?PHP
85 echo urlencode($passed_id); ?>&mailbox=<?PHP
86 echo urlencode($mailbox); ?>&startMessage=<?PHP
87 echo urlencode($startMessage); ?>"><?PHP
88 echo _("Report as Spam"); ?
></a
><?PHP
93 // Show the link to our own custom options page
94 function spamcop_options()
96 global $optpage_blocks;
98 $optpage_blocks[] = array(
99 'name' => _("SpamCop - Spam Reporting"),
100 'url' => '../plugins/spamcop/options.php',
101 'desc' => _("Help fight the battle against unsolicited email. SpamCop reads the spam email and determines the correct addresses to send complaints to. Quite fast, really smart, and easy to use."),
107 // When we send the email, we optionally trash it then too
108 function spamcop_while_sending()
110 global $mailbox, $spamcop_delete, $spamcop_is_composing, $auto_expunge,
111 $username, $key, $imapServerAddress, $imapPort;
113 if ($spamcop_delete) {
114 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
116 sqimap_mailbox_select($imapConnection, $mailbox);
117 sqimap_messages_delete($imapConnection, $spamcop_is_composing,
118 $spamcop_is_composing, $mailbox);
120 sqimap_mailbox_expunge($imapConnection, $mailbox, true);