f44a7134577fa8641262f95ae17b996982207769
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 sqgetGlobalVar('spamcop_is_composing' , $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 sqgetGlobalVar('passed_id', $passed_id, SQ_GET
);
66 sqgetGlobalVar('mailbox', $mailbox, SQ_GET
);
67 sqgetGlobalVar('startMessage', $startMessage, SQ_GET
);
72 if ($spamcop_method == 'web_form') {
73 ?
><script language
="javascript" type
="text/javascript">
74 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">');
75 document
.write("<?PHP echo _("Report
as Spam
"); ?>");
76 document
.write("</a>");
78 <a href
="../plugins/spamcop/spamcop.php?passed_id=<?PHP echo urlencode($passed_id); ?>&mailbox=<?PHP echo urlencode($mailbox); ?>&startMessage=<?PHP echo urlencode($startMessage); ?>">
79 <?PHP
echo _("Report as Spam"); ?
></a
>
82 ?
><a href
="../plugins/spamcop/spamcop.php?passed_id=<?PHP echo urlencode($passed_id); ?>&mailbox=<?PHP echo urlencode($mailbox); ?>&startMessage=<?PHP echo urlencode($startMessage); ?>">
83 <?PHP
echo _("Report as Spam"); ?
></a
>
89 // Show the link to our own custom options page
90 function spamcop_options()
92 global $optpage_blocks;
94 $optpage_blocks[] = array(
95 'name' => _("SpamCop - Spam Reporting"),
96 'url' => '../plugins/spamcop/options.php',
97 '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."),
103 // When we send the email, we optionally trash it then too
104 function spamcop_while_sending()
106 global $mailbox, $spamcop_delete, $spamcop_is_composing, $auto_expunge,
107 $username, $key, $imapServerAddress, $imapPort;
109 if ($spamcop_delete) {
110 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
112 sqimap_mailbox_select($imapConnection, $mailbox);
113 sqimap_messages_delete($imapConnection, $spamcop_is_composing,
114 $spamcop_is_composing, $mailbox);
116 sqimap_mailbox_expunge($imapConnection, $mailbox, true);