phpDocumentor pond
[ class tree: pond ] [ index: pond ] [ all elements ]

Source for file antispam_settings.ctrl.php

Documentation is available at antispam_settings.ctrl.php

  1. <?php
  2. /**
  3.  * This file implements the UI controller for Antispam Features.
  4.  *
  5.  * This file is part of Quam Plures - {@link http://quamplures.net/}
  6.  * See also {@link https://launchpad.net/quam-plures}.
  7.  *
  8.  * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
  9.  * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
  10.  *  Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
  11.  *
  12.  *  {@internal License choice
  13.  *  - If you have received this file as part of a package, please find the license.txt file in
  14.  *    the same folder or the closest folder above for complete license terms.
  15.  *  - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  16.  *    then you must choose one of the following licenses before using the file:
  17.  *    - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  18.  *    - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  19.  *  }}}
  20.  *
  21.  *  {@internal Open Source relicensing agreement:
  22.  *  Daniel HAHLER grants Francois PLANQUE the right to license
  23.  *  Daniel HAHLER's contributions to this file and the b2evolution project
  24.  *  under any OSI approved OSS license (http://www.opensource.org/licenses/).
  25.  *  }}}
  26.  *
  27.  *  {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  28.  * @author blueyed: Daniel HAHLER.
  29.  *
  30.  * @package pond
  31.  */
  32. if!defined('QP_MAIN_INIT') ) die'Please, do not access this page directly.' );
  33.  
  34.  
  35. // Check minimum permission:
  36. $current_User->check_perm'options''view'true );
  37.  
  38.  
  39. $AdminUI->set_path'options''antispam' );
  40.  
  41. param'action''string' );
  42.  
  43. switch$action )
  44. {
  45.     case 'update':
  46.         // Check permission:
  47.         $current_User->check_perm'options''edit'true );
  48.  
  49.         param'submit''array'array() );
  50.         ifisset($submit['restore_defaults']) )
  51.         // RESTORE DEFAULTS:
  52.             $Settings->delete_arrayarray(
  53.                 'antispam_threshold_publish''antispam_threshold_delete''antispam_block_spam_referers' ) );
  54.  
  55.             // Set "spam detection relevance weight" back to 1 for all plugins:
  56.             $changed $DB->query'UPDATE T_plugins SET plug_spam_weight = 1' );
  57.  
  58.             if$Settings->dbupdate(|| $changed )
  59.             {
  60.                 $Messages->addT_('Restored default values.')'success' );
  61.             }
  62.             else
  63.             {
  64.                 $Messages->addT_('Settings have not changed.')'note' );
  65.             }
  66.         }
  67.         else
  68.         // UPDATE:
  69.             param_integer_range'antispam_threshold_publish'-100100T_('The threshold must be between -100 and 100.') );
  70.             $Settings->set'antispam_threshold_publish'$antispam_threshold_publish );
  71.  
  72.             param_integer_range'antispam_threshold_delete'-100100T_('The threshold must be between -100 and 100.') );
  73.             $Settings->set'antispam_threshold_delete'$antispam_threshold_delete );
  74.  
  75.             param'antispam_block_spam_referers''integer');
  76.             $Settings->set'antispam_block_spam_referers'$antispam_block_spam_referers );
  77.  
  78.             param'antispam_report_to_central''integer');
  79.             $Settings->set'antispam_report_to_central'$antispam_report_to_central );
  80.  
  81.             $changed_weight false;
  82.             param'antispam_plugin_spam_weight''array'array() );
  83.             foreach$antispam_plugin_spam_weight as $l_plugin_ID => $l_weight )
  84.             {
  85.                 ifis_numeric($l_weight) )
  86.                 {
  87.                     continue;
  88.                 }
  89.                 if$l_weight || $l_weight 100 )
  90.                 {
  91.                     param_error'antispam_plugin_spam_weight['.$l_plugin_ID.']'T_('Spam weight has to be in the range of 0-100.') );
  92.                     continue;
  93.                 }
  94.                 if$DB->query'
  95.                         UPDATE T_plugins
  96.                            SET plug_spam_weight = '.$DB->quote($l_weight).'
  97.                          WHERE plug_ID = '.(int)$l_plugin_ID ) )
  98.                 {
  99.                     $changed_weight true;
  100.                 }
  101.             }
  102.             if$changed_weight )
  103.             // Reload plugins table (for display):
  104.                 $Plugins->loaded_plugins_table false;
  105.                 $Plugins->load_plugins_table();
  106.             }
  107.  
  108.  
  109.             if$Messages->count('error') )
  110.             {
  111.                 if$Settings->dbupdate(|| $changed_weight )
  112.                 {
  113.                     $Messages->addT_('Settings updated.')'success' );
  114.                 }
  115.                 else
  116.                 {
  117.                     $Messages->addT_('Settings have not changed.')'note' );
  118.                 }
  119.             }
  120.         }
  121.         break;
  122. }
  123.  
  124.  
  125. // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)
  126. $AdminUI->disp_html_head();
  127.  
  128. // Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)
  129. $AdminUI->disp_body_top();
  130.  
  131. // Begin payload block:
  132. $AdminUI->disp_payload_begin();
  133.  
  134. // Display VIEW:
  135. $AdminUI->disp_view'antispam/views/_antispam_settings.form.php' );
  136.  
  137. // End payload block:
  138. $AdminUI->disp_payload_end();
  139.  
  140. // Display body bottom, debug info and close </html>:
  141. $AdminUI->disp_global_footer();
  142.  
  143. ?>