06cf3389e18021bda3ed9cc4cd80a3bdece5b9e7
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');
16 /** Disable Quick Reporting by default */
17 $spamcop_quick_report = false;
19 /** Initialize the plugin */
20 function squirrelmail_plugin_init_spamcop() {
21 global $squirrelmail_plugin_hooks, $data_dir, $username,
22 $spamcop_is_composing;
24 $squirrelmail_plugin_hooks['optpage_register_block']['spamcop'] =
26 $squirrelmail_plugin_hooks['loading_prefs']['spamcop'] =
28 $squirrelmail_plugin_hooks['read_body_header_right']['spamcop'] =
31 sqgetGlobalVar('spamcop_is_composing' , $spamcop_is_composing);
33 if (isset($spamcop_is_composing)) {
34 $squirrelmail_plugin_hooks['compose_send']['spamcop'] =
35 'spamcop_while_sending';
41 // Validate some of it (make '' into 'default', etc.)
42 function spamcop_load() {
43 global $username, $data_dir, $spamcop_enabled, $spamcop_delete,
44 $spamcop_method, $spamcop_id, $spamcop_quick_report;
46 $spamcop_enabled = getPref($data_dir, $username, 'spamcop_enabled');
47 $spamcop_delete = getPref($data_dir, $username, 'spamcop_delete');
48 $spamcop_method = getPref($data_dir, $username, 'spamcop_method');
49 $spamcop_id = getPref($data_dir, $username, 'spamcop_id');
50 if ($spamcop_method == '') {
51 // This variable is not used
52 // if (getPref($data_dir, $username, 'spamcop_form'))
53 // $spamcop_method = 'web_form';
56 // Default to web_form. It is faster.
57 $spamcop_method = 'web_form';
58 setPref($data_dir, $username, 'spamcop_method', $spamcop_method);
60 if (! $spamcop_quick_report && $spamcop_method=='quick_email') {
61 $spamcop_method = 'web_form';
62 setPref($data_dir, $username, 'spamcop_method', $spamcop_method);
64 if ($spamcop_id == '')
69 // Show the link on the read-a-message screen
70 function spamcop_show_link() {
71 global $spamcop_enabled, $spamcop_method, $spamcop_quick_report;
73 if (! $spamcop_enabled)
77 sqgetGlobalVar('passed_id', $passed_id, SQ_FORM
);
78 sqgetGlobalVar('mailbox', $mailbox, SQ_FORM
);
79 sqgetGlobalVar('startMessage', $startMessage, SQ_FORM
);
85 Catch situation when user use quick_email and does not update
86 preferences. User gets web_form link. If prefs are set to
87 quick_email format - they will be updated after clicking the link
89 if (! $spamcop_quick_report && $spamcop_method=='quick_email') {
90 $spamcop_method = 'web_form';
93 if ($spamcop_method == 'web_form') {
94 ?
><script language
="javascript" type
="text/javascript">
95 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">');
96 document
.write("<?PHP echo _("Report
as Spam
"); ?>");
97 document
.write("</a>");
99 <a href
="../plugins/spamcop/spamcop.php?passed_id=<?PHP echo urlencode($passed_id); ?>&mailbox=<?PHP echo urlencode($mailbox); ?>&startMessage=<?PHP echo urlencode($startMessage); ?>">
100 <?PHP
echo _("Report as Spam"); ?
></a
>
103 ?
><a href
="../plugins/spamcop/spamcop.php?passed_id=<?PHP echo urlencode($passed_id); ?>&mailbox=<?PHP echo urlencode($mailbox); ?>&startMessage=<?PHP echo urlencode($startMessage); ?>">
104 <?PHP
echo _("Report as Spam"); ?
></a
>
110 // Show the link to our own custom options page
111 function spamcop_options()
113 global $optpage_blocks;
115 $optpage_blocks[] = array(
116 'name' => _("SpamCop - Spam Reporting"),
117 'url' => '../plugins/spamcop/options.php',
118 '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."),
124 // When we send the email, we optionally trash it then too
125 function spamcop_while_sending()
127 global $mailbox, $spamcop_delete, $spamcop_is_composing, $auto_expunge,
128 $username, $key, $imapServerAddress, $imapPort;
130 if ($spamcop_delete) {
131 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
133 sqimap_mailbox_select($imapConnection, $mailbox);
134 sqimap_messages_delete($imapConnection, $spamcop_is_composing,
135 $spamcop_is_composing, $mailbox);
137 sqimap_mailbox_expunge($imapConnection, $mailbox, true);