https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114408

Revision: 114408
Author:   catrope
Date:     2012-03-21 21:28:09 +0000 (Wed, 21 Mar 2012)
Log Message:
-----------
Revert r111465, unreviewed.

All of these revisions are tagged with 'gerritmigration' and will be 
resubmitted into Gerrit after the Gerrit switchover. See also 
http://lists.wikimedia.org/pipermail/wikitech-l/2012-March/059124.html

Modified Paths:
--------------
    trunk/extensions/GlobalBlocking/ApiQueryGlobalBlocks.php
    trunk/extensions/GlobalBlocking/GlobalBlocking.class.php
    trunk/extensions/GlobalBlocking/SpecialGlobalBlock.php
    trunk/extensions/GlobalBlocking/SpecialGlobalBlockList.php
    trunk/extensions/GlobalBlocking/SpecialGlobalBlockStatus.php
    trunk/extensions/GlobalBlocking/SpecialRemoveGlobalBlock.php

Modified: trunk/extensions/GlobalBlocking/ApiQueryGlobalBlocks.php
===================================================================
--- trunk/extensions/GlobalBlocking/ApiQueryGlobalBlocks.php    2012-03-21 
20:49:43 UTC (rev 114407)
+++ trunk/extensions/GlobalBlocking/ApiQueryGlobalBlocks.php    2012-03-21 
21:28:09 UTC (rev 114408)
@@ -83,29 +83,30 @@
                }
                if(isset($params['ip'])) {
                        list($ip, $range) = IP::parseCIDR($params['ip']);
-                       if($ip && $range) {
+                       if($ip && $range)
+                       {
                                # We got a CIDR range
                                if($range < 16)
                                        $this->dieUsage('CIDR ranges broader 
than /16 are not accepted', 'cidrtoobroad');
                                $lower = wfBaseConvert($ip, 10, 16, 8, false);
                                $upper = wfBaseConvert($ip + pow(2, 32 - 
$range) - 1, 10, 16, 8, false);
-                       } else {
+                       }
+                       else
                                $lower = $upper = IP::toHex($params['ip']);
-                       }
                        $prefix = substr($lower, 0, 4);
-                       $this->addWhere( array(
-                                       "gb_range_start LIKE '$prefix%'",
-                                       "gb_range_start <= '$lower'",
-                                       "gb_range_end >= '$upper'"
-                               )
-                       );
+                       $this->addWhere(array(
+                               "gb_range_start LIKE '$prefix%'",
+                               "gb_range_start <= '$lower'",
+                               "gb_range_end >= '$upper'"
+                       ));
                }
 
                $res = $this->select(__METHOD__);
 
                $count = 0;
                foreach ( $res as $row ) {
-                       if(++$count > $params['limit']) {
+                       if(++$count > $params['limit'])
+                       {
                                // We've had enough
                                $this->setContinueEnumParameter('start', 
wfTimestamp(TS_ISO_8601, $row->gb_timestamp));
                                break;
@@ -113,12 +114,14 @@
                        $block = array();
                        if($fld_id)
                                $block['id'] = $row->gb_id;
-                       if($fld_address) {
+                       if($fld_address)
+                       {
                                $block['address'] = $row->gb_address;
                                if($row->gb_anon_only)
                                        $block['anononly'] = '';
                        }
-                       if($fld_by) {
+                       if($fld_by)
+                       {
                                $block['by'] = $row->gb_by;
                                $block['bywiki'] = $row->gb_by_wiki;
                        }
@@ -128,7 +131,8 @@
                                $block['expiry'] = 
Block::decodeExpiry($row->gb_expiry, TS_ISO_8601);
                        if($fld_reason)
                                $block['reason'] = $row->gb_reason;
-                       if($fld_range) {
+                       if($fld_range)
+                       {
                                $block['rangestart'] = 
IP::hexToQuad($row->gb_range_start);
                                $block['rangeend'] = 
IP::hexToQuad($row->gb_range_end);
                        }

Modified: trunk/extensions/GlobalBlocking/GlobalBlocking.class.php
===================================================================
--- trunk/extensions/GlobalBlocking/GlobalBlocking.class.php    2012-03-21 
20:49:43 UTC (rev 114407)
+++ trunk/extensions/GlobalBlocking/GlobalBlocking.class.php    2012-03-21 
21:28:09 UTC (rev 114408)
@@ -42,7 +42,7 @@
         */
        static function getUserBlockErrors( $user, $ip ) {
                static $result = null;
-
+               
                // Instance cache
                if ( !is_null( $result ) ) {
                        return $result;
@@ -57,7 +57,7 @@
                                // Block has been whitelisted.
                                return $result = array();
                        }
-
+                       
                        if ( $user->isAllowed( 'ipblock-exempt' ) || 
$user->isAllowed( 'globalblock-exempt' ) ) {
                                // User is exempt from IP blocks.
                                return $result = array();
@@ -72,10 +72,10 @@
                        } else {
                                $blockExpiry = $wgLang->timeanddate( 
wfTimestamp( TS_MW, $blockExpiry ), true );
                        }
-
+                       
                        $display_wiki = self::getWikiName( $block->gb_by_wiki );
                        $blockingUser = self::maybeLinkUserpage( 
$block->gb_by_wiki, $block->gb_by );
-
+                       
                        return $result = array( 'globalblocking-ipblocked',
                                $blockingUser, $display_wiki, 
$block->gb_reason, $blockTimestamp, $blockExpiry, $ip );
                }
@@ -95,7 +95,7 @@
                $hex_ip = IP::toHex( $ip );
                $ip_pattern = substr( $hex_ip, 0, 4 ) . '%'; // Don't bother 
checking blocks out of this /16.
 
-               $conds = array(
+               $conds = array( 
                        'gb_range_end>='.$dbr->addQuotes( $hex_ip ), // This 
block in the given range.
                        'gb_range_start<='.$dbr->addQuotes( $hex_ip ),
                        'gb_range_start like ' . $dbr->addQuotes( $ip_pattern ),
@@ -115,32 +115,32 @@
                global $wgGlobalBlockingDatabase;
                return wfGetDB( DB_MASTER, 'globalblocking', 
$wgGlobalBlockingDatabase );
        }
-
+       
        static function getGlobalBlockingSlave() {
                global $wgGlobalBlockingDatabase;
                return wfGetDB( DB_SLAVE, 'globalblocking', 
$wgGlobalBlockingDatabase );
        }
-
+       
        static function getGlobalBlockId( $ip ) {
                $dbr = GlobalBlocking::getGlobalBlockingSlave();
-
+       
                if (!($row = $dbr->selectRow( 'globalblocks', 'gb_id', array( 
'gb_address' => $ip ), __METHOD__ )))
                        return 0;
-
+       
                return $row->gb_id;
        }
-
+       
        static function purgeExpired() {
                // This is expensive. It involves opening a connection to a new 
master,
                // and doing a write query. We should only do it when a 
connection to the master
                // is already open (currently, when a global block is made).
                $dbw = GlobalBlocking::getGlobalBlockingMaster();
-
+               
                // Stand-alone transaction.
                $dbw->begin();
                $dbw->delete( 'globalblocks', 
array('gb_expiry<'.$dbw->addQuotes($dbw->timestamp())), __METHOD__ );
                $dbw->commit();
-
+               
                // Purge the global_block_whitelist table.
                // We can't be perfect about this without an expensive check on 
the master
                // for every single global block. However, we can be clever 
about it and store
@@ -151,7 +151,7 @@
                $dbw->delete( 'global_block_whitelist', array( 
'gbw_expiry<'.$dbw->addQuotes($dbw->timestamp())), __METHOD__ );
                $dbw->commit();
        }
-
+       
        static function getWhitelistInfo( $id = null, $address = null ) {
                if ($id != null) {
                        $conds = array( 'gbw_id' => $id );
@@ -161,10 +161,10 @@
                        //WTF?
                        throw new MWException( "Neither Block IP nor Block ID 
given for retrieving whitelist status" );
                }
-
+               
                $dbr = wfGetDB( DB_SLAVE );
                $row = $dbr->selectRow( 'global_block_whitelist', array( 
'gbw_by', 'gbw_reason' ), $conds, __METHOD__ );
-
+               
                if ($row == false) {
                        // Not whitelisted.
                        return false;
@@ -173,45 +173,45 @@
                        return array( 'user' => $row->gbw_by, 'reason' => 
$row->gbw_reason );
                }
        }
-
+       
        static function getWhitelistInfoByIP( $block_ip ) {
                return self::getWhitelistInfo( null, $block_ip );
        }
-
+       
        static function getWikiName( $wiki_id ) {
                if (class_exists('WikiMap')) {
                        // We can give more info than just the wiki id!
                        $wiki = WikiMap::getWiki( $wiki_id );
-
+                               
                        if ($wiki) {
                                return $wiki->getDisplayName();
                        }
                }
-
+               
                return $wiki_id;
        }
-
+       
        static function maybeLinkUserpage( $wiki_id, $user ) {
                if (class_exists( 'WikiMap')) {
                        $wiki = WikiMap::getWiki( $wiki_id );
-
+                       
                        if ($wiki) {
                                return "[".$wiki->getUrl( "User:$user" )." 
$user]";
                        }
                }
                return $user;
        }
-
+       
        static function insertBlock( $address, $reason, $expiry, $options = 
array() ) {
                global $wgUser;
                $errors = array();
-
+               
                ## Purge expired blocks.
                GlobalBlocking::purgeExpired();
 
                ## Validate input
                $ip = IP::sanitizeIP( $address );
-
+               
                $anonOnly = in_array( 'anon-only', $options );
                $modify = in_array( 'modify', $options );
 
@@ -219,37 +219,37 @@
                        // Invalid IP address.
                        $errors[] = array( 'globalblocking-block-ipinvalid', 
$ip );
                }
-
+               
                if ( false === $expiry ) {
                        $errors[] = array( 
'globalblocking-block-expiryinvalid', $expiry );
                }
-
+               
                $existingBlock = GlobalBlocking::getGlobalBlockId($ip);
                if ( !$modify && $existingBlock ) {
                        $errors[] = array( 
'globalblocking-block-alreadyblocked', $ip );
                }
-
+       
                // Check for too-big ranges.
                list( $range_start, $range_end ) = IP::parseRange( $ip );
-
+               
                if (substr( $range_start, 0, 4 ) != substr( $range_end, 0, 4 )) 
{
                        // Range crosses a /16 boundary.
                        $errors[] = array( 'globalblocking-block-bigrange', $ip 
);
                }
-
+               
                // Normalise the range
                if ($range_start != $range_end) {
                        $ip = Block::normaliseRange( $ip );
                }
-
+               
                if (count($errors)>0)
                        return $errors;
 
                // We're a-ok.
                $dbw = GlobalBlocking::getGlobalBlockingMaster();
-
+               
                // Delete the old block, if applicable
-
+               
                if ($modify) {
                        $dbw->delete( 'globalblocks', array( 'gb_id' => 
$existingBlock ), __METHOD__ );
                }
@@ -265,36 +265,36 @@
                list( $row['gb_range_start'], $row['gb_range_end'] ) = array( 
$range_start, $range_end );
 
                $dbw->insert( 'globalblocks', $row, __METHOD__ );
-
+               
                return array();
        }
-
+       
        static function block( $address, $reason, $expiry, $options = array() ) 
{
                global $wgContLang;
-
+               
                $expiry = SpecialBlock::parseExpiryInput( $expiry );
                $errors = self::insertBlock( $address, $reason, $expiry, 
$options );
-
+               
                if ( count($errors) > 0 )
                        return $errors;
-
+       
                $anonOnly = in_array( 'anon-only', $options );
                $modify = in_array( 'modify', $options );
 
                // Log it.
                $logAction = $modify ? 'modify' : 'gblock2';
                $flags = array();
-
+               
                if ($anonOnly)
                        $flags[] = wfMsgForContent( 
'globalblocking-list-anononly' );
-
+               
                if ( $expiry != 'infinity' ) {
                        $displayExpiry = $wgContLang->timeanddate( $expiry );
                        $flags[] = wfMsgForContent( 
'globalblocking-logentry-expiry', $displayExpiry );
                } else {
                        $flags[] = wfMsgForContent( 
'globalblocking-logentry-noexpiry' );
                }
-
+               
                $info = implode( ', ', $flags );
 
                $page = new LogPage( 'gblblock' );
@@ -306,10 +306,10 @@
 
                return array();
        }
-
+       
        static function onSpecialPasswordResetOnSubmit( &$users, $data, &$error 
) {
                global $wgUser;
-
+               
                if ( GlobalBlocking::getUserBlockErrors( $wgUser, wfGetIp() ) ) 
{
                        $error = wfMsg( 'globalblocking-blocked-nopassreset' );
                        return false;
@@ -342,7 +342,6 @@
                );
                return true;
        }
-
        /**
         * Build links to other global blocking special pages, shown in the 
subtitle
         * @param string $pagetype The calling special page name
@@ -353,29 +352,30 @@
 
                // Add a few useful links
                $links = array();
+               $sk = $wgUser->getSkin();
 
                // Don't show a link to a special page on the special page 
itself.
                // Show the links only if the user has sufficient rights
                if( $pagetype != 'GlobalBlockList' ) {
                        $title = SpecialPage::getTitleFor( 'GlobalBlockList' );
-                       $links[] = Linker::linkKnown( $title, wfMsg( 
'globalblocklist' ) );
+                       $links[] = $sk->linkKnown( $title, wfMsg( 
'globalblocklist' ) );
                }
 
                if( $pagetype != 'GlobalBlock' && $wgUser->isAllowed( 
'globalblock' ) ) {
                        $title = SpecialPage::getTitleFor( 'GlobalBlock' );
-                       $links[] = Linker::linkKnown( $title, wfMsg( 
'globalblocking-goto-block' ) );
+                       $links[] = $sk->linkKnown( $title, wfMsg( 
'globalblocking-goto-block' ) );
                }
                if( $pagetype != 'RemoveGlobalBlock' && $wgUser->isAllowed( 
'globalunblock' ) ) {
                        $title = SpecialPage::getTitleFor( 'RemoveGlobalBlock' 
);
-                       $links[] = Linker::linkKnown( $title, wfMsg( 
'globalblocking-goto-unblock' ) );
+                       $links[] = $sk->linkKnown( $title, wfMsg( 
'globalblocking-goto-unblock' ) );
                }
                if( $pagetype != 'GlobalBlockStatus' && $wgUser->isAllowed( 
'globalblock-whitelist' ) ) {
                        $title = SpecialPage::getTitleFor( 'GlobalBlockStatus' 
);
-                       $links[] = Linker::linkKnown( $title, wfMsg( 
'globalblocking-goto-status' ) );
+                       $links[] = $sk->linkKnown( $title, wfMsg( 
'globalblocking-goto-status' ) );
                }
                if( $pagetype == 'GlobalBlock' && $wgUser->isAllowed( 
'editinterface' ) ) {
                        $title = Title::makeTitle( NS_MEDIAWIKI, 
'Globalblocking-block-reason-dropdown' );
-                       $links[] = Linker::linkKnown( $title, wfMsg( 
'globalblocking-block-edit-dropdown' ), array(), array( 'action' => 'edit' ) );
+                       $links[] = $sk->linkKnown( $title, wfMsg( 
'globalblocking-block-edit-dropdown' ), array(), array( 'action' => 'edit' ) );
                }
                $linkItems = count( $links ) ? wfMsg( 'parentheses', 
$wgLang->pipeList( $links ) ) : '';
                return $linkItems;

Modified: trunk/extensions/GlobalBlocking/SpecialGlobalBlock.php
===================================================================
--- trunk/extensions/GlobalBlocking/SpecialGlobalBlock.php      2012-03-21 
20:49:43 UTC (rev 114407)
+++ trunk/extensions/GlobalBlocking/SpecialGlobalBlock.php      2012-03-21 
21:28:09 UTC (rev 114408)
@@ -10,17 +10,16 @@
        }
 
        function execute( $par ) {
-               global $wgUser;
+               global $wgOut, $wgRequest, $wgUser;
                $this->setHeaders();
 
                $this->loadParameters( $par );
 
-               $out = $this->getOutput();
-               $out->setPageTitle( wfMsg( 'globalblocking-block' ) );
-               $out->setSubtitle( GlobalBlocking::buildSubtitleLinks( 
'GlobalBlock' ) );
-               $out->setRobotPolicy( "noindex,nofollow" );
-               $out->setArticleRelated( false );
-               $out->enableClientCache( false );
+               $wgOut->setPageTitle( wfMsg( 'globalblocking-block' ) );
+               $wgOut->setSubtitle( GlobalBlocking::buildSubtitleLinks( 
'GlobalBlock' ) );
+               $wgOut->setRobotPolicy( "noindex,nofollow" );
+               $wgOut->setArticleRelated( false );
+               $wgOut->enableClientCache( false );
 
                if (!$this->userCanExecute( $wgUser )) {
                        $this->displayRestrictionError();
@@ -29,8 +28,7 @@
 
                $errors = '';
 
-               $request = $this->getRequest();
-               if ( $request->wasPosted() && $wgUser->matchEditToken( 
$request->getVal( 'wpEditToken' ) ) ) {
+               if ($wgRequest->wasPosted() && $wgUser->matchEditToken( 
$wgRequest->getVal( 'wpEditToken' ))) {
                        // They want to submit. Let's have a look.
                        $errors = $this->trySubmit();
                        if( !$errors ) {
@@ -116,14 +114,15 @@
        }
 
        function trySubmit() {
+               global $wgOut, $wgUser;
                $options = array();
+               $skin = $wgUser->getSkin();
 
                if ($this->mAnonOnly)
                        $options[] = 'anon-only';
                if ($this->mModify)
                        $options[] = 'modify';
 
-               $out = $this->getOutput();
                $reasonstr = $this->mReasonList;
                if( $reasonstr != 'other' && $this->mReason != '' ) {
                        // Entry from drop down menu + additional comment
@@ -146,12 +145,12 @@
                        $subMessage = 'globalblocking-block-successsub';
                }
 
-               $out->addWikitext( wfMsg($textMessage, $this->mAddress ) );
-               $out->setSubtitle( wfMsg( $subMessage ) );
+               $wgOut->addWikitext( wfMsg($textMessage, $this->mAddress ) );
+               $wgOut->setSubtitle( wfMsg( $subMessage ) );
 
-               $link = Linker::link( SpecialPage::getTitleFor( 
'GlobalBlockList' ),
+               $link = $skin->link( SpecialPage::getTitleFor( 
'GlobalBlockList' ),
                                                        wfMsg( 
'globalblocking-return' ) );
-               $out->addHTML( $link );
+               $wgOut->addHTML( $link );
 
                return array();
        }

Modified: trunk/extensions/GlobalBlocking/SpecialGlobalBlockList.php
===================================================================
--- trunk/extensions/GlobalBlocking/SpecialGlobalBlockList.php  2012-03-21 
20:49:43 UTC (rev 114407)
+++ trunk/extensions/GlobalBlocking/SpecialGlobalBlockList.php  2012-03-21 
21:28:09 UTC (rev 114408)
@@ -8,22 +8,23 @@
        }
 
        function execute( $par ) {
-               $out = $this->getOutput();
+               global $wgOut, $wgRequest;
+
                $this->setHeaders();
-               $ip = isset( $par ) ? $par : $this->getRequest()->getText( 'ip' 
);
+               $ip = isset( $par ) ? $par : $wgRequest->getText( 'ip' );
                $this->loadParameters( $ip );
 
-               $out->setPageTitle( wfMsg( 'globalblocking-list' ) );
-               $out->setSubtitle( GlobalBlocking::buildSubtitleLinks( 
'GlobalBlockList' ) );
-               $out->setRobotPolicy( "noindex,nofollow" );
-               $out->setArticleRelated( false );
-               $out->enableClientCache( false );
+               $wgOut->setPageTitle( wfMsg( 'globalblocking-list' ) );
+               $wgOut->setSubtitle( GlobalBlocking::buildSubtitleLinks( 
'GlobalBlockList' ) );
+               $wgOut->setRobotPolicy( "noindex,nofollow" );
+               $wgOut->setArticleRelated( false );
+               $wgOut->enableClientCache( false );
 
                $this->showList();
        }
 
        function showList( ) {
-               global $wgScript;
+               global $wgOut, $wgScript;
                $errors = array();
 
                // Validate search IP
@@ -33,8 +34,8 @@
                        $ip = '';
                }
 
-               $out = $this->getOutput();
-               $out->addWikiMsg( 'globalblocking-list-intro' );
+               $wgOut->addWikiMsg( 'globalblocking-list-intro' );
+               
 
                // Build the search form
                $searchForm = '';
@@ -45,7 +46,7 @@
 
                if (is_array($errors) && count($errors)>0) {
                        $errorstr = '';
-
+                       
                        foreach ( $errors as $error ) {
                                if (is_array($error)) {
                                        $msg = array_shift($error);
@@ -53,12 +54,12 @@
                                        $msg = $error;
                                        $error = array();
                                }
-
+                               
                                $errorstr .= Xml::tags( 'li', null, wfMsgExt( 
$msg, array( 'parseinline' ), $error ) );
                        }
 
-                       $out->addWikiMsg( 'globalblocking-unblock-errors', 
count($errors) );
-                       $out->addHTML( Xml::tags( 'ul', array( 'class' => 
'error' ), $errorstr ) );
+                       $wgOut->addWikiMsg( 'globalblocking-unblock-errors', 
count($errors) );
+                       $wgOut->addHTML( Xml::tags( 'ul', array( 'class' => 
'error' ), $errorstr ) );
                }
 
                $fields = array();
@@ -66,24 +67,24 @@
                $searchForm .= Xml::buildForm( $fields, 
'globalblocking-search-submit' );
 
                $searchForm .= Xml::closeElement( 'form' ) . Xml::closeElement( 
'fieldset' );
-               $out->addHTML( $searchForm );
+               $wgOut->addHTML( $searchForm );
 
                // Build a list of blocks.
                $conds = array();
-
+               
                if (strlen($ip)) {
                        list ($range_start, $range_end) = IP::parseRange( $ip );
-
+                       
                        if ($range_start != $range_end) {
                                // They searched for a range. Match that exact 
range only
                                $conds = array( 'gb_address' => $ip );
                        } else {
-                               // They searched for an IP. Match any range 
covering that IP
+                               // They searched for an IP. Match any range 
covering that IP            
                                $hex_ip = IP::toHex( $ip );
                                $ip_pattern = substr( $hex_ip, 0, 4 ) . '%'; // 
Don't bother checking blocks out of this /16.
-
+                               
                                $dbr = wfGetDB( DB_SLAVE );
-
+                       
                                $conds = array( 
'gb_range_end>='.$dbr->addQuotes($hex_ip), // This block in the given range.
                                                
'gb_range_start<='.$dbr->addQuotes($hex_ip),
                                                'gb_range_start like ' . 
$dbr->addQuotes( $ip_pattern ),
@@ -94,11 +95,11 @@
                $pager = new GlobalBlockListPager( $this, $conds );
                $body = $pager->getBody();
                if( $body != '' ) {
-                       $out->addHTML( $pager->getNavigationBar() .
+                       $wgOut->addHTML( $pager->getNavigationBar() .
                                        Html::rawElement( 'ul', array(), $body 
) .
                                        $pager->getNavigationBar() );
                } else {
-                       $out->wrapWikiMsg( "<div 
class='mw-globalblocking-noresults'>\n$1</div>\n",
+                       $wgOut->wrapWikiMsg( "<div 
class='mw-globalblocking-noresults'>\n$1</div>\n",
                                array( 'globalblocking-list-noresults' ) );
                }
        }
@@ -124,12 +125,19 @@
 
        function formatRow( $row ) {
                global $wgLang, $wgUser;
-
+               
+               ## One-time setup
+               static $sk=null;
+               
+               if (is_null($sk)) {
+                       $sk = $wgUser->getSkin();
+               }
+               
                ## Setup
                $timestamp = $row->gb_timestamp;
                $expiry = $row->gb_expiry;
                $options = array();
-
+               
                # Messy B/C until $wgLang->formatExpiry() is well embedded
                if( Block::decodeExpiry( $expiry ) == 'infinity' ){
                        $options[] = wfMsgExt( 'infiniteblock', 'parseinline' );
@@ -142,24 +150,24 @@
                                $wgLang->time( $expiry )
                        );
                }
-
+               
                # Check for whitelisting.
                $wlinfo = GlobalBlocking::getWhitelistInfo( $row->gb_id );
                if ($wlinfo) {
                        $options[] = wfMsg( 'globalblocking-list-whitelisted', 
User::whois($wlinfo['user']), $wlinfo['reason'] );
                }
-
+               
                $timestamp = $wgLang->timeanddate( wfTimestamp( TS_MW, 
$timestamp ), true );
 
                if ($row->gb_anon_only)
                        $options[] = wfMsg('globalblocking-list-anononly');
-
+               
                ## Do afterthoughts (comment, links for admins)
                $info = array();
 
                if( $wgUser->isAllowed( 'globalunblock' ) ) {
                        $unblockTitle = SpecialPage::getTitleFor( 
"RemoveGlobalBlock" );
-                       $info[] = Linker::link( $unblockTitle,
+                       $info[] = $sk->link( $unblockTitle, 
                                                                wfMsgExt( 
'globalblocking-list-unblock', 'parseinline' ),
                                                                array(),
                                                                array( 
'address' => $row->gb_address )
@@ -169,7 +177,7 @@
                global $wgApplyGlobalBlocks;
                if( $wgUser->isAllowed( 'globalblock-whitelist' ) && 
$wgApplyGlobalBlocks ) {
                        $whitelistTitle = SpecialPage::getTitleFor( 
"GlobalBlockStatus" );
-                       $info[] = Linker::link( $whitelistTitle,
+                       $info[] = $sk->link( $whitelistTitle, 
                                                                wfMsgExt( 
'globalblocking-list-whitelist', 'parseinline' ),
                                                                array(),
                                                                array( 
'address' => $row->gb_address )
@@ -179,7 +187,7 @@
                if ( $wgUser->isAllowed( 'globalblock' ) ) {
                        $reblockTitle = SpecialPage::getTitleFor( 'GlobalBlock' 
);
                        $msg = wfMsgExt( 'globalblocking-list-modify', 
'parseinline' );
-                       $info[] = Linker::link(
+                       $info[] = $sk->link(
                                                $reblockTitle,
                                                $msg,
                                                array(),
@@ -201,7 +209,7 @@
                                        $row->gb_address,
                                        $wgLang->commaList( $options )
                                        ) . ' ' .
-                                               Linker::commentBlock( 
$row->gb_reason ) . ' ' .
+                               $sk->commentBlock( $row->gb_reason ) . ' ' .
                                $infoItems
                        );
        }

Modified: trunk/extensions/GlobalBlocking/SpecialGlobalBlockStatus.php
===================================================================
--- trunk/extensions/GlobalBlocking/SpecialGlobalBlockStatus.php        
2012-03-21 20:49:43 UTC (rev 114407)
+++ trunk/extensions/GlobalBlocking/SpecialGlobalBlockStatus.php        
2012-03-21 21:28:09 UTC (rev 114408)
@@ -8,33 +8,31 @@
        }
 
        function execute( $par ) {
-               global $wgUser;
+               global $wgOut, $wgRequest, $wgUser;
                $this->setHeaders();
 
                $this->loadParameters();
 
-               $out = $this->getOutput();
-               $out->setPageTitle( wfMsg( 'globalblocking-whitelist' ) );
-               $out->setSubtitle( GlobalBlocking::buildSubtitleLinks( 
'GlobalBlockStatus' ) );
-               $out->setRobotPolicy( "noindex,nofollow" );
-               $out->setArticleRelated( false );
-               $out->enableClientCache( false );
+               $wgOut->setPageTitle( wfMsg( 'globalblocking-whitelist' ) );
+               $wgOut->setSubtitle( GlobalBlocking::buildSubtitleLinks( 
'GlobalBlockStatus' ) );
+               $wgOut->setRobotPolicy( "noindex,nofollow" );
+               $wgOut->setArticleRelated( false );
+               $wgOut->enableClientCache( false );
 
                if (!$this->userCanExecute( $wgUser )) {
                        $this->displayRestrictionError();
                        return;
                }
-
+               
                global $wgApplyGlobalBlocks;
                if (!$wgApplyGlobalBlocks) {
-                       $out->addWikiMsg( 'globalblocking-whitelist-notapplied' 
);
+                       $wgOut->addWikiMsg( 
'globalblocking-whitelist-notapplied' );
                        return;
                }
 
                $errors = '';
 
-               $request = $this->getRequest();
-               if ( $request->wasPosted() && $wgUser->matchEditToken( 
$request->getVal( 'wpEditToken' ) ) ) {
+               if ($wgRequest->wasPosted() && $wgUser->matchEditToken( 
$wgRequest->getVal( 'wpEditToken' ))) {
                        // They want to submit. Let's have a look.
                        $errors = $this->trySubmit();
                        if( !$errors ) {
@@ -42,11 +40,11 @@
                                return;
                        }
                }
-
+               
                $errorstr = '';
 
                if (is_array($errors) && count($errors)>0) {
-
+                       
                        foreach ( $errors as $error ) {
                                if (is_array($error)) {
                                        $msg = array_shift($error);
@@ -59,27 +57,28 @@
 
                        $errorstr = wfMsgExt( 
'globalblocking-whitelist-errors', array( 'parse' ), array( count( $errors ) ) 
) .
                                Xml::tags( 'ul', array( 'class' => 'error' ), 
$errorstr );
-
+                               
                        $errorstr = Xml::tags( 'div', array( 'class' => 'error' 
), $errorstr );
                }
-
+               
                $this->form( $errorstr );
+
        }
 
        function loadParameters() {
-               $request = $this->getRequest();
-               $ip = trim( $request->getText( 'address' ) );
-               $this->mAddress = ( $ip !== '' || $request->wasPosted() )
+               global $wgRequest;
+               $ip = trim( $wgRequest->getText( 'address' ) );
+               $this->mAddress = ( $ip !== '' || $wgRequest->wasPosted() )
                        ? Block::normaliseRange( $ip )
                        : '';
-               $this->mReason = $request->getText( 'wpReason' );
-               $this->mWhitelistStatus = $request->getCheck( 
'wpWhitelistStatus' );
-               $this->mEditToken = $request->getText( 'wpEditToken' );
-
+               $this->mReason = $wgRequest->getText( 'wpReason' );
+               $this->mWhitelistStatus = $wgRequest->getCheck( 
'wpWhitelistStatus' );
+               $this->mEditToken = $wgRequest->getText( 'wpEditToken' );
+               
                if ( $this->mAddress ) {
-                       $this->mCurrentStatus = ( 
GlobalBlocking::getWhitelistInfoByIP( $this->mAddress ) !== false);
-
-                       if ( !$request->wasPosted() ) {
+                       $this->mCurrentStatus = 
(GlobalBlocking::getWhitelistInfoByIP( $this->mAddress ) !== false);
+                       
+                       if ( !$wgRequest->wasPosted() ) {
                                $this->mWhitelistStatus = $this->mCurrentStatus;
                        }
                } else {
@@ -88,65 +87,63 @@
        }
 
        function trySubmit() {
-               global $wgUser;
-
+               global $wgOut,$wgUser;
+               
                $ip = $this->mAddress;
-
+               
                // Is it blocked?
                if ( !($id = GlobalBlocking::getGlobalBlockId( $ip ) ) ) {
                        return array( array( 'globalblocking-notblocked', $ip ) 
);
                }
-
+               
                $new_status = $this->mWhitelistStatus;
                $cur_status = $this->mCurrentStatus;
-
+               
                // Already whitelisted.
                if ($cur_status == $new_status) {
                        return array('globalblocking-whitelist-nochange');
                }
 
                $dbw = wfGetDB( DB_MASTER );
-
-               $out = $this->getOutput();
+               
                if ($new_status == true) {
                        $gdbr = GlobalBlocking::getGlobalBlockingSlave();
-
+                       
                        // Find the expiry of the block. This is important so 
that we can store it in the
                        // global_block_whitelist table, which allows us to 
purge it when the block has expired.
                        $expiry = $gdbr->selectField( 'globalblocks', 
'gb_expiry', array( 'gb_id' => $id ), __METHOD__ );
-
+                       
                        $row = array('gbw_by' => $wgUser->getId(), 
'gbw_by_text' => $wgUser->getName(), 'gbw_reason' => $this->mReason, 
'gbw_address' => $ip, 'gbw_expiry' => $expiry, 'gbw_id' => $id);
                        $dbw->replace( 'global_block_whitelist', array( 
'gbw_id' ), $row, __METHOD__ );
 
                        $page = new LogPage( 'gblblock' );
                        $page->addEntry( 'whitelist', Title::makeTitleSafe( 
NS_USER, $ip ), $this->mReason );
-
-                       $out->addWikiMsg( 
'globalblocking-whitelist-whitelisted', $ip, $id );
+                       
+                       $wgOut->addWikiMsg( 
'globalblocking-whitelist-whitelisted', $ip, $id );
                } else {
                        // Delete the row from the database
                        $dbw->delete( 'global_block_whitelist', array( 'gbw_id' 
=> $id ), __METHOD__ );
-
+                       
                        $page = new LogPage( 'gblblock' );
                        $page->addEntry( 'dwhitelist', Title::makeTitleSafe( 
NS_USER, $ip ), $this->mReason );
-                       $out->addWikiMsg( 
'globalblocking-whitelist-dewhitelisted', $ip, $id );
+                       $wgOut->addWikiMsg( 
'globalblocking-whitelist-dewhitelisted', $ip, $id );
                }
-
+               
                $link = Linker::makeKnownLinkObj( SpecialPage::getTitleFor( 
'GlobalBlockList' ), wfMsg( 'globalblocking-return' ) );
-               $out->addHTML( $link );
+               $wgOut->addHTML( $link );
 
-               $out->setSubtitle(wfMsg('globalblocking-whitelist-successsub'));
+               
$wgOut->setSubtitle(wfMsg('globalblocking-whitelist-successsub'));
 
                return array();
        }
 
        function form( $error ) {
-               global $wgUser;
+               global $wgUser, $wgOut;
+               
+               $wgOut->addWikiMsg( 'globalblocking-whitelist-intro' );
+               
+               $wgOut->addHTML( $error );
 
-               $out = $this->getOutput();
-               $out->addWikiMsg( 'globalblocking-whitelist-intro' );
-
-               $out->addHTML( $error );
-
                $form = '';
                $form .= Xml::openElement( 'fieldset' ) . Xml::element( 
'legend', null, wfMsg( 'globalblocking-whitelist-legend' ) );
                $form .= Xml::openElement( 'form', array( 'method' => 'post', 
'action' => $this->getTitle()->getFullURL(), 'name' => 'globalblock-whitelist' 
) );
@@ -168,6 +165,6 @@
                $form .= Xml::closeElement( 'form' );
                $form .= Xml::closeElement( 'fieldset' );
 
-               $out->addHTML( $form );
+               $wgOut->addHTML( $form );
        }
 }

Modified: trunk/extensions/GlobalBlocking/SpecialRemoveGlobalBlock.php
===================================================================
--- trunk/extensions/GlobalBlocking/SpecialRemoveGlobalBlock.php        
2012-03-21 20:49:43 UTC (rev 114407)
+++ trunk/extensions/GlobalBlocking/SpecialRemoveGlobalBlock.php        
2012-03-21 21:28:09 UTC (rev 114408)
@@ -8,19 +8,17 @@
        }
 
        function execute( $par ) {
-               global $wgUser;
+               global $wgOut, $wgRequest, $wgUser;
                $this->setHeaders();
 
                $this->loadParameters();
 
-               $out = $this->getOutput();
+               $wgOut->setPageTitle( wfMsg( 'globalblocking-unblock' ) );
+               $wgOut->setSubtitle( GlobalBlocking::buildSubtitleLinks( 
'RemoveGlobalBlock' ) );
+               $wgOut->setRobotPolicy( "noindex,nofollow" );
+               $wgOut->setArticleRelated( false );
+               $wgOut->enableClientCache( false );
 
-               $out->setPageTitle( wfMsg( 'globalblocking-unblock' ) );
-               $out->setSubtitle( GlobalBlocking::buildSubtitleLinks( 
'RemoveGlobalBlock' ) );
-               $out->setRobotPolicy( "noindex,nofollow" );
-               $out->setArticleRelated( false );
-               $out->enableClientCache( false );
-
                if (!$this->userCanExecute( $wgUser )) {
                        $this->displayRestrictionError();
                        return;
@@ -28,8 +26,7 @@
 
                $errors = '';
 
-               $request = $this->getRequest();
-               if ( $request->wasPosted() && $wgUser->matchEditToken( 
$request->getVal( 'wpEditToken' ) ) ) {
+               if ($wgRequest->wasPosted() && $wgUser->matchEditToken( 
$wgRequest->getVal( 'wpEditToken' ))) {
                        // They want to submit. Let's have a look.
                        $errors = $this->trySubmit();
                        if( !$errors ) {
@@ -37,12 +34,12 @@
                                return;
                        }
                }
+               
+               $wgOut->addWikiMsg( 'globalblocking-unblock-intro' );
 
-               $out->addWikiMsg( 'globalblocking-unblock-intro' );
-
                if (is_array($errors) && count($errors)>0) {
                        $errorstr = '';
-
+                       
                        foreach ( $errors as $error ) {
                                if (is_array($error)) {
                                        $msg = array_shift($error);
@@ -52,14 +49,15 @@
                                }
                                $errorstr .= Xml::tags( 'li', null, wfMsgExt( 
$msg, array( 'parseinline' ), $error ) );
                        }
-
+                       
                        $errorstr = Xml::tags( 'ul', array( 'class' => 'error' 
), $errorstr );
                        $errorstr = wfMsgExt( 'globalblocking-unblock-errors', 
array('parse'), array( count( $errors ) ) ) . $errorstr;
                        $errorstr = Xml::tags( 'div', array( 'class' => 'error' 
), $errorstr );
-                       $out->addHTML( $errorstr );
+                       $wgOut->addHTML( $errorstr );
                }
+               
+               $this->form( );
 
-               $this->form();
        }
 
        function loadParameters() {
@@ -70,7 +68,7 @@
        }
 
        function trySubmit() {
-               global $wgOut;
+               global $wgOut,$wgUser;
                $errors = array();
                $ip = $this->mUnblockIP;
                if (!IP::isIPAddress($ip) && strlen($ip)) {
@@ -86,7 +84,6 @@
                        return $errors;
                }
 
-               $out = $this->getOutput();
                $dbw = GlobalBlocking::getGlobalBlockingMaster();
                $dbw->delete( 'globalblocks', array( 'gb_id' => $id ), 
__METHOD__ );
 
@@ -94,12 +91,12 @@
                $page->addEntry( 'gunblock', Title::makeTitleSafe( NS_USER, $ip 
), $this->mReason );
 
                $successmsg = wfMsgExt( 'globalblocking-unblock-unblocked', 
array( 'parse' ), $ip, $id );
-               $out->addHTML( $successmsg );
+               $wgOut->addHTML( $successmsg );
 
-               $link = Linker::makeKnownLinkObj( SpecialPage::getTitleFor( 
'GlobalBlockList' ), wfMsg( 'globalblocking-return' ) );
-               $out->addHTML( $link );
+               $link = $wgUser->getSkin()->makeKnownLinkObj( 
SpecialPage::getTitleFor( 'GlobalBlockList' ), wfMsg( 'globalblocking-return' ) 
);
+               $wgOut->addHTML( $link );
 
-               $out->setSubtitle(wfMsg('globalblocking-unblock-successsub'));
+               $wgOut->setSubtitle(wfMsg('globalblocking-unblock-successsub'));
 
                return array();
        }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to