*/
class SpecialBlock extends FormSpecialPage {
/** @var User|string|null User to be blocked, as passed either by parameter (url?wpTarget=Foo)
- * or as subpage (Special:Block/Foo) */
+ * or as subpage (Special:Block/Foo)
+ */
protected $target;
/** @var int DatabaseBlock::TYPE_ constant */
* @return bool|array
*/
public static function processForm( array $data, IContextSource $context ) {
- global $wgBlockAllowsUTEdit, $wgHideUserContribLimit;
-
$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'] );
-
# This might have been a hidden field or a checkbox, so interesting data
# can come from it
$data['Confirm'] = !in_array( $data['Confirm'], [ '', '0', null, false ], true );
}
# Recheck params here...
+ $hideUserContribLimit = $context->getConfig()->get( 'HideUserContribLimit' );
if ( $type != DatabaseBlock::TYPE_USER ) {
$data['HideUser'] = false; # IP users should not be hidden
} elseif ( !wfIsInfinity( $data['Expiry'] ) ) {
# Bad expiry.
return [ 'ipb_expiry_temp' ];
- } elseif ( $wgHideUserContribLimit !== false
- && $user->getEditCount() > $wgHideUserContribLimit
+ } elseif ( $hideUserContribLimit !== false
+ && $user->getEditCount() > $hideUserContribLimit
) {
# Typically, the user should have a handful of edits.
# Disallow hiding users with many edits for performance.
return [ [ 'ipb_hide_invalid',
- Message::numParam( $wgHideUserContribLimit ) ] ];
+ Message::numParam( $hideUserContribLimit ) ] ];
} elseif ( !$data['Confirm'] ) {
return [ 'ipb-confirmhideuser', 'ipb-confirmaction' ];
}
}
+ $blockAllowsUTEdit = $context->getConfig()->get( 'BlockAllowsUTEdit' );
+ $userTalkEditAllowed = !$blockAllowsUTEdit || !$data['DisableUTEdit'];
+ if ( !$userTalkEditAllowed &&
+ $isPartialBlock &&
+ !in_array( NS_USER_TALK, explode( "\n", $data['NamespaceRestrictions'] ) )
+ ) {
+ return [ 'ipb-prevent-user-talk-edit' ];
+ }
+
# Create block object.
$block = new DatabaseBlock();
$block->setTarget( $target );
$block->setReason( $data['Reason'][0] );
$block->setExpiry( $expiryTime );
$block->isCreateAccountBlocked( $data['CreateAccount'] );
- $block->isUsertalkEditAllowed( !$wgBlockAllowsUTEdit || !$data['DisableUTEdit'] );
+ $block->isUsertalkEditAllowed( $userTalkEditAllowed );
$block->isEmailBlocked( $data['DisableEmail'] );
$block->isHardblock( $data['HardBlock'] );
$block->isAutoblocking( $data['AutoBlock'] );
if ( $performer->getBlock() ) {
if ( $target instanceof User && $target->getId() == $performer->getId() ) {
# User is trying to unblock themselves
- // @TODO Ensure that the block does not apply to the `unblockself`
- // right.
if ( $performer->isAllowed( 'unblockself' ) ) {
return true;
# User blocked themselves and is now trying to reverse it