squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

setup.php
Go to the documentation of this file.
1 <?php
13 $spamcop_quick_report = false;
14 
15 /* Initialize the plugin */
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';
25  $squirrelmail_plugin_hooks['compose_send']['spamcop'] =
26  'spamcop_while_sending';
27 }
28 
29 
30 // Load the settings
31 // Validate some of it (make '' into 'default', etc.)
32 function spamcop_load() {
34  $spamcop_method, $spamcop_id, $spamcop_quick_report;
35 
36  $spamcop_enabled = getPref($data_dir, $username, 'spamcop_enabled');
37  $spamcop_delete = getPref($data_dir, $username, 'spamcop_delete');
38  $spamcop_method = getPref($data_dir, $username, 'spamcop_method');
39  $spamcop_id = getPref($data_dir, $username, 'spamcop_id');
40  if ($spamcop_method == '') {
41 // This variable is not used
42 // if (getPref($data_dir, $username, 'spamcop_form'))
43 // $spamcop_method = 'web_form';
44 // else
45 
46 // Default to web_form. It is faster.
47  $spamcop_method = 'web_form';
48  setPref($data_dir, $username, 'spamcop_method', $spamcop_method);
49  }
50  if (! $spamcop_quick_report && $spamcop_method=='quick_email') {
51  $spamcop_method = 'web_form';
52  setPref($data_dir, $username, 'spamcop_method', $spamcop_method);
53  }
54  if ($spamcop_id == '')
55  $spamcop_enabled = 0;
56 }
57 
58 
59 // Show the link on the read-a-message screen
60 function spamcop_show_link() {
61  global $spamcop_enabled, $spamcop_method, $spamcop_quick_report;
62 
63  if (! $spamcop_enabled)
64  return;
65 
66  /* GLOBALS */
67  sqgetGlobalVar('passed_id', $passed_id, SQ_FORM);
68  sqgetGlobalVar('passed_ent_id',$passed_ent_id,SQ_FORM);
69  sqgetGlobalVar('mailbox', $mailbox, SQ_FORM);
70  if ( sqgetGlobalVar('startMessage', $startMessage, SQ_FORM) ) {
71  $startMessage = (int)$startMessage;
72  }
73  /* END GLOBALS */
74 
75  // catch unset passed_ent_id
76  if (! sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_FORM) ) {
77  $passed_ent_id = 0;
78  }
79 
80  echo "<br>\n";
81 
82  /*
83  Catch situation when user use quick_email and does not update
84  preferences. User gets web_form link. If prefs are set to
85  quick_email format - they will be updated after clicking the link
86  */
87  if (! $spamcop_quick_report && $spamcop_method=='quick_email') {
88  $spamcop_method = 'web_form';
89  }
90 
91  if ($spamcop_method == 'web_form') {
92 ?><script language="javascript" type="text/javascript">
93 document.write('<a href="../plugins/spamcop/spamcop.php?passed_id=<?php echo urlencode($passed_id); ?>&amp;js_web=1&amp;mailbox=<?php echo urlencode($mailbox); ?>&amp;passed_ent_id=<?php echo urlencode($passed_ent_id); ?>" target="_blank">');
94 document.write("<?php echo _("Report as Spam"); ?>");
95 document.write("</a>");
96 </script><noscript>
97 <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); ?>&amp;passed_ent_id=<?php echo urlencode($passed_ent_id); ?>">
98 <?php echo _("Report as Spam"); ?></a>
99 </noscript><?php
100  } else {
101 ?><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); ?>&amp;passed_ent_id=<?php echo urlencode($passed_ent_id); ?>">
102 <?php echo _("Report as Spam"); ?></a>
103 <?php
104  }
105 }
106 
107 
108 // Show the link to our own custom options page
109 function spamcop_options() {
110  global $optpage_blocks;
111 
112  $optpage_blocks[] = array(
113  'name' => _("SpamCop - Spam Reporting"),
114  'url' => '../plugins/spamcop/options.php',
115  '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."),
116  'js' => false
117  );
118 }
119 
120 
121 // When we send the email, we optionally trash it then too
125 
126  // load sqgetGlobalVar()
127  include_once(SM_PATH . 'functions/global.php');
128 
129  // check if compose.php is called by spamcop plugin
130  if (sqgetGlobalVar('spamcop_is_composing' , $spamcop_is_composing)) {
131  if ($spamcop_delete) {
134  sqimap_msgs_list_delete($imapConnection, $mailbox, $spamcop_is_composing);
135  if ($auto_expunge)
137  }
138  // change default email composition setting. Plugin always operates in right frame.
139  // make sure that compose.php redirects to right page. Temporally override.
140  global $compose_new_win;
141  $compose_new_win = false;
142  }
143 }
sqgetGlobalVar
sqgetGlobalVar($name, &$value, $search=SQ_INORDER)
Definition: global.php:344
$imapConnection
$imapConnection
Definition: message_details_bottom.php:74
getPref
getPref($data_dir, $username, $string, $default='')
Definition: db_prefs.php:316
sqimap_mailbox_expunge
sqimap_mailbox_expunge($imap_stream, $mailbox, $handle_errors=true, $id='')
Definition: imap_mailbox.php:198
$imapServerAddress
$imapServerAddress
Definition: config_default.php:202
sqimap_login
sqimap_login($username, $password, $imap_server_address, $imap_port, $hide)
Definition: imap_general.php:481
$data_dir
$data_dir
Definition: config_default.php:499
$mailbox
$mailbox
Definition: options.php:28
setPref
setPref($data_dir, $username, $string, $set_to)
Definition: db_prefs.php:352
$username
global $username
Definition: validate.php:55
$spamcop_enabled
switch($action) global $spamcop_enabled
Definition: options.php:36
sqimap_mailbox_select
sqimap_mailbox_select($imap_stream, $mailbox)
Definition: imap_mailbox.php:238
spamcop_show_link
spamcop_show_link()
Definition: setup.php:60
$squirrelmail_plugin_hooks
global $squirrelmail_plugin_hooks
Definition: plugin.php:17
sqimap_msgs_list_delete
sqimap_msgs_list_delete($imap_stream, $mailbox, $id)
Definition: imap_messages.php:73
spamcop_options
spamcop_options()
Definition: setup.php:109
spamcop_load
spamcop_load()
Definition: setup.php:32
$spamcop_quick_report
global $spamcop_quick_report
Definition: setup.php:12
SM_PATH
const SM_PATH
Definition: decrypt_headers.php:16
_
_($str)
Definition: gettext.php:160
$imapPort
$imapPort
Definition: config_default.php:210
SQ_FORM
const SQ_FORM
Definition: global.php:21
spamcop_while_sending
spamcop_while_sending()
Definition: setup.php:122
$spamcop_delete
switch($action) global $spamcop_delete
Definition: options.php:36
$compose_new_win
$compose_new_win
Definition: load_prefs.php:251
squirrelmail_plugin_init_spamcop
squirrelmail_plugin_init_spamcop()
Definition: setup.php:16
$auto_expunge
$auto_expunge
Definition: config_default.php:397