3 ** setup.php -- SpamCop plugin
5 ** Copyright (c) 1999-2003 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
11 require_once(SM_PATH
. 'functions/global.php');
14 /* Initialize the plugin */
15 function squirrelmail_plugin_init_spamcop() {
16 global $squirrelmail_plugin_hooks, $data_dir, $username,
17 $spamcop_is_composing;
19 $squirrelmail_plugin_hooks['optpage_register_block']['spamcop'] =
21 $squirrelmail_plugin_hooks['loading_prefs']['spamcop'] =
23 $squirrelmail_plugin_hooks['read_body_header_right']['spamcop'] =
26 sqextractGlobalVar('spamcop_is_composing');
28 if (isset($spamcop_is_composing)) {
29 $squirrelmail_plugin_hooks['compose_send']['spamcop'] =
30 'spamcop_while_sending';
36 // Validate some of it (make '' into 'default', etc.)
37 function spamcop_load() {
38 global $username, $data_dir, $spamcop_enabled, $spamcop_delete,
39 $spamcop_method, $spamcop_id;
41 $spamcop_enabled = getPref($data_dir, $username, 'spamcop_enabled');
42 $spamcop_delete = getPref($data_dir, $username, 'spamcop_delete');
43 $spamcop_method = getPref($data_dir, $username, 'spamcop_method');
44 $spamcop_id = getPref($data_dir, $username, 'spamcop_id');
45 if ($spamcop_method == '') {
46 if (getPref($data_dir, $username, 'spamcop_form'))
47 $spamcop_method = 'web_form';
49 $spamcop_method = 'thorough_email';
50 setPref($data_dir, $username, 'spamcop_method', $spamcop_method);
52 if ($spamcop_id == '')
57 // Show the link on the read-a-message screen
58 function spamcop_show_link() {
59 global $spamcop_enabled, $spamcop_method;
61 if (! $spamcop_enabled)
65 $passed_id = $_GET['passed_id'];
66 $mailbox = $_GET['mailbox'];
67 $startMessage = $_GET['startMessage'];
72 if ($spamcop_method == 'web_form') {
73 ?
><script language
=javascript
>
74 document
.write('<a href="../plugins/spamcop/spamcop.php?passed_id=<?PHP
75 echo urlencode($passed_id); ?>&js_web=1&mailbox=<?PHP
76 echo urlencode($mailbox); ?>" target="_blank">');
77 document
.write("<?PHP echo _("Report
as Spam
"); ?>");
78 document
.write("</a>");
80 <a href
="../plugins/spamcop/spamcop.php?passed_id=<?PHP
81 echo urlencode($passed_id); ?>&mailbox=<?PHP
82 echo urlencode($mailbox); ?>&startMessage=<?PHP
83 echo urlencode($startMessage); ?>"><?PHP
84 echo _("Report as Spam"); ?
></a
>
87 ?
><a href
="../plugins/spamcop/spamcop.php?passed_id=<?PHP
88 echo urlencode($passed_id); ?>&mailbox=<?PHP
89 echo urlencode($mailbox); ?>&startMessage=<?PHP
90 echo urlencode($startMessage); ?>"><?PHP
91 echo _("Report as Spam"); ?
></a
><?PHP
96 // Show the link to our own custom options page
97 function spamcop_options()
99 global $optpage_blocks;
101 $optpage_blocks[] = array(
102 'name' => _("SpamCop - Spam Reporting"),
103 'url' => '../plugins/spamcop/options.php',
104 '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."),
110 // When we send the email, we optionally trash it then too
111 function spamcop_while_sending()
113 global $mailbox, $spamcop_delete, $spamcop_is_composing, $auto_expunge,
114 $username, $key, $imapServerAddress, $imapPort;
116 if ($spamcop_delete) {
117 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
119 sqimap_mailbox_select($imapConnection, $mailbox);
120 sqimap_messages_delete($imapConnection, $spamcop_is_composing,
121 $spamcop_is_composing, $mailbox);
123 sqimap_mailbox_expunge($imapConnection, $mailbox, true);