34cf415b72a569b1aad1d602411d7be94b671459
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.
14 require_once(SM_PATH
. 'functions/global.php');
17 /** Initialize the plugin */
18 function squirrelmail_plugin_init_spamcop() {
19 global $squirrelmail_plugin_hooks, $data_dir, $username,
20 $spamcop_is_composing;
22 $squirrelmail_plugin_hooks['optpage_register_block']['spamcop'] =
24 $squirrelmail_plugin_hooks['loading_prefs']['spamcop'] =
26 $squirrelmail_plugin_hooks['read_body_header_right']['spamcop'] =
29 sqgetGlobalVar('spamcop_is_composing' , $spamcop_is_composing);
31 if (isset($spamcop_is_composing)) {
32 $squirrelmail_plugin_hooks['compose_send']['spamcop'] =
33 'spamcop_while_sending';
39 // Validate some of it (make '' into 'default', etc.)
40 function spamcop_load() {
41 global $username, $data_dir, $spamcop_enabled, $spamcop_delete,
42 $spamcop_method, $spamcop_id;
44 $spamcop_enabled = getPref($data_dir, $username, 'spamcop_enabled');
45 $spamcop_delete = getPref($data_dir, $username, 'spamcop_delete');
46 $spamcop_method = getPref($data_dir, $username, 'spamcop_method');
47 $spamcop_id = getPref($data_dir, $username, 'spamcop_id');
48 if ($spamcop_method == '') {
49 if (getPref($data_dir, $username, 'spamcop_form'))
50 $spamcop_method = 'web_form';
52 $spamcop_method = 'thorough_email';
53 setPref($data_dir, $username, 'spamcop_method', $spamcop_method);
55 if ($spamcop_id == '')
60 // Show the link on the read-a-message screen
61 function spamcop_show_link() {
62 global $spamcop_enabled, $spamcop_method;
64 if (! $spamcop_enabled)
68 sqgetGlobalVar('passed_id', $passed_id, SQ_FORM
);
69 sqgetGlobalVar('mailbox', $mailbox, SQ_FORM
);
70 sqgetGlobalVar('startMessage', $startMessage, SQ_FORM
);
75 if ($spamcop_method == 'web_form') {
76 ?
><script language
="javascript" type
="text/javascript">
77 document
.write('<a href="../plugins/spamcop/spamcop.php?passed_id=<?PHP echo urlencode($passed_id); ?>&js_web=1&mailbox=<?PHP echo urlencode($mailbox); ?>" target="_blank">');
78 document
.write("<?PHP echo _("Report
as Spam
"); ?>");
79 document
.write("</a>");
81 <a href
="../plugins/spamcop/spamcop.php?passed_id=<?PHP echo urlencode($passed_id); ?>&mailbox=<?PHP echo urlencode($mailbox); ?>&startMessage=<?PHP echo urlencode($startMessage); ?>">
82 <?PHP
echo _("Report as Spam"); ?
></a
>
85 ?
><a href
="../plugins/spamcop/spamcop.php?passed_id=<?PHP echo urlencode($passed_id); ?>&mailbox=<?PHP echo urlencode($mailbox); ?>&startMessage=<?PHP echo urlencode($startMessage); ?>">
86 <?PHP
echo _("Report as Spam"); ?
></a
>
92 // Show the link to our own custom options page
93 function spamcop_options()
95 global $optpage_blocks;
97 $optpage_blocks[] = array(
98 'name' => _("SpamCop - Spam Reporting"),
99 'url' => '../plugins/spamcop/options.php',
100 '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."),
106 // When we send the email, we optionally trash it then too
107 function spamcop_while_sending()
109 global $mailbox, $spamcop_delete, $spamcop_is_composing, $auto_expunge,
110 $username, $key, $imapServerAddress, $imapPort;
112 if ($spamcop_delete) {
113 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
115 sqimap_mailbox_select($imapConnection, $mailbox);
116 sqimap_messages_delete($imapConnection, $spamcop_is_composing,
117 $spamcop_is_composing, $mailbox);
119 sqimap_mailbox_expunge($imapConnection, $mailbox, true);