utf-8 is already converted by ja_JP extra functions.
[squirrelmail.git] / plugins / spamcop / setup.php
CommitLineData
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 **
8 ** $Id$
9 **/
772be735 10
0dabfa7f 11require_once(SM_PATH . 'functions/global.php');
12
13
772be735 14/* Initialize the plugin */
15function squirrelmail_plugin_init_spamcop() {
16 global $squirrelmail_plugin_hooks, $data_dir, $username,
17 $spamcop_is_composing;
18
19 $squirrelmail_plugin_hooks['optpage_register_block']['spamcop'] =
20 'spamcop_options';
21 $squirrelmail_plugin_hooks['loading_prefs']['spamcop'] =
22 'spamcop_load';
23 $squirrelmail_plugin_hooks['read_body_header_right']['spamcop'] =
24 'spamcop_show_link';
04f6008a 25
3267e4d8 26 sqgetGlobalVar('spamcop_is_composing' , $spamcop_is_composing);
772be735 27
28 if (isset($spamcop_is_composing)) {
29 $squirrelmail_plugin_hooks['compose_send']['spamcop'] =
30 'spamcop_while_sending';
31 }
32}
33
34
35// Load the settings
36// Validate some of it (make '' into 'default', etc.)
37function spamcop_load() {
38 global $username, $data_dir, $spamcop_enabled, $spamcop_delete,
39 $spamcop_method, $spamcop_id;
40
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';
48 else
49 $spamcop_method = 'thorough_email';
50 setPref($data_dir, $username, 'spamcop_method', $spamcop_method);
51 }
52 if ($spamcop_id == '')
53 $spamcop_enabled = 0;
54}
55
56
57// Show the link on the read-a-message screen
58function spamcop_show_link() {
04f6008a 59 global $spamcop_enabled, $spamcop_method;
772be735 60
61 if (! $spamcop_enabled)
62 return;
63
04f6008a 64 /* GLOBALS */
8ddc4111 65 sqgetGlobalVar('passed_id', $passed_id, SQ_GET);
66 sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
67 sqgetGlobalVar('startMessage', $startMessage, SQ_GET);
04f6008a 68 /* END GLOBALS */
69
772be735 70 echo "<br>\n";
71
72 if ($spamcop_method == 'web_form') {
8ddc4111 73?><script language="javascript" type="text/javascript">
2bd52bbe 74document.write('<a href="../plugins/spamcop/spamcop.php?passed_id=<?PHP echo urlencode($passed_id); ?>&amp;js_web=1&amp;mailbox=<?PHP echo urlencode($mailbox); ?>" target="_blank">');
772be735 75document.write("<?PHP echo _("Report as Spam"); ?>");
76document.write("</a>");
77</script><noscript>
2bd52bbe 78<a href="../plugins/spamcop/spamcop.php?passed_id=<?PHP echo urlencode($passed_id); ?>&amp;mailbox=<?PHP echo urlencode($mailbox); ?>&amp;startMessage=<?PHP echo urlencode($startMessage); ?>">
79<?PHP echo _("Report as Spam"); ?></a>
772be735 80</noscript><?PHP
81 } else {
2bd52bbe 82?><a href="../plugins/spamcop/spamcop.php?passed_id=<?PHP echo urlencode($passed_id); ?>&amp;mailbox=<?PHP echo urlencode($mailbox); ?>&amp;startMessage=<?PHP echo urlencode($startMessage); ?>">
83<?PHP echo _("Report as Spam"); ?></a>
84<?PHP
772be735 85 }
86}
87
88
89// Show the link to our own custom options page
90function spamcop_options()
91{
92 global $optpage_blocks;
93
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."),
98 'js' => false
99 );
100}
101
102
103// When we send the email, we optionally trash it then too
104function spamcop_while_sending()
105{
106 global $mailbox, $spamcop_delete, $spamcop_is_composing, $auto_expunge,
107 $username, $key, $imapServerAddress, $imapPort;
108
109 if ($spamcop_delete) {
110 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
111 $imapPort, 0);
112 sqimap_mailbox_select($imapConnection, $mailbox);
113 sqimap_messages_delete($imapConnection, $spamcop_is_composing,
114 $spamcop_is_composing, $mailbox);
115 if ($auto_expunge)
116 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
117 }
118}
119
120?>