0613a87b991ac71502b72fdf0f02250ba6870e4e
3 ** setup.php -- SpamCop plugin
5 ** Copyright (c) 1999-2004 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
14 require_once(SM_PATH
. 'functions/global.php');
16 /** Disable Quick Reporting by default */
17 $spamcop_quick_report = false;
19 /** Initialize the plugin */
20 function squirrelmail_plugin_init_spamcop() {
21 global $squirrelmail_plugin_hooks, $data_dir, $username,
22 $spamcop_is_composing;
24 $squirrelmail_plugin_hooks['optpage_register_block']['spamcop'] =
26 $squirrelmail_plugin_hooks['loading_prefs']['spamcop'] =
28 $squirrelmail_plugin_hooks['read_body_header_right']['spamcop'] =
31 sqgetGlobalVar('spamcop_is_composing' , $spamcop_is_composing);
33 if (isset($spamcop_is_composing)) {
34 $squirrelmail_plugin_hooks['compose_send']['spamcop'] =
35 'spamcop_while_sending';
41 * Loads spamcop settings and validates some of values (make '' into 'default', etc.)
43 function spamcop_load() {
44 global $username, $data_dir, $spamcop_enabled, $spamcop_delete,
45 $spamcop_method, $spamcop_id, $spamcop_quick_report, $spamcop_type;
47 $spamcop_enabled = getPref($data_dir, $username, 'spamcop_enabled');
48 $spamcop_delete = getPref($data_dir, $username, 'spamcop_delete');
49 $spamcop_method = getPref($data_dir, $username, 'spamcop_method');
50 $spamcop_type = getPref($data_dir, $username, 'spamcop_type');
51 $spamcop_id = getPref($data_dir, $username, 'spamcop_id');
52 if ($spamcop_method == '') {
53 // Default to web_form. It is faster.
54 $spamcop_method = 'web_form';
55 setPref($data_dir, $username, 'spamcop_method', $spamcop_method);
57 if (! $spamcop_quick_report && $spamcop_method=='quick_email') {
58 $spamcop_method = 'web_form';
59 setPref($data_dir, $username, 'spamcop_method', $spamcop_method);
61 if ($spamcop_type == '') {
62 $spamcop_type = 'free';
63 setPref($data_dir, $username, 'spamcop_type', $spamcop_type);
65 if ($spamcop_id == '')
71 * Shows spamcop link on the read-a-message screen
73 function spamcop_show_link() {
74 global $spamcop_enabled, $spamcop_method, $spamcop_quick_report,$javascript_on;
76 if (! $spamcop_enabled)
80 sqgetGlobalVar('passed_id', $passed_id, SQ_FORM
);
81 sqgetGlobalVar('passed_ent_id',$passed_ent_id,SQ_FORM
);
82 sqgetGlobalVar('mailbox', $mailbox, SQ_FORM
);
83 sqgetGlobalVar('startMessage', $startMessage, SQ_FORM
);
86 // catch unset passed_ent_id
87 if (! sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_FORM
) ) {
94 Catch situation when user use quick_email and does not update
95 preferences. User gets web_form link. If prefs are set to
96 quick_email format - they will be updated after clicking the link
98 if (! $spamcop_quick_report && $spamcop_method=='quick_email') {
99 $spamcop_method = 'web_form';
102 // Javascript is used only in web based reporting
103 // don't insert javascript if javascript is disabled
104 if ($spamcop_method == 'web_form' && $javascript_on) {
105 ?
><script language
="javascript" type
="text/javascript">
106 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">');
107 document
.write("<?PHP echo _("Report
as Spam
"); ?>");
108 document
.write("</a>");
111 ?
><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); ?>">
112 <?PHP
echo _("Report as Spam"); ?
></a
>
118 * Show spamcop options block
120 function spamcop_options()
122 global $optpage_blocks;
124 $optpage_blocks[] = array(
125 'name' => _("SpamCop - Spam Reporting"),
126 'url' => '../plugins/spamcop/options.php',
127 '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."),
134 * When we send the email, we optionally trash it then too
136 function spamcop_while_sending()
138 global $mailbox, $spamcop_delete, $spamcop_is_composing, $auto_expunge,
139 $username, $key, $imapServerAddress, $imapPort;
141 if ($spamcop_delete) {
142 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
144 sqimap_mailbox_select($imapConnection, $mailbox);
145 sqimap_messages_delete($imapConnection, $spamcop_is_composing,
146 $spamcop_is_composing, $mailbox);
148 sqimap_mailbox_expunge($imapConnection, $mailbox, true);