mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-09-24 02:38:16 +00:00
Allow to define custom actions and their callback functions
This commit is contained in:
parent
fcfaf6df5e
commit
f128bd5931
Notes:
Raimond Spekking
2012-03-12 20:46:25 +00:00
|
@ -935,6 +935,8 @@ class AbuseFilter {
|
|||
public static function takeConsequenceAction( $action, $parameters, $title,
|
||||
$vars, $rule_desc )
|
||||
{
|
||||
global $wgAbuseFilterCustomActionsHandlers;
|
||||
|
||||
$display = '';
|
||||
switch ( $action ) {
|
||||
case 'disallow':
|
||||
|
@ -1073,6 +1075,18 @@ class AbuseFilter {
|
|||
AbuseFilter::$tagsToSet[$actionID] = $parameters;
|
||||
break;
|
||||
default:
|
||||
if( is_array( $wgAbuseFilterCustomActionsHandlers ) &&
|
||||
in_array( $action, array_keys( $wgAbuseFilterCustomActionsHandlers ) ) )
|
||||
{
|
||||
$custom_function = $wgAbuseFilterCustomActionsHandlers[$action];
|
||||
if( is_callable( $custom_function ) ) {
|
||||
$ok = call_user_func( $custom_function, $action, $parameters, $title, $vars, $rule_desc );
|
||||
}
|
||||
if( $ok ) {
|
||||
$display .= wfMsgExt( 'abusefilter-' . $action, 'parseinline', array() ) . "<br />\n";
|
||||
}
|
||||
break;
|
||||
}
|
||||
wfDebugLog( 'AbuseFilter', "Unrecognised action $action" );
|
||||
}
|
||||
|
||||
|
|
|
@ -166,3 +166,5 @@ $wgAbuseFilterIsCentral = false;
|
|||
|
||||
// Block duration
|
||||
$wgAbuseFilterBlockDuration = 'indefinite';
|
||||
|
||||
$wgAbuseFilterCustomActionsHandlers = false;
|
Loading…
Reference in a new issue