Allow to define custom actions and their callback functions

This commit is contained in:
Alexander K. 2011-11-06 01:15:55 +00:00
parent fcfaf6df5e
commit f128bd5931
Notes: Raimond Spekking 2012-03-12 20:46:25 +00:00
2 changed files with 16 additions and 0 deletions

View file

@ -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" );
}

View file

@ -166,3 +166,5 @@ $wgAbuseFilterIsCentral = false;
// Block duration
$wgAbuseFilterBlockDuration = 'indefinite';
$wgAbuseFilterCustomActionsHandlers = false;