Happy New Year
[squirrelmail.git] / plugins / spamcop / options.php
index 31d17ac133847c0965ee1f609311aacbe6b8b3c5..e6d2a77ea9c5622438303cc54e810ac245bb5228 100755 (executable)
@@ -1,40 +1,31 @@
 <?php
 
 /**
- *  options.php -- SpamCop options page
+ * options.php -- SpamCop options page
  *
- * @copyright (c) 1999-2004 The SquirrelMail development team
+ * @copyright 1999-2020 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package plugins
  * @subpackage spamcop
  */
 
-/** @ignore */
-define('SM_PATH','../../');
-require_once(SM_PATH . 'include/validate.php');
 
 /**
- * Internal spamcop plugin function.
- *
- * It is used to display similar action links.
- * @access private
+ * Include the SquirrelMail initialization file.
  */
-function spamcop_enable_disable($option,$disable_action,$enable_action) {
-    if ($option) { 
-       $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";
-    }
-    return $ret;
-}
+require('../../include/init.php');
+/* plugin functions */
+include_once(SM_PATH . 'plugins/spamcop/functions.php');
+
+displayPageHeader($color);
+
+/** is spamcop plugin disabled */
+// option changes do nothing, if read_body_header_right hook is not active.
 
-displayPageHeader($color, 'None');
-   
 /* globals */
 sqgetGlobalVar('action', $action);
 sqgetGlobalVar('meth', $meth);
-sqgetGlobalVar('type', $type);
 sqgetGlobalVar('ID' , $ID);
 
 sqgetGlobalVar('username', $username, SQ_SESSION);
@@ -55,16 +46,17 @@ 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);
         }
         break;
-    case 'type':
-        if (isset($type)) {
-            setPref($data_dir, $username, 'spamcop_type', $type);
-        }
-       break;
     case 'save_id':
         if (isset($ID)) {
             $ID = trim($ID);
@@ -75,107 +67,89 @@ switch ($action) {
         break;
 }
 
-global $spamcop_enabled, $spamcop_delete, $spamcop_quick_report;
-spamcop_load();
+global $spamcop_enabled, $spamcop_delete, $spamcop_save, $spamcop_quick_report;
+spamcop_load_function();
 
 ?>
       <br />
       <table width="95%" align="center" border="0" cellpadding="2" cellspacing="0">
       <tr><td bgcolor="<?php echo $color[0]; ?>">
-         <center><b>
-        <?php echo _("Options") . " - " . _("Spam reporting"); ?>
-        </b></center>
+        <div style="text-align: center;"><b>
+        <?php echo _("Options") . " - " . _("Spam reporting"); ?>
+        </b></div>
       </td></tr></table>
       <br />
-      
+
       <table align="center">
         <tr>
-         <?php
-         echo html_tag('td',_("SpamCop link is:"),'right');
-         echo html_tag('td', spamcop_enable_disable($spamcop_enabled,'disable','enable') );
-         ?>
-       </tr>
+          <?php
+            echo html_tag('td',_("SpamCop link is:"),'right');
+            echo html_tag('td', spamcop_enable_disable($spamcop_enabled,'disable','enable') );
+          ?>
+        </tr>
+        <tr>
+          <?php
+            echo html_tag('td',_("Delete spam when reported:") . "<br />\n" .
+            '<small>(' . _("Only works with email-based reporting") . ')</small>',
+            'right','','valign="top"');
+            echo html_tag('td', spamcop_enable_disable($spamcop_delete,'save','delete'),'','','valign="top"');
+          ?>
+        </tr>
         <tr>
-         <?php
-         echo html_tag('td',_("Delete spam when reported:") . "<br />\n" .
-         '<small>(' . _("Only works with email-based reporting") . ')</small>',
-         'right','','valign="top"');
-         echo html_tag('td', spamcop_enable_disable($spamcop_delete,'save','delete'),'','','valign="top"');
-         ?>
-       </tr>
-       <tr>
-         <?php
-         echo html_tag('td',_("Spam Reporting Method:"),'right');
-         ?>
-         <td>
-         <form method="post" action="options.php">
-           <select name="meth">
-               <?php
-                   if ($spamcop_quick_report) {
-                       echo '<option value="quick_email"';
-                       if ($spamcop_method == 'quick_email') echo ' selected';
-                       echo ">"._("Quick email-based reporting");
-                       echo '</option>';
+          <?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>
+          <form method="post" action="options.php">
+            <select name="meth">
+              <?php
+                if ($spamcop_quick_report) {
+                    echo '<option value="quick_email"';
+                    if ($spamcop_method == 'quick_email') echo ' selected="selected"';
+                    echo ">"._("Quick email-based reporting");
+                    echo '</option>';
+                }
+                   $selected = '';
+                   if ($spamcop_method == 'thorough_email') {
+                       $selected = ' selected';
+                   }
+                   echo sprintf('            <option value="thorough_email"%s>%s</option>',$selected, _("Through email-based reporting"));
+                   
+                   $selected = '';
+                   if ($spamcop_method == 'web_form') {
+                       $selected = ' selected';
                    }
-               ?>
-             <option value="thorough_email"
-               <?php
-                 if ($spamcop_method == 'thorough_email') echo ' selected';
-                 echo ">"._("Thorough email-based reporting");
-               ?>
-             </option>
-             <option value="web_form"
-               <?php
-                 if ($spamcop_method == 'web_form') echo ' selected';
-                 echo ">"._("Web-based form");
-               ?>
-             </option>
-           </select>
-           <input type="hidden" name="action" value="meth" />
-           <?php
-               echo '<input type="submit" value="' . _("Save Method") . "\" />\n";
-           ?>
-         </form></td>
-       </tr>
-       <tr>
-           <?php
-               echo html_tag('td',_("Spam Service Type:"),'right');
-           ?>
-         <td>
-         <form method="post" action="options.php">
-           <select name="type">
-             <option value="free"
-               <?php
-                 if ($spamcop_type == 'free') echo ' selected';
-                 echo ">"._("Free reporting");
-               ?>
-             </option>
-             <option value="member"
-               <?php
-                 if ($spamcop_type == 'member') echo ' selected';
-                 echo ">"._("Member services");
-               ?>
-             </option>
-           </select>
-           <?php
-           echo '<input type="hidden" name="action" value="type" />' .
-                '<input type="submit" value="' . _("Save Service Type") . "\" />\n";
-           ?>
-          </form></td>
-       </tr>
-       <tr>
-         <?php
-           echo html_tag('td',_("Your SpamCop authorization code:") . "<br />" .
-           '<small>(' . _("see below") . ')</small>','right','','valign="top"');
-         ?>
-         <td valign="top"><form method="post" action="options.php">
-           <input type="text" size="30" name="ID" value="<?php echo htmlspecialchars($spamcop_id) ?>" />
-           <input type="hidden" name="action" value="save_id" />
-           <?php
-               echo '<input type="submit" value="' . _("Save ID") . "\" />\n";
-           ?>
-         </form></td>
-       </tr>
+                   echo sprintf('            <option value="web_form"%s>%s</option>', $selected, _("Web-based form"));
+                
+            ?>
+            </select>
+            <input type="hidden" name="action" value="meth" />
+            <?php
+              echo '<input type="submit" value="' . _("Save Method") . "\" />\n";
+            ?>
+          </form></td>
+        </tr>
+        <tr>
+          <?php
+            echo html_tag('td',_("Your SpamCop authorization code:") . "<br />" .
+            '<small>(' . _("see below") . ')</small>','right','','valign="top"');
+          ?>
+          <td valign="top"><form method="post" action="options.php">
+            <input type="text" size="30" name="ID" value="<?php echo sm_encode_html_special_chars($spamcop_id) ?>" />
+            <input type="hidden" name="action" value="save_id" />
+            <?php
+              echo '<input type="submit" value="' . _("Save ID") . "\" />\n";
+            ?>
+          </form></td>
+        </tr>
       </table>
 <?php
 echo '<p><b>' . _("About SpamCop") . '</b><br />';
@@ -213,7 +187,7 @@ echo _("The SpamCop service will display information as it finds it, so scroll d
 echo "</p>\n";
 
 echo '<p><b>' . _("SpamCop service type") . '</b><br />';
-echo _("Service type option allows selecting which spamcop services you are using. Member services use different web reporting forms and does not display nags. You can purchase these services, if you want to support SpamCop.");
+echo _("Service type option allows selecting which SpamCop services you are using. Member services use different web reporting forms and does not display nags. You can purchase these services, if you want to support SpamCop.");
 echo "</p>\n";
 
 echo '<p><b>' . _("More information") . '</b><br />';