4 /* Initialize the plugin */
5 function squirrelmail_plugin_init_spamcop() {
6 global $squirrelmail_plugin_hooks, $data_dir, $username,
9 $squirrelmail_plugin_hooks['optpage_register_block']['spamcop'] =
11 $squirrelmail_plugin_hooks['loading_prefs']['spamcop'] =
13 $squirrelmail_plugin_hooks['read_body_header_right']['spamcop'] =
16 if (isset($spamcop_is_composing)) {
17 $squirrelmail_plugin_hooks['compose_send']['spamcop'] =
18 'spamcop_while_sending';
24 // Validate some of it (make '' into 'default', etc.)
25 function spamcop_load() {
26 global $username, $data_dir, $spamcop_enabled, $spamcop_delete,
27 $spamcop_method, $spamcop_id;
29 $spamcop_enabled = getPref($data_dir, $username, 'spamcop_enabled');
30 $spamcop_delete = getPref($data_dir, $username, 'spamcop_delete');
31 $spamcop_method = getPref($data_dir, $username, 'spamcop_method');
32 $spamcop_id = getPref($data_dir, $username, 'spamcop_id');
33 if ($spamcop_method == '') {
34 if (getPref($data_dir, $username, 'spamcop_form'))
35 $spamcop_method = 'web_form';
37 $spamcop_method = 'thorough_email';
38 setPref($data_dir, $username, 'spamcop_method', $spamcop_method);
40 if ($spamcop_id == '')
45 // Show the link on the read-a-message screen
46 function spamcop_show_link() {
47 global $passed_id, $mailbox, $ent_num, $spamcop_enabled, $startMessage,
50 // This was stolen from printer_friendly
51 // Do I really need/want it?
55 if (! $spamcop_enabled)
60 if ($spamcop_method == 'web_form') {
61 ?
><script language
=javascript
>
62 document
.write('<a href="../plugins/spamcop/spamcop.php?passed_id=<?PHP
63 echo urlencode($passed_id); ?>&js_web=1&mailbox=<?PHP
64 echo urlencode($mailbox); ?>" target="_blank">');
65 document
.write("<?PHP echo _("Report
as Spam
"); ?>");
66 document
.write("</a>");
68 <a href
="../plugins/spamcop/spamcop.php?passed_id=<?PHP
69 echo urlencode($passed_id); ?>&mailbox=<?PHP
70 echo urlencode($mailbox); ?>&startMessage=<?PHP
71 echo urlencode($startMessage); ?>"><?PHP
72 echo _("Report as Spam"); ?
></a
>
75 ?
><a href
="../plugins/spamcop/spamcop.php?passed_id=<?PHP
76 echo urlencode($passed_id); ?>&mailbox=<?PHP
77 echo urlencode($mailbox); ?>&startMessage=<?PHP
78 echo urlencode($startMessage); ?>"><?PHP
79 echo _("Report as Spam"); ?
></a
><?PHP
84 // Show the link to our own custom options page
85 function spamcop_options()
87 global $optpage_blocks;
89 $optpage_blocks[] = array(
90 'name' => _("SpamCop - Spam Reporting"),
91 'url' => '../plugins/spamcop/options.php',
92 '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."),
98 // When we send the email, we optionally trash it then too
99 function spamcop_while_sending()
101 global $mailbox, $spamcop_delete, $spamcop_is_composing, $auto_expunge,
102 $username, $key, $imapServerAddress, $imapPort;
104 if ($spamcop_delete) {
105 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
107 sqimap_mailbox_select($imapConnection, $mailbox);
108 sqimap_messages_delete($imapConnection, $spamcop_is_composing,
109 $spamcop_is_composing, $mailbox);
111 sqimap_mailbox_expunge($imapConnection, $mailbox, true);