stop loading functions in setup.php
authortokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 13 Jul 2005 13:50:51 +0000 (13:50 +0000)
committertokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 13 Jul 2005 13:50:51 +0000 (13:50 +0000)
detect spamcop submission inside compose_send hook.
add keep/don't keep submitted mails option
fix redirection when compose_new_win = true.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@9771 7612ce4b-ef26-0410-bec9-ea0150e637f0

plugins/spamcop/options.php
plugins/spamcop/setup.php

index c16cf61..fea1041 100755 (executable)
@@ -22,9 +22,9 @@ require_once(SM_PATH . 'include/validate.php');
  */
 function spamcop_enable_disable($option,$disable_action,$enable_action) {
     if ($option) {
-        $ret= _("Enabled") . "(<a href=\"options.php?action=$disable_action\">" . _("Disable it") . "</a>)\n";
+        $ret= _("Enabled") . " (<a href=\"options.php?action=$disable_action\">" . _("Disable it") . "</a>)\n";
     } else {
-        $ret = _("Disabled") . "(<a href=\"options.php?action=$enable_action\">" . _("Enable it") . "</a>)\n";
+        $ret = _("Disabled") . " (<a href=\"options.php?action=$enable_action\">" . _("Enable it") . "</a>)\n";
     }
     return $ret;
 }
@@ -55,6 +55,12 @@ switch ($action) {
     case 'delete':
         setPref($data_dir, $username, 'spamcop_delete', 1);
         break;
+    case 'keep':
+        setPref($data_dir, $username, 'spamcop_save', 0);
+        break;
+    case 'dontkeep':
+        setPref($data_dir, $username, 'spamcop_save', 1);
+        break;
     case 'meth':
         if (isset($meth)) {
             setPref($data_dir, $username, 'spamcop_method', $meth);
@@ -75,7 +81,7 @@ switch ($action) {
         break;
 }
 
-global $spamcop_enabled, $spamcop_delete, $spamcop_quick_report;
+global $spamcop_enabled, $spamcop_delete, $spamcop_save, $spamcop_quick_report;
 spamcop_load();
 
 ?>
@@ -105,6 +111,14 @@ spamcop_load();
         </tr>
         <tr>
           <?php
+            echo html_tag('td',_("Save emails submitted to spamcop:") . "<br />\n" .
+            '<small>(' . _("Only works with email-based reporting") . ')</small>',
+            'right','','valign="top"');
+            echo html_tag('td', spamcop_enable_disable($spamcop_save,'keep','dontkeep'),'','','valign="top"');
+          ?>
+        </tr>
+        <tr>
+          <?php
             echo html_tag('td',_("Spam Reporting Method:"),'right');
           ?>
           <td>
index a71448c..f62b441 100755 (executable)
@@ -9,10 +9,8 @@
  * @subpackage spamcop
  */
 
-/** @ignore */
-require_once(SM_PATH . 'functions/global.php');
-
 /** Disable Quick Reporting by default */
+global $spamcop_quick_report;
 $spamcop_quick_report = false;
 
 /**
@@ -20,7 +18,7 @@ $spamcop_quick_report = false;
  * @access private
  */
 function squirrelmail_plugin_init_spamcop() {
-    global $squirrelmail_plugin_hooks, $spamcop_is_composing;
+    global $squirrelmail_plugin_hooks;
 
     $squirrelmail_plugin_hooks['optpage_register_block']['spamcop'] =
         'spamcop_options';
@@ -28,13 +26,8 @@ function squirrelmail_plugin_init_spamcop() {
         'spamcop_load';
     $squirrelmail_plugin_hooks['read_body_header_right']['spamcop'] =
         'spamcop_show_link';
-
-    sqgetGlobalVar('spamcop_is_composing' , $spamcop_is_composing);
-
-    if (isset($spamcop_is_composing)) {
-        $squirrelmail_plugin_hooks['compose_send']['spamcop'] =
-            'spamcop_while_sending';
-    }
+    $squirrelmail_plugin_hooks['compose_send']['spamcop'] =
+        'spamcop_while_sending';
 }
 
 
@@ -43,11 +36,12 @@ function squirrelmail_plugin_init_spamcop() {
  * @access private
  */
 function spamcop_load() {
-    global $username, $data_dir, $spamcop_enabled, $spamcop_delete,
+    global $username, $data_dir, $spamcop_enabled, $spamcop_delete, $spamcop_save,
            $spamcop_method, $spamcop_id, $spamcop_quick_report, $spamcop_type;
 
     $spamcop_enabled = getPref($data_dir, $username, 'spamcop_enabled');
     $spamcop_delete = getPref($data_dir, $username, 'spamcop_delete');
+    $spamcop_save = getPref($data_dir, $username, 'spamcop_save',true);
     $spamcop_method = getPref($data_dir, $username, 'spamcop_method');
     $spamcop_type = getPref($data_dir, $username, 'spamcop_type');
     $spamcop_id = getPref($data_dir, $username, 'spamcop_id');
@@ -96,7 +90,7 @@ function spamcop_show_link() {
     echo "<br />\n";
 
     /*
-       Catch situation when user use quick_email and does not update
+       Catch situation when user uses quick_email and does not update
        preferences. User gets web_form link. If prefs are set to
        quick_email format - they will be updated after clicking the link
      */
@@ -123,8 +117,7 @@ document.write("</a>");
  * Show spamcop options block
  * @access private
  */
-function spamcop_options()
-{
+function spamcop_options() {
     global $optpage_blocks;
 
     $optpage_blocks[] = array(
@@ -140,19 +133,30 @@ function spamcop_options()
  * When we send the email, we optionally trash it then too
  * @access private
  */
-function spamcop_while_sending()
-{
-    global $mailbox, $spamcop_delete, $spamcop_is_composing, $auto_expunge,
+function spamcop_while_sending() {
+    global $mailbox, $spamcop_delete, $spamcop_save, $spamcop_is_composing, $auto_expunge,
            $username, $key, $imapServerAddress, $imapPort;
 
-    if ($spamcop_delete) {
-        $imapConnection = sqimap_login($username, $key, $imapServerAddress,
+    if (sqgetGlobalVar('spamcop_is_composing' , $spamcop_is_composing)) {
+        // delete spam message
+        if ($spamcop_delete) {
+            $imapConnection = sqimap_login($username, $key, $imapServerAddress,
                 $imapPort, 0);
-        sqimap_mailbox_select($imapConnection, $mailbox);
-        sqimap_msgs_list_delete($imapConnection, $mailbox, array($spamcop_is_composing));
-        if ($auto_expunge)
-            sqimap_mailbox_expunge($imapConnection, $mailbox, true);
+            sqimap_mailbox_select($imapConnection, $mailbox);
+            sqimap_msgs_list_delete($imapConnection, $mailbox, array($spamcop_is_composing));
+            if ($auto_expunge)
+                sqimap_mailbox_expunge($imapConnection, $mailbox, true);
+        }
+        if (! $spamcop_save) {
+            // disable use of send folder.
+            // Temporally override in order to disable saving of 'reply anyway' messages.
+            global $default_move_to_sent;
+            $default_move_to_sent=false;
+        }
+        // change default email composition setting. Plugin always operates in right frame.
+        // make sure that compose.php redirects to right page. Temporally override.
+        global $compose_new_win;
+        $compose_new_win = false;
     }
 }
-
 ?>
\ No newline at end of file