2024-05-04 20:28:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace MediaWiki\Extension\ConfirmEdit;
|
|
|
|
|
2024-05-15 06:25:56 +00:00
|
|
|
use MediaWiki\Config\Config;
|
2024-05-04 20:28:51 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\Consequences\Parameters;
|
|
|
|
use MediaWiki\Extension\AbuseFilter\Hooks\AbuseFilterCustomActionsHook;
|
|
|
|
use MediaWiki\Extension\ConfirmEdit\AbuseFilter\CaptchaConsequence;
|
|
|
|
|
|
|
|
class AbuseFilterHooks implements AbuseFilterCustomActionsHook {
|
|
|
|
|
2024-05-15 06:25:56 +00:00
|
|
|
private Config $config;
|
|
|
|
|
|
|
|
public function __construct( Config $config ) {
|
|
|
|
$this->config = $config;
|
|
|
|
}
|
|
|
|
|
2024-05-04 20:28:51 +00:00
|
|
|
/** @inheritDoc */
|
|
|
|
public function onAbuseFilterCustomActions( array &$actions ): void {
|
2024-05-15 06:25:56 +00:00
|
|
|
$enabledActions = $this->config->get( 'ConfirmEditEnabledAbuseFilterCustomActions' );
|
|
|
|
if ( in_array( 'showcaptcha', $enabledActions ) ) {
|
|
|
|
$actions['showcaptcha'] = static function ( Parameters $params ): CaptchaConsequence {
|
|
|
|
return new CaptchaConsequence( $params );
|
|
|
|
};
|
|
|
|
}
|
2024-05-04 20:28:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|