Typo
[squirrelmail.git] / plugins / spamcop / setup.php
CommitLineData
772be735 1<?php
2
3
4/* Initialize the plugin */
5function squirrelmail_plugin_init_spamcop() {
6 global $squirrelmail_plugin_hooks, $data_dir, $username,
7 $spamcop_is_composing;
8
9 $squirrelmail_plugin_hooks['optpage_register_block']['spamcop'] =
10 'spamcop_options';
11 $squirrelmail_plugin_hooks['loading_prefs']['spamcop'] =
12 'spamcop_load';
13 $squirrelmail_plugin_hooks['read_body_header_right']['spamcop'] =
14 'spamcop_show_link';
15
16 if (isset($spamcop_is_composing)) {
17 $squirrelmail_plugin_hooks['compose_send']['spamcop'] =
18 'spamcop_while_sending';
19 }
20}
21
22
23// Load the settings
24// Validate some of it (make '' into 'default', etc.)
25function spamcop_load() {
26 global $username, $data_dir, $spamcop_enabled, $spamcop_delete,
27 $spamcop_method, $spamcop_id;
28
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';
36 else
37 $spamcop_method = 'thorough_email';
38 setPref($data_dir, $username, 'spamcop_method', $spamcop_method);
39 }
40 if ($spamcop_id == '')
41 $spamcop_enabled = 0;
42}
43
44
45// Show the link on the read-a-message screen
46function spamcop_show_link() {
47 global $passed_id, $mailbox, $ent_num, $spamcop_enabled, $startMessage,
48 $spamcop_method;
49
50 // This was stolen from printer_friendly
51 // Do I really need/want it?
52 if (!trim($mailbox))
53 $mailbox = 'INBOX';
54
55 if (! $spamcop_enabled)
56 return;
57
58 echo "<br>\n";
59
60 if ($spamcop_method == 'web_form') {
61?><script language=javascript>
62document.write('<a href="../plugins/spamcop/spamcop.php?passed_id=<?PHP
63echo urlencode($passed_id); ?>&js_web=1&mailbox=<?PHP
64echo urlencode($mailbox); ?>" target="_blank">');
65document.write("<?PHP echo _("Report as Spam"); ?>");
66document.write("</a>");
67</script><noscript>
68<a href="../plugins/spamcop/spamcop.php?passed_id=<?PHP
69echo urlencode($passed_id); ?>&mailbox=<?PHP
70echo urlencode($mailbox); ?>&startMessage=<?PHP
71echo urlencode($startMessage); ?>"><?PHP
72echo _("Report as Spam"); ?></a>
73</noscript><?PHP
74 } else {
75?><a href="../plugins/spamcop/spamcop.php?passed_id=<?PHP
76echo urlencode($passed_id); ?>&mailbox=<?PHP
77echo urlencode($mailbox); ?>&startMessage=<?PHP
78echo urlencode($startMessage); ?>"><?PHP
79echo _("Report as Spam"); ?></a><?PHP
80 }
81}
82
83
84// Show the link to our own custom options page
85function spamcop_options()
86{
87 global $optpage_blocks;
88
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."),
93 'js' => false
94 );
95}
96
97
98// When we send the email, we optionally trash it then too
99function spamcop_while_sending()
100{
101 global $mailbox, $spamcop_delete, $spamcop_is_composing, $auto_expunge,
102 $username, $key, $imapServerAddress, $imapPort;
103
104 if ($spamcop_delete) {
105 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
106 $imapPort, 0);
107 sqimap_mailbox_select($imapConnection, $mailbox);
108 sqimap_messages_delete($imapConnection, $spamcop_is_composing,
109 $spamcop_is_composing, $mailbox);
110 if ($auto_expunge)
111 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
112 }
113}
114
115?>