Don't show the form for restoring autopromotion to unprivileged users

Bug: T232881
Change-Id: I80c34c823f505c81e20f83ccf5c5a99e8e69b626
This commit is contained in:
Daimona Eaytoy 2019-09-13 20:31:17 +02:00
parent f4b555f113
commit ed2bc7badf
2 changed files with 22 additions and 18 deletions

View file

@ -40,22 +40,24 @@ class AbuseFilterViewTools extends AbuseFilterView {
$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 );
if ( AbuseFilter::canEdit( $this->getUser() ) ) {
// 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 );
}
}
}

View file

@ -110,6 +110,8 @@
$( function initialize() {
$( '#mw-abusefilter-submitexpr' ).on( 'click', doExprSubmit );
$( '#mw-abusefilter-reautoconfirmsubmit' ).on( 'click', doReautoSubmit );
if ( $( '#mw-abusefilter-reautoconfirmsubmit' ).length ) {
$( '#mw-abusefilter-reautoconfirmsubmit' ).on( 'click', doReautoSubmit );
}
} );
}() );