Index: trunk/extensions/CheckUser/CheckUser_body.php |
— | — | @@ -364,7 +364,6 @@ |
365 | 365 | wfRestoreWarnings(); |
366 | 366 | |
367 | 367 | $logs = SpecialPage::getTitleFor( 'Log' ); |
368 | | - $blocklist = SpecialPage::getTitleFor( 'Ipblocklist' ); |
369 | 368 | $s = '<div id="checkuserresults"><ul>'; |
370 | 369 | foreach( $ips_edits as $ip => $edits ) { |
371 | 370 | $s .= '<li>'; |
— | — | @@ -397,25 +396,7 @@ |
398 | 397 | } |
399 | 398 | |
400 | 399 | # If this IP is blocked, give a link to the block log |
401 | | - $block = new Block(); |
402 | | - $block->fromMaster( false ); // use slaves |
403 | | - if( $block->load( $ip, 0 ) ) { |
404 | | - if( IP::isIPAddress($block->mAddress) && strpos($block->mAddress,'/') ) { |
405 | | - $userpage = Title::makeTitle( NS_USER, $block->mAddress ); |
406 | | - $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-blocked'), |
407 | | - 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) ); |
408 | | - $s .= ' <strong>(' . $blocklog . ' - ' . $block->mAddress . ')</strong>'; |
409 | | - } else if( $block->mAuto ) { |
410 | | - $blocklog = $this->sk->makeKnownLinkObj( $blocklist, wfMsgHtml('checkuser-blocked'), |
411 | | - 'ip=' . urlencode( "#$block->mId" ) ); |
412 | | - $s .= ' <strong>(' . $blocklog . ')</strong>'; |
413 | | - } else { |
414 | | - $userpage = Title::makeTitle( NS_USER, $ip ); |
415 | | - $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-blocked'), |
416 | | - 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) ); |
417 | | - $s .= ' <strong>(' . $blocklog . ')</strong>'; |
418 | | - } |
419 | | - } |
| 400 | + $s.= $this->getIPBlockInfo( $ip ); |
420 | 401 | $s .= "<div style='margin-left:5%'>"; |
421 | 402 | $s .= "<small>" . wfMsgExt('checkuser-toollinks',array('parseinline'),urlencode($ip)) . "</small>"; |
422 | 403 | $s .= "</div>"; |
— | — | @@ -426,6 +407,31 @@ |
427 | 408 | $wgOut->addHTML( $s ); |
428 | 409 | $dbr->freeResult( $ret ); |
429 | 410 | } |
| 411 | + |
| 412 | + protected function getIPBlockInfo( $ip ) { |
| 413 | + static $blocklist; |
| 414 | + $blocklist = SpecialPage::getTitleFor( 'Ipblocklist' ); |
| 415 | + $block = new Block(); |
| 416 | + $block->fromMaster( false ); // use slaves |
| 417 | + if( $block->load( $ip, 0 ) ) { |
| 418 | + if( IP::isIPAddress($block->mAddress) && strpos($block->mAddress,'/') ) { |
| 419 | + $userpage = Title::makeTitle( NS_USER, $block->mAddress ); |
| 420 | + $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-blocked'), |
| 421 | + 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) ); |
| 422 | + return ' <strong>(' . $blocklog . ' - ' . $block->mAddress . ')</strong>'; |
| 423 | + } else if( $block->mAuto ) { |
| 424 | + $blocklog = $this->sk->makeKnownLinkObj( $blocklist, wfMsgHtml('checkuser-blocked'), |
| 425 | + 'ip=' . urlencode( "#$block->mId" ) ); |
| 426 | + return ' <strong>(' . $blocklog . ')</strong>'; |
| 427 | + } else { |
| 428 | + $userpage = Title::makeTitle( NS_USER, $ip ); |
| 429 | + $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-blocked'), |
| 430 | + 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) ); |
| 431 | + return ' <strong>(' . $blocklog . ')</strong>'; |
| 432 | + } |
| 433 | + } |
| 434 | + return ''; |
| 435 | + } |
430 | 436 | |
431 | 437 | /** |
432 | 438 | * @param string $ip |
— | — | @@ -824,9 +830,6 @@ |
825 | 831 | } |
826 | 832 | $dbr->freeResult( $ret ); |
827 | 833 | |
828 | | - $logs = SpecialPage::getTitleFor( 'Log' ); |
829 | | - $blocklist = SpecialPage::getTitleFor( 'Ipblocklist' ); |
830 | | - |
831 | 834 | $action = $this->getTitle()->escapeLocalUrl( 'action=block' ); |
832 | 835 | $s = "<form name='checkuserblock' id='checkuserblock' action=\"$action\" method='post'>"; |
833 | 836 | $s .= '<div id="checkuserresults"><ul>'; |
— | — | @@ -850,37 +853,8 @@ |
851 | 854 | # Total edit count |
852 | 855 | $s .= ' [<strong>' . $count . '</strong>]<br />'; |
853 | 856 | # Check if this user or IP is blocked. If so, give a link to the block log... |
854 | | - $block = new Block(); |
855 | | - $block->fromMaster( false ); // use slaves |
856 | 857 | $ip = IP::isIPAddress( $name ) ? $name : ''; |
857 | | - $flags = array(); |
858 | | - if( $block->load( $ip, $users_ids[$name] ) ) { |
859 | | - // Range blocked? |
860 | | - if( IP::isIPAddress($block->mAddress) && strpos($block->mAddress,'/') ) { |
861 | | - $userpage = Title::makeTitle( NS_USER, $block->mAddress ); |
862 | | - $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-blocked'), |
863 | | - 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) ); |
864 | | - $flags[] = '<strong>(' . $blocklog . ' - ' . $block->mAddress . ')</strong>'; |
865 | | - // Auto blocked? |
866 | | - } else if( $block->mAuto ) { |
867 | | - $blocklog = $this->sk->makeKnownLinkObj( $blocklist, |
868 | | - wfMsgHtml('checkuser-blocked'), 'ip=' . urlencode( "#{$block->mId}" ) ); |
869 | | - $flags[] = '<strong>(' . $blocklog . ')</strong>'; |
870 | | - } else { |
871 | | - $userpage = Title::makeTitle( NS_USER, $name ); |
872 | | - $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-blocked'), |
873 | | - 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) ); |
874 | | - $flags[] = '<strong>(' . $blocklog . ')</strong>'; |
875 | | - } |
876 | | - // IP that is blocked on all wikis? |
877 | | - } else if( $ip === $name && $user->isBlockedGlobally( $ip ) ) { |
878 | | - $flags[] = '<strong>(' . wfMsgHtml('checkuser-gblocked') . ')</strong>'; |
879 | | - } else if( self::userWasBlocked( $name ) ) { |
880 | | - $userpage = Title::makeTitle( NS_USER, $name ); |
881 | | - $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-wasblocked'), |
882 | | - 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) ); |
883 | | - $flags[] = '<strong>(' . $blocklog . ')</strong>'; |
884 | | - } |
| 858 | + $flags = $this->userBlockFlags( $ip, $users_ids[$name], $name ); |
885 | 859 | # Show if account is local only |
886 | 860 | $authUser = $wgAuth->getUserInstance( $user ); |
887 | 861 | if( $user->getId() && $authUser->getId() === 0 ) { |
— | — | @@ -963,9 +937,47 @@ |
964 | 938 | |
965 | 939 | $wgOut->addHTML( $s ); |
966 | 940 | } |
| 941 | + |
| 942 | + protected function userBlockFlags( $ip, $userId, $name ) { |
| 943 | + static $logs, $blocklist; |
| 944 | + $logs = SpecialPage::getTitleFor( 'Log' ); |
| 945 | + $blocklist = SpecialPage::getTitleFor( 'Ipblocklist' ); |
| 946 | + $block = new Block(); |
| 947 | + $block->fromMaster( false ); // use slaves |
| 948 | + $flags = array(); |
| 949 | + if( $block->load( $ip, $userId ) ) { |
| 950 | + // Range blocked? |
| 951 | + if( IP::isIPAddress($block->mAddress) && strpos($block->mAddress,'/') ) { |
| 952 | + $userpage = Title::makeTitle( NS_USER, $block->mAddress ); |
| 953 | + $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-blocked'), |
| 954 | + 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) ); |
| 955 | + $flags[] = '<strong>(' . $blocklog . ' - ' . $block->mAddress . ')</strong>'; |
| 956 | + // Auto blocked? |
| 957 | + } else if( $block->mAuto ) { |
| 958 | + $blocklog = $this->sk->makeKnownLinkObj( $blocklist, |
| 959 | + wfMsgHtml('checkuser-blocked'), 'ip=' . urlencode( "#{$block->mId}" ) ); |
| 960 | + $flags[] = '<strong>(' . $blocklog . ')</strong>'; |
| 961 | + } else { |
| 962 | + $userpage = Title::makeTitle( NS_USER, $name ); |
| 963 | + $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-blocked'), |
| 964 | + 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) ); |
| 965 | + $flags[] = '<strong>(' . $blocklog . ')</strong>'; |
| 966 | + } |
| 967 | + // IP that is blocked on all wikis? |
| 968 | + } else if( $ip === $name && $user->isBlockedGlobally( $ip ) ) { |
| 969 | + $flags[] = '<strong>(' . wfMsgHtml('checkuser-gblocked') . ')</strong>'; |
| 970 | + } else if( self::userWasBlocked( $name ) ) { |
| 971 | + $userpage = Title::makeTitle( NS_USER, $name ); |
| 972 | + $blocklog = $this->sk->makeKnownLinkObj( $logs, wfMsgHtml('checkuser-wasblocked'), |
| 973 | + 'type=block&page=' . urlencode( $userpage->getPrefixedText() ) ); |
| 974 | + $flags[] = '<strong>(' . $blocklog . ')</strong>'; |
| 975 | + } |
| 976 | + return $flags; |
| 977 | + } |
967 | 978 | |
968 | 979 | /** |
969 | | - * @param $row |
| 980 | + * @param Row $row |
| 981 | + * @param string $reason |
970 | 982 | * @return a streamlined recent changes line with IP data |
971 | 983 | */ |
972 | 984 | protected function CUChangesLine( $row, $reason ) { |