Glaisher has uploaded a new change for review. https://gerrit.wikimedia.org/r/283997
Change subject: Remove duplicated code related to block flag in Special:CheckUser ...................................................................... Remove duplicated code related to block flag in Special:CheckUser * Also use 'parentheses' msg instead of hardcoded parentheses Change-Id: Icf7dc28076cd6ff0899cb513dfa2de451e3eb662 --- M specials/SpecialCheckUser.php 1 file changed, 45 insertions(+), 76 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CheckUser refs/changes/97/283997/1 diff --git a/specials/SpecialCheckUser.php b/specials/SpecialCheckUser.php index ea7c300..421d5c3 100644 --- a/specials/SpecialCheckUser.php +++ b/specials/SpecialCheckUser.php @@ -570,41 +570,46 @@ protected function getIPBlockInfo( $ip ) { $block = Block::newFromTarget( null, $ip, false ); if ( $block instanceof Block ) { - if ( $block->getType() == Block::TYPE_RANGE ) { - $userpage = Title::makeTitle( NS_USER, $block->getTarget() ); - $blocklog = Linker::linkKnown( - SpecialPage::getTitleFor( 'Log' ), - $this->msg( 'checkuser-blocked' )->escaped(), - array(), - array( - 'type' => 'block', - 'page' => $userpage->getPrefixedText() - ) - ); - return ' <strong>(' . $blocklog . ' - ' . $block->getTarget() . ')</strong>'; - } elseif ( $block->getType() == Block::TYPE_AUTO ) { - $blocklog = Linker::linkKnown( - SpecialPage::getTitleFor( 'BlockList' ), - $this->msg( 'checkuser-blocked' )->escaped(), - array(), - array( 'ip' => "#{$block->getId()}" ) - ); - return ' <strong>(' . $blocklog . ')</strong>'; - } else { - $userpage = Title::makeTitle( NS_USER, $block->getTarget() ); - $blocklog = Linker::linkKnown( - SpecialPage::getTitleFor( 'Log' ), - $this->msg( 'checkuser-blocked' )->escaped(), - array(), - array( - 'type' => 'block', - 'page' => $userpage->getPrefixedText() - ) - ); - return ' <strong>(' . $blocklog . ')</strong>'; - } + return $this->getBlockFlag( $block ); } return ''; + } + + /** + * Get a link to block information about the passed block for displaying to the user. + * + * @param Block $block + * @return string + */ + protected function getBlockFlag( Block $block ) { + if ( $block->getType() == Block::TYPE_AUTO ) { + $ret = Linker::linkKnown( + SpecialPage::getTitleFor( 'BlockList' ), + $this->msg( 'checkuser-blocked' )->escaped(), + array(), + array( 'wpTarget' => "#{$block->getId()}" ) + ); + } else { + $userPage = Title::makeTitle( NS_USER, $block->getTarget() ); + $ret = Linker::linkKnown( + SpecialPage::getTitleFor( 'Log' ), + $this->msg( 'checkuser-blocked' )->escaped(), + array(), + array( + 'type' => 'block', + 'page' => $userPage->getPrefixedText() + ) + ); + } + + // Add the blocked range if the block is on a range + if ( $block->getType() == Block::TYPE_RANGE ) { + $ret .= ' - ' . htmlspecialchars( $block->getTarget() ); + } + + return '<strong>' . + $this->msg( 'parentheses' )->rawParams( $ret )->escaped() + . '</strong>'; } /** @@ -1202,56 +1207,20 @@ */ protected function userBlockFlags( $ip, $userId, $user ) { global $wgAuth; - static $logs, $blocklist; - $logs = SpecialPage::getTitleFor( 'Log' ); - $blocklist = SpecialPage::getTitleFor( 'BlockList' ); - $block = Block::newFromTarget( $user, $ip, false ); $flags = array(); + + $block = Block::newFromTarget( $user, $ip, false ); if ( $block instanceof Block ) { - // Range blocked? - if ( $block->getType() == Block::TYPE_RANGE ) { - $userpage = Title::makeTitle( NS_USER, $block->getTarget() ); - $blocklog = Linker::linkKnown( - $logs, - $this->msg( 'checkuser-blocked' )->escaped(), - array(), - array( - 'type' => 'block', - 'page' => $userpage->getPrefixedText() - ) - ); - $flags[] = '<strong>(' . $blocklog . ' - ' . $block->getTarget() . ')</strong>'; - // Auto blocked? - } elseif ( $block->getType() == Block::TYPE_AUTO ) { - $blocklog = Linker::linkKnown( - $blocklist, - $this->msg( 'checkuser-blocked' )->escaped(), - array(), - array( 'ip' => "#{$block->getId()}" ) - ); - // @todo FIXME: Hard coded parentheses. - $flags[] = '<strong>(' . $blocklog . ')</strong>'; - } else { - $userpage = $user->getUserPage(); - $blocklog = Linker::linkKnown( - $logs, - $this->msg( 'checkuser-blocked' )->escaped(), - array(), - array( - 'type' => 'block', - 'page' => $userpage->getPrefixedText() - ) - ); - // @todo FIXME: Hard coded parentheses. - $flags[] = '<strong>(' . $blocklog . ')</strong>'; - } - // IP that is blocked on all wikis? + // Locally blocked + $flags[] = $this->getBlockFlag( $block ); } elseif ( $ip == $user->getName() && $user->isBlockedGlobally( $ip ) ) { + // Globally blocked IP $flags[] = '<strong>(' . $this->msg( 'checkuser-gblocked' )->escaped() . ')</strong>'; } elseif ( self::userWasBlocked( $user->getName() ) ) { + // Previously blocked $userpage = $user->getUserPage(); $blocklog = Linker::linkKnown( - $logs, + SpecialPage::getTitleFor( 'Log' ), $this->msg( 'checkuser-wasblocked' )->escaped(), array(), array( -- To view, visit https://gerrit.wikimedia.org/r/283997 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icf7dc28076cd6ff0899cb513dfa2de451e3eb662 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CheckUser Gerrit-Branch: master Gerrit-Owner: Glaisher <glaisher.w...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits