$performer = $context->getUser();
$enablePartialBlocks = $context->getConfig()->get( 'EnablePartialBlocks' );
+ $isPartialBlock = $enablePartialBlocks &&
+ isset( $data['EditingRestriction'] ) &&
+ $data['EditingRestriction'] === 'partial';
// Handled by field validator callback
// self::validateTargetField( $data['Target'] );
return [ 'badaccess-group0' ];
}
+ if ( $isPartialBlock ) {
+ return [ 'ipb_hide_partial' ];
+ }
+
# Recheck params here...
if ( $type != Block::TYPE_USER ) {
$data['HideUser'] = false; # IP users should not be hidden
$block->isAutoblocking( $data['AutoBlock'] );
$block->mHideName = $data['HideUser'];
- if (
- $enablePartialBlocks &&
- isset( $data['EditingRestriction'] ) &&
- $data['EditingRestriction'] === 'partial'
- ) {
- $block->isSitewide( false );
+ if ( $isPartialBlock ) {
+ $block->isSitewide( false );
}
$reason = [ 'hookaborted' ];
"ipb_expiry_old": "Expiry time is in the past.",
"ipb_expiry_temp": "Hidden username blocks must be permanent.",
"ipb_hide_invalid": "Unable to suppress this account; it has more than {{PLURAL:$1|one edit|$1 edits}}.",
+ "ipb_hide_partial": "Hidden username blocks must be sitewide blocks.",
"ipb_already_blocked": "\"$1\" is already blocked.",
"ipb-needreblock": "$1 is already blocked. Do you want to change the settings?",
"ipb-otherblocks-header": "Other {{PLURAL:$1|block|blocks}}",
"ipb_expiry_old": "Used as error message in [[Special:Block]], if the expiry time is in the past.\n{{Identical|protect_expiry_old}}",
"ipb_expiry_temp": "Warning message displayed on [[Special:BlockIP]] if the option \"hide username\" is selected but the expiry time is not infinite.",
"ipb_hide_invalid": "Used as error message in [[Special:Block]].\n* $1 - Number of edits (Value of [[mw:Manual:$wgHideUserContribLimit]])",
+ "ipb_hide_partial": "Warning message displayed on [[Special:Block]] if the option \"hide username\" is selected but the block is a partial block.",
"ipb_already_blocked": "{{Identical|$1 is already blocked}}",
"ipb-needreblock": "Used in [[Special:Block]].\n* $1 - target username, can be used for GENDER support",
"ipb-otherblocks-header": "[[File:Special.Block with other blocks from GlobalBlocking and TorBlocks.png|thumb|Example]]\nUsed on [[Special:Block]] as header for other blocks, i.e. from GlobalBlocking or TorBlocks\n\nParameters:\n* $1 - number of blocks\nSee also:\n* {{msg-mw|Ipblocklist-otherblocks}}",
var blockTargetWidget = infuseIfExists( $( '#mw-bi-target' ) ),
anonOnlyField = infuseIfExists( $( '#mw-input-wpHardBlock' ).closest( '.oo-ui-fieldLayout' ) ),
enableAutoblockField = infuseIfExists( $( '#mw-input-wpAutoBlock' ).closest( '.oo-ui-fieldLayout' ) ),
+ hideUserWidget = infuseIfExists( $( '#mw-input-wpHideUser' ) ),
hideUserField = infuseIfExists( $( '#mw-input-wpHideUser' ).closest( '.oo-ui-fieldLayout' ) ),
watchUserField = infuseIfExists( $( '#mw-input-wpWatch' ).closest( '.oo-ui-fieldLayout' ) ),
expiryWidget = infuseIfExists( $( '#mw-input-wpExpiry' ) ),
// infinityValues are the values the SpecialBlock class accepts as infinity (sf. wfIsInfinity)
infinityValues = [ 'infinite', 'indefinite', 'infinity', 'never' ],
isIndefinite = infinityValues.indexOf( expiryValue ) !== -1,
- editingRestrictionValue = editingRestrictionWidget ? editingRestrictionWidget.getValue() : undefined,
- editingIsSelected = editingWidget ? editingWidget.isSelected() : false;
+ // editingRestrictionWidget only exists if partial blocks is enabled; if not, block must be sitewide
+ editingRestrictionValue = editingRestrictionWidget ? editingRestrictionWidget.getValue() : 'sitewide',
+ editingIsSelected = editingWidget ? editingWidget.isSelected() : false,
+ isSitewide = editingIsSelected && editingRestrictionValue === 'sitewide';
if ( enableAutoblockField ) {
enableAutoblockField.toggle( !isNonEmptyIp );
}
if ( hideUserField ) {
- hideUserField.toggle( !isNonEmptyIp && isIndefinite );
+ hideUserField.toggle( !isNonEmptyIp && isIndefinite && isSitewide );
+ if ( !hideUserField.isVisible() ) {
+ hideUserWidget.setSelected( false );
+ }
}
if ( anonOnlyField ) {
anonOnlyField.toggle( isIp || isEmpty );
editingRestrictionWidget.setDisabled( !editingIsSelected );
}
if ( pageRestrictionsWidget ) {
- pageRestrictionsWidget.setDisabled( !editingIsSelected || editingRestrictionValue === 'sitewide' );
+ pageRestrictionsWidget.setDisabled( !editingIsSelected || isSitewide );
}
if ( namespaceRestrictionsWidget ) {
- namespaceRestrictionsWidget.setDisabled( !editingIsSelected || editingRestrictionValue === 'sitewide' );
+ namespaceRestrictionsWidget.setDisabled( !editingIsSelected || isSitewide );
}
if ( preventTalkPageEdit && namespaceRestrictionsWidget ) {
// This option is disabled for partial blocks unless a namespace restriction