rtl alignment fix
[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 **
ea5f4b8e 8 ** $Id$
9 * @package plugins
10 * @subpackage spamcop
04f6008a 11 **/
772be735 12
ea5f4b8e 13/** @ignore */
0dabfa7f 14require_once(SM_PATH . 'functions/global.php');
15
057e9d6e 16/** Disable Quick Reporting by default */
17$spamcop_quick_report = false;
0dabfa7f 18
ea5f4b8e 19/** Initialize the plugin */
772be735 20function squirrelmail_plugin_init_spamcop() {
21 global $squirrelmail_plugin_hooks, $data_dir, $username,
22 $spamcop_is_composing;
23
24 $squirrelmail_plugin_hooks['optpage_register_block']['spamcop'] =
25 'spamcop_options';
26 $squirrelmail_plugin_hooks['loading_prefs']['spamcop'] =
27 'spamcop_load';
28 $squirrelmail_plugin_hooks['read_body_header_right']['spamcop'] =
29 'spamcop_show_link';
04f6008a 30
3267e4d8 31 sqgetGlobalVar('spamcop_is_composing' , $spamcop_is_composing);
772be735 32
33 if (isset($spamcop_is_composing)) {
34 $squirrelmail_plugin_hooks['compose_send']['spamcop'] =
35 'spamcop_while_sending';
36 }
37}
38
39
40// Load the settings
41// Validate some of it (make '' into 'default', etc.)
42function spamcop_load() {
43 global $username, $data_dir, $spamcop_enabled, $spamcop_delete,
057e9d6e 44 $spamcop_method, $spamcop_id, $spamcop_quick_report;
772be735 45
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');
057e9d6e 50 if ($spamcop_method == '') {
51// This variable is not used
52// if (getPref($data_dir, $username, 'spamcop_form'))
53// $spamcop_method = 'web_form';
54// else
55
56// Default to web_form. It is faster.
57 $spamcop_method = 'web_form';
58 setPref($data_dir, $username, 'spamcop_method', $spamcop_method);
59 }
60 if (! $spamcop_quick_report && $spamcop_method=='quick_email') {
61 $spamcop_method = 'web_form';
62 setPref($data_dir, $username, 'spamcop_method', $spamcop_method);
772be735 63 }
64 if ($spamcop_id == '')
65 $spamcop_enabled = 0;
66}
67
68
69// Show the link on the read-a-message screen
70function spamcop_show_link() {
057e9d6e 71 global $spamcop_enabled, $spamcop_method, $spamcop_quick_report;
772be735 72
73 if (! $spamcop_enabled)
74 return;
75
04f6008a 76 /* GLOBALS */
555d97ec 77 sqgetGlobalVar('passed_id', $passed_id, SQ_FORM);
78 sqgetGlobalVar('mailbox', $mailbox, SQ_FORM);
79 sqgetGlobalVar('startMessage', $startMessage, SQ_FORM);
04f6008a 80 /* END GLOBALS */
81
772be735 82 echo "<br>\n";
057e9d6e 83
84 /*
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
88 */
89 if (! $spamcop_quick_report && $spamcop_method=='quick_email') {
90 $spamcop_method = 'web_form';
91 }
772be735 92
93 if ($spamcop_method == 'web_form') {
8ddc4111 94?><script language="javascript" type="text/javascript">
2bd52bbe 95document.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 96document.write("<?PHP echo _("Report as Spam"); ?>");
97document.write("</a>");
98</script><noscript>
2bd52bbe 99<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); ?>">
100<?PHP echo _("Report as Spam"); ?></a>
772be735 101</noscript><?PHP
102 } else {
2bd52bbe 103?><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); ?>">
104<?PHP echo _("Report as Spam"); ?></a>
105<?PHP
772be735 106 }
107}
108
109
110// Show the link to our own custom options page
111function spamcop_options()
112{
113 global $optpage_blocks;
114
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."),
119 'js' => false
120 );
121}
122
123
124// When we send the email, we optionally trash it then too
125function spamcop_while_sending()
126{
127 global $mailbox, $spamcop_delete, $spamcop_is_composing, $auto_expunge,
128 $username, $key, $imapServerAddress, $imapPort;
129
130 if ($spamcop_delete) {
131 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
132 $imapPort, 0);
133 sqimap_mailbox_select($imapConnection, $mailbox);
134 sqimap_messages_delete($imapConnection, $spamcop_is_composing,
135 $spamcop_is_composing, $mailbox);
136 if ($auto_expunge)
137 sqimap_mailbox_expunge($imapConnection, $mailbox, true);
138 }
139}
140
057e9d6e 141?>