X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialBlock.php;h=c18ae0e33651f2e4eba3b3d9d6a39ca6bf568057;hb=03000d40b7e5d8136ef28d1bd78c40fdd0776a12;hp=625e4aa946d5d891e9e42b1c1b19dee20049f2b4;hpb=0d0059d36e7494792378c020f5de6033985c3637;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index 625e4aa946..c18ae0e336 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -28,7 +28,7 @@ * @ingroup SpecialPage */ class SpecialBlock extends FormSpecialPage { - /** @var User User to be blocked, as passed either by parameter (url?wpTarget=Foo) + /** @var User|string|null User to be blocked, as passed either by parameter (url?wpTarget=Foo) * or as subpage (Special:Block/Foo) */ protected $target; @@ -330,8 +330,12 @@ class SpecialBlock extends FormSpecialPage { $otherBlockMessages = []; if ( $this->target !== null ) { + $targetName = $this->target; + if ( $this->target instanceof User ) { + $targetName = $this->target->getName(); + } # Get other blocks, i.e. from GlobalBlocking or TorBlock extension - Hooks::run( 'OtherBlockLogLink', [ &$otherBlockMessages, $this->target ] ); + Hooks::run( 'OtherBlockLogLink', [ &$otherBlockMessages, $targetName ] ); if ( count( $otherBlockMessages ) ) { $s = Html::rawElement( @@ -368,12 +372,13 @@ class SpecialBlock extends FormSpecialPage { $this->getOutput()->addModuleStyles( 'mediawiki.special' ); + $linkRenderer = $this->getLinkRenderer(); # Link to the user's contributions, if applicable if ( $this->target instanceof User ) { $contribsPage = SpecialPage::getTitleFor( 'Contributions', $this->target->getName() ); - $links[] = Linker::link( + $links[] = $linkRenderer->makeLink( $contribsPage, - $this->msg( 'ipb-blocklist-contribs', $this->target->getName() )->escaped() + $this->msg( 'ipb-blocklist-contribs', $this->target->getName() )->text() ); } @@ -388,21 +393,24 @@ class SpecialBlock extends FormSpecialPage { $message = $this->msg( 'ipb-unblock' )->parse(); $list = SpecialPage::getTitleFor( 'Unblock' ); } - $links[] = Linker::linkKnown( $list, $message, [] ); + $links[] = $linkRenderer->makeKnownLink( + $list, + new HtmlArmor( $message ) + ); # Link to the block list - $links[] = Linker::linkKnown( + $links[] = $linkRenderer->makeKnownLink( SpecialPage::getTitleFor( 'BlockList' ), - $this->msg( 'ipb-blocklist' )->escaped() + $this->msg( 'ipb-blocklist' )->text() ); $user = $this->getUser(); # Link to edit the block dropdown reasons, if applicable if ( $user->isAllowed( 'editinterface' ) ) { - $links[] = Linker::linkKnown( + $links[] = $linkRenderer->makeKnownLink( $this->msg( 'ipbreason-dropdown' )->inContentLanguage()->getTitle(), - $this->msg( 'ipb-edit-dropdown' )->escaped(), + $this->msg( 'ipb-edit-dropdown' )->text(), [], [ 'action' => 'edit' ] ); @@ -641,8 +649,10 @@ class SpecialBlock extends FormSpecialPage { return [ 'ipb-blockingself', 'ipb-confirmaction' ]; } } elseif ( $type == Block::TYPE_RANGE ) { + $user = null; $userId = 0; } elseif ( $type == Block::TYPE_IP ) { + $user = null; $target = $target->getName(); $userId = 0; } else { @@ -725,6 +735,7 @@ class SpecialBlock extends FormSpecialPage { return $reason; } + $priorBlock = null; # Try to insert block. Is there a conflicting block? $status = $block->insert(); if ( !$status ) { @@ -744,17 +755,16 @@ class SpecialBlock extends FormSpecialPage { # This returns direct blocks before autoblocks/rangeblocks, since we should # be sure the user is blocked by now it should work for our purposes $currentBlock = Block::newFromTarget( $target ); - if ( $block->equals( $currentBlock ) ) { return [ [ 'ipb_already_blocked', $block->getTarget() ] ]; } - # If the name was hidden and the blocking user cannot hide # names, then don't allow any block changes... if ( $currentBlock->mHideName && !$performer->isAllowed( 'hideuser' ) ) { return [ 'cant-see-hidden-user' ]; } + $priorBlock = clone $currentBlock; $currentBlock->isHardblock( $block->isHardblock() ); $currentBlock->prevents( 'createaccount', $block->prevents( 'createaccount' ) ); $currentBlock->mExpiry = $block->mExpiry; @@ -782,7 +792,7 @@ class SpecialBlock extends FormSpecialPage { $logaction = 'block'; } - Hooks::run( 'BlockIpComplete', [ $block, $performer ] ); + Hooks::run( 'BlockIpComplete', [ $block, $performer, $priorBlock ] ); # Set *_deleted fields if requested if ( $data['HideUser'] ) { @@ -818,9 +828,13 @@ class SpecialBlock extends FormSpecialPage { $blockIds = array_merge( [ $status['id'] ], $status['autoIds'] ); $logEntry->setRelations( [ 'ipb_id' => $blockIds ] ); $logId = $logEntry->insert(); + + if ( !empty( $data['Tags'] ) ) { + $logEntry->setTags( $data['Tags'] ); + } + $logEntry->publish( $logId ); - # Report to the user return true; }