3
* This file implements the UI controller for Antispam Features.
5
* This file is part of Quam Plures - {@link http://quamplures.net/}
6
* See also {@link https://launchpad.net/quam-plures}.
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}.
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
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/).
27
* {@internal Below is a list of authors who have contributed to design/coding of this file: }}
28
* @author blueyed: Daniel HAHLER.
3
* $ctrl_mappings: 'aspm_settings' || Global settings -> Antispam
5
* @todo (1111): This should probably be turned into a plugin
7
* @author {@link http://wonderwinds.com/ Ed Bennett}
8
* @author {@link http://daniel.hahler.de/ Daniel HAHLER}
9
* @author {@link http://fplanque.net/ Francois PLANQUE}
10
* @copyright (c) 2009 by {@link http://quamplures.net/ the Quam Plures project}
11
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3
32
if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
35
// Check minimum permission:
14
if(!defined('QP_MAIN_INIT')) die('fail');
16
// Check minimum permission
36
17
$current_User->check_perm( 'options', 'view', true );
39
$AdminUI->set_path( 'options', 'antispam' );
19
$AdminUI->set_path( 'tools', 'antispam', 'saspm' );
41
21
param( 'action', 'string' );
47
$current_User->check_perm( 'options', 'edit', true );
49
param( 'submit', 'array', array() );
50
if( isset($submit['restore_defaults']) )
51
{ // RESTORE DEFAULTS:
52
$Settings->delete_array( array(
53
'antispam_threshold_publish', 'antispam_threshold_delete', 'antispam_block_spam_referers' ) );
55
// Set "spam detection relevance weight" back to 1 for all plugins:
56
$changed = $DB->query( 'UPDATE T_plugins SET plug_spam_weight = 1' );
58
if( $Settings->dbupdate() || $changed )
60
$Messages->add( T_('Restored default values.'), 'success' );
27
$current_User->check_perm( 'options', 'edit', true );
28
param( 'submit', 'array', array() );
29
if( isset( $submit['restore_defaults'] ) )
32
$Settings->delete_array( array(
33
'antispam_threshold_publish', 'antispam_threshold_delete', 'antispam_block_spam_referers' )
35
// Set "spam detection relevance weight" back to 1 for all plugins
36
$changed = $DB->query( 'UPDATE T_plugins SET plug_spam_weight = 1' );
38
if( $Settings->dbupdate() || $changed )
40
$Messages->add( T_('Restored default values.'), 'success' );
44
$Messages->add( T_('Settings have not changed.'), 'note' );
50
param_integer_range( 'antispam_threshold_publish', -100, 100, T_('The threshold must be between -100 and 100.') );
51
$Settings->set( 'antispam_threshold_publish', $antispam_threshold_publish );
52
param_integer_range( 'antispam_threshold_delete', -100, 100, T_('The threshold must be between -100 and 100.') );
53
$Settings->set( 'antispam_threshold_delete', $antispam_threshold_delete );
54
param( 'antispam_block_spam_referers', 'integer', 0 );
55
$Settings->set( 'antispam_block_spam_referers', $antispam_block_spam_referers );
56
param( 'antispam_report_to_central', 'integer', 0 );
57
$Settings->set( 'antispam_report_to_central', $antispam_report_to_central );
58
$changed_weight = false;
59
param( 'antispam_plugin_spam_weight', 'array', array() );
60
foreach( $antispam_plugin_spam_weight as $l_plugin_ID => $l_weight )
62
if( ! is_numeric( $l_weight ) )
66
if( $l_weight < 0 || $l_weight > 100 )
68
param_error( 'antispam_plugin_spam_weight['.$l_plugin_ID.']', T_('Spam weight has to be in the range of 0-100.') );
71
if( $DB->query( 'UPDATE T_plugins SET plug_spam_weight = '.$DB->quote( $l_weight ).' WHERE plug_ID = '.(int)$l_plugin_ID ) )
73
$changed_weight = true;
78
// Reload plugins table (for display)
79
$Plugins->loaded_plugins_table = false;
80
$Plugins->load_plugins_table();
83
if( ! $Messages->count('error') )
85
if( $Settings->dbupdate() || $changed_weight )
87
$Messages->add( T_('Settings updated.'), 'success' );
64
91
$Messages->add( T_('Settings have not changed.'), 'note' );
69
param_integer_range( 'antispam_threshold_publish', -100, 100, T_('The threshold must be between -100 and 100.') );
70
$Settings->set( 'antispam_threshold_publish', $antispam_threshold_publish );
72
param_integer_range( 'antispam_threshold_delete', -100, 100, T_('The threshold must be between -100 and 100.') );
73
$Settings->set( 'antispam_threshold_delete', $antispam_threshold_delete );
75
param( 'antispam_block_spam_referers', 'integer', 0 );
76
$Settings->set( 'antispam_block_spam_referers', $antispam_block_spam_referers );
78
param( 'antispam_report_to_central', 'integer', 0 );
79
$Settings->set( 'antispam_report_to_central', $antispam_report_to_central );
81
$changed_weight = false;
82
param( 'antispam_plugin_spam_weight', 'array', array() );
83
foreach( $antispam_plugin_spam_weight as $l_plugin_ID => $l_weight )
85
if( ! is_numeric($l_weight) )
89
if( $l_weight < 0 || $l_weight > 100 )
91
param_error( 'antispam_plugin_spam_weight['.$l_plugin_ID.']', T_('Spam weight has to be in the range of 0-100.') );
96
SET plug_spam_weight = '.$DB->quote($l_weight).'
97
WHERE plug_ID = '.(int)$l_plugin_ID ) )
99
$changed_weight = true;
102
if( $changed_weight )
103
{ // Reload plugins table (for display):
104
$Plugins->loaded_plugins_table = false;
105
$Plugins->load_plugins_table();
109
if( ! $Messages->count('error') )
111
if( $Settings->dbupdate() || $changed_weight )
113
$Messages->add( T_('Settings updated.'), 'success' );
117
$Messages->add( T_('Settings have not changed.'), 'note' );
125
// Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)
98
// Display <html><head>...</head> section (should be done early if actions do not redirect)
126
99
$AdminUI->disp_html_head();
128
// Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)
100
// Display title, menu, messages, etc... (messages MUST be displayed AFTER the actions)
129
101
$AdminUI->disp_body_top();
131
// Begin payload block:
102
// Begin payload block
132
103
$AdminUI->disp_payload_begin();
135
$AdminUI->disp_view( 'antispam/views/_antispam_settings.form.php' );
137
// End payload block:
104
// Display final (unbound) menu depth
105
echo $AdminUI->get_html_menu( array( 'tools', 'antispam' ), 'menu3' );
108
$AdminUI->disp_view( 'antispam/views/_settings.form.php' );
138
111
$AdminUI->disp_payload_end();
140
// Display body bottom, debug info and close </html>:
112
// Display body bottom, debug info, close </html>
141
113
$AdminUI->disp_global_footer();
b'\\ No newline at end of file'