3 * setup.php -- SpamCop plugin - setup script
5 * @copyright (c) 1999-2004 The SquirrelMail development team
6 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 require_once(SM_PATH
. 'functions/global.php');
15 /** Disable Quick Reporting by default */
16 $spamcop_quick_report = false;
19 * Initialize the plugin
22 function squirrelmail_plugin_init_spamcop() {
23 global $squirrelmail_plugin_hooks, $data_dir, $username,
24 $spamcop_is_composing;
26 $squirrelmail_plugin_hooks['optpage_register_block']['spamcop'] =
28 $squirrelmail_plugin_hooks['loading_prefs']['spamcop'] =
30 $squirrelmail_plugin_hooks['read_body_header_right']['spamcop'] =
33 sqgetGlobalVar('spamcop_is_composing' , $spamcop_is_composing);
35 if (isset($spamcop_is_composing)) {
36 $squirrelmail_plugin_hooks['compose_send']['spamcop'] =
37 'spamcop_while_sending';
43 * Loads spamcop settings and validates some of values (make '' into 'default', etc.)
46 function spamcop_load() {
47 global $username, $data_dir, $spamcop_enabled, $spamcop_delete,
48 $spamcop_method, $spamcop_id, $spamcop_quick_report, $spamcop_type;
50 $spamcop_enabled = getPref($data_dir, $username, 'spamcop_enabled');
51 $spamcop_delete = getPref($data_dir, $username, 'spamcop_delete');
52 $spamcop_method = getPref($data_dir, $username, 'spamcop_method');
53 $spamcop_type = getPref($data_dir, $username, 'spamcop_type');
54 $spamcop_id = getPref($data_dir, $username, 'spamcop_id');
55 if ($spamcop_method == '') {
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_type == '') {
65 $spamcop_type = 'free';
66 setPref($data_dir, $username, 'spamcop_type', $spamcop_type);
68 if ($spamcop_id == '')
74 * Shows spamcop link on the read-a-message screen
77 function spamcop_show_link() {
78 global $spamcop_enabled, $spamcop_method, $spamcop_quick_report,$javascript_on;
80 if (! $spamcop_enabled)
84 sqgetGlobalVar('passed_id', $passed_id, SQ_FORM
);
85 sqgetGlobalVar('passed_ent_id',$passed_ent_id,SQ_FORM
);
86 sqgetGlobalVar('mailbox', $mailbox, SQ_FORM
);
87 sqgetGlobalVar('startMessage', $startMessage, SQ_FORM
);
90 // catch unset passed_ent_id
91 if (! sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_FORM
) ) {
98 Catch situation when user use quick_email and does not update
99 preferences. User gets web_form link. If prefs are set to
100 quick_email format - they will be updated after clicking the link
102 if (! $spamcop_quick_report && $spamcop_method=='quick_email') {
103 $spamcop_method = 'web_form';
106 // Javascript is used only in web based reporting
107 // don't insert javascript if javascript is disabled
108 if ($spamcop_method == 'web_form' && $javascript_on) {
109 ?
><script language
="javascript" type
="text/javascript">
110 document
.write('<a href="../plugins/spamcop/spamcop.php?passed_id=<?PHP echo urlencode($passed_id); ?>&js_web=1&mailbox=<?PHP echo urlencode($mailbox); ?>&passed_ent_id=<?PHP echo urlencode($passed_ent_id); ?>" target="_blank">');
111 document
.write("<?PHP echo _("Report
as Spam
"); ?>");
112 document
.write("</a>");
115 ?
><a href
="../plugins/spamcop/spamcop.php?passed_id=<?PHP echo urlencode($passed_id); ?>&mailbox=<?PHP echo urlencode($mailbox); ?>&startMessage=<?PHP echo urlencode($startMessage); ?>&passed_ent_id=<?PHP echo urlencode($passed_ent_id); ?>">
116 <?PHP
echo _("Report as Spam"); ?
></a
>
122 * Show spamcop options block
125 function spamcop_options()
127 global $optpage_blocks;
129 $optpage_blocks[] = array(
130 'name' => _("SpamCop - Spam Reporting"),
131 'url' => '../plugins/spamcop/options.php',
132 '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."),
139 * When we send the email, we optionally trash it then too
142 function spamcop_while_sending()
144 global $mailbox, $spamcop_delete, $spamcop_is_composing, $auto_expunge,
145 $username, $key, $imapServerAddress, $imapPort;
147 if ($spamcop_delete) {
148 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
150 sqimap_mailbox_select($imapConnection, $mailbox);
151 sqimap_messages_delete($imapConnection, $spamcop_is_composing,
152 $spamcop_is_composing, $mailbox);
154 sqimap_mailbox_expunge($imapConnection, $mailbox, true);