mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-15 18:19:38 +00:00
c469fb4b76
There are lots of cases where we can inject a User object without additional efforts. Now $wgUser is only used inside AFComputedVariable, which is a little bit harder to handle because some instances of that class are serialized in the DB, and thus we cannot easily change the constructor until T213006 is resolved. This partly copies what Ia474f02dfeee8c7d067ee7e555c08cbfef08f6a6 tried to do, but adopting a different approach for various can*() methods: they're now static methods in the AbuseFilter class, so future callers don't need to instantiate an AbuseFilterView class. This also allows to re-use those methods in an API module for editing filters (T213037). Bug: T213037 Bug: T159299 Change-Id: I22743557e162fd23b3b4e52951a649d8c21109c8
62 lines
1.6 KiB
PHP
62 lines
1.6 KiB
PHP
<?php
|
|
|
|
class AbuseFilterViewTools extends AbuseFilterView {
|
|
/**
|
|
* Shows the page
|
|
*/
|
|
public function show() {
|
|
$out = $this->getOutput();
|
|
$out->enableOOUI();
|
|
$request = $this->getRequest();
|
|
|
|
if ( !AbuseFilter::canViewPrivate( $this->getUser() ) ) {
|
|
$out->addWikiMsg( 'abusefilter-mustviewprivateoredit' );
|
|
return;
|
|
}
|
|
|
|
// Header
|
|
$out->addWikiMsg( 'abusefilter-tools-text' );
|
|
|
|
// Expression evaluator
|
|
$eval = '';
|
|
$eval .= $this->buildEditBox(
|
|
$request->getText( 'wpFilterRules' ),
|
|
true,
|
|
false,
|
|
false
|
|
);
|
|
|
|
$eval .=
|
|
Xml::tags( 'p', null,
|
|
new OOUI\ButtonInputWidget( [
|
|
'label' => $this->msg( 'abusefilter-tools-submitexpr' )->text(),
|
|
'id' => 'mw-abusefilter-submitexpr'
|
|
] )
|
|
);
|
|
$eval .= Xml::element( 'p', [ 'id' => 'mw-abusefilter-expr-result' ], ' ' );
|
|
|
|
$eval = Xml::fieldset( $this->msg( 'abusefilter-tools-expr' )->text(), $eval );
|
|
$out->addHTML( $eval );
|
|
|
|
$out->addModules( 'ext.abuseFilter.tools' );
|
|
|
|
// Hacky little box to re-enable autoconfirmed if it got disabled
|
|
$formDescriptor = [
|
|
'RestoreAutoconfirmed' => [
|
|
'label-message' => 'abusefilter-tools-reautoconfirm-user',
|
|
'type' => 'user',
|
|
'name' => 'wpReAutoconfirmUser',
|
|
'id' => 'reautoconfirm-user',
|
|
'infusable' => true
|
|
],
|
|
];
|
|
$htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
|
|
$htmlForm->setWrapperLegendMsg( 'abusefilter-tools-reautoconfirm' )
|
|
->setSubmitTextMsg( 'abusefilter-tools-reautoconfirm-submit' )
|
|
->setSubmitName( 'wpReautoconfirmSubmit' )
|
|
->setSubmitId( 'mw-abusefilter-reautoconfirmsubmit' )
|
|
->prepareForm()
|
|
->displayForm( false );
|
|
}
|
|
}
|