772be735 |
1 | <?php |
04f6008a |
2 | /** |
3 | ** setup.php -- SpamCop plugin |
4 | ** |
76911253 |
5 | ** Copyright (c) 1999-2003 The SquirrelMail development team |
04f6008a |
6 | ** Licensed under the GNU GPL. For full terms see the file COPYING. |
7 | ** |
ea5f4b8e |
8 | ** $Id$ |
9 | * @package plugins |
10 | * @subpackage spamcop |
04f6008a |
11 | **/ |
772be735 |
12 | |
ea5f4b8e |
13 | /** @ignore */ |
0dabfa7f |
14 | require_once(SM_PATH . 'functions/global.php'); |
15 | |
16 | |
ea5f4b8e |
17 | /** Initialize the plugin */ |
772be735 |
18 | function squirrelmail_plugin_init_spamcop() { |
19 | global $squirrelmail_plugin_hooks, $data_dir, $username, |
20 | $spamcop_is_composing; |
21 | |
22 | $squirrelmail_plugin_hooks['optpage_register_block']['spamcop'] = |
23 | 'spamcop_options'; |
24 | $squirrelmail_plugin_hooks['loading_prefs']['spamcop'] = |
25 | 'spamcop_load'; |
26 | $squirrelmail_plugin_hooks['read_body_header_right']['spamcop'] = |
27 | 'spamcop_show_link'; |
04f6008a |
28 | |
3267e4d8 |
29 | sqgetGlobalVar('spamcop_is_composing' , $spamcop_is_composing); |
772be735 |
30 | |
31 | if (isset($spamcop_is_composing)) { |
32 | $squirrelmail_plugin_hooks['compose_send']['spamcop'] = |
33 | 'spamcop_while_sending'; |
34 | } |
35 | } |
36 | |
37 | |
38 | // Load the settings |
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; |
43 | |
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'; |
51 | else |
52 | $spamcop_method = 'thorough_email'; |
53 | setPref($data_dir, $username, 'spamcop_method', $spamcop_method); |
54 | } |
55 | if ($spamcop_id == '') |
56 | $spamcop_enabled = 0; |
57 | } |
58 | |
59 | |
60 | // Show the link on the read-a-message screen |
61 | function spamcop_show_link() { |
04f6008a |
62 | global $spamcop_enabled, $spamcop_method; |
772be735 |
63 | |
64 | if (! $spamcop_enabled) |
65 | return; |
66 | |
04f6008a |
67 | /* GLOBALS */ |
555d97ec |
68 | sqgetGlobalVar('passed_id', $passed_id, SQ_FORM); |
69 | sqgetGlobalVar('mailbox', $mailbox, SQ_FORM); |
70 | sqgetGlobalVar('startMessage', $startMessage, SQ_FORM); |
04f6008a |
71 | /* END GLOBALS */ |
72 | |
772be735 |
73 | echo "<br>\n"; |
74 | |
75 | if ($spamcop_method == 'web_form') { |
8ddc4111 |
76 | ?><script language="javascript" type="text/javascript"> |
2bd52bbe |
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">'); |
772be735 |
78 | document.write("<?PHP echo _("Report as Spam"); ?>"); |
79 | document.write("</a>"); |
80 | </script><noscript> |
2bd52bbe |
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> |
772be735 |
83 | </noscript><?PHP |
84 | } else { |
2bd52bbe |
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> |
87 | <?PHP |
772be735 |
88 | } |
89 | } |
90 | |
91 | |
92 | // Show the link to our own custom options page |
93 | function spamcop_options() |
94 | { |
95 | global $optpage_blocks; |
96 | |
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."), |
101 | 'js' => false |
102 | ); |
103 | } |
104 | |
105 | |
106 | // When we send the email, we optionally trash it then too |
107 | function spamcop_while_sending() |
108 | { |
109 | global $mailbox, $spamcop_delete, $spamcop_is_composing, $auto_expunge, |
110 | $username, $key, $imapServerAddress, $imapPort; |
111 | |
112 | if ($spamcop_delete) { |
113 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, |
114 | $imapPort, 0); |
115 | sqimap_mailbox_select($imapConnection, $mailbox); |
116 | sqimap_messages_delete($imapConnection, $spamcop_is_composing, |
117 | $spamcop_is_composing, $mailbox); |
118 | if ($auto_expunge) |
119 | sqimap_mailbox_expunge($imapConnection, $mailbox, true); |
120 | } |
121 | } |
122 | |
123 | ?> |