| Index: trunk/phase3/includes/specials/SpecialBlock.php |
| — | — | @@ -56,10 +56,8 @@ |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public function execute( $par ) { |
| 60 | | - global $wgUser, $wgOut, $wgRequest; |
| 61 | | - |
| 62 | 60 | # Permission check |
| 63 | | - if( !$this->userCanExecute( $wgUser ) ) { |
| | 61 | + if( !$this->userCanExecute( $this->getUser() ) ) { |
| 64 | 62 | $this->displayRestrictionError(); |
| 65 | 63 | return; |
| 66 | 64 | } |
| — | — | @@ -72,15 +70,16 @@ |
| 73 | 71 | # Extract variables from the request. Try not to get into a situation where we |
| 74 | 72 | # need to extract *every* variable from the form just for processing here, but |
| 75 | 73 | # there are legitimate uses for some variables |
| 76 | | - list( $this->target, $this->type ) = self::getTargetAndType( $par, $wgRequest ); |
| | 74 | + $request = $this->getRequest(); |
| | 75 | + list( $this->target, $this->type ) = self::getTargetAndType( $par, $request ); |
| 77 | 76 | if ( $this->target instanceof User ) { |
| 78 | 77 | # Set the 'relevant user' in the skin, so it displays links like Contributions, |
| 79 | 78 | # User logs, UserRights, etc. |
| 80 | 79 | $this->getSkin()->setRelevantUser( $this->target ); |
| 81 | 80 | } |
| 82 | 81 | |
| 83 | | - list( $this->previousTarget, /*...*/ ) = Block::parseTarget( $wgRequest->getVal( 'wpPreviousTarget' ) ); |
| 84 | | - $this->requestedHideUser = $wgRequest->getBool( 'wpHideUser' ); |
| | 82 | + list( $this->previousTarget, /*...*/ ) = Block::parseTarget( $request->getVal( 'wpPreviousTarget' ) ); |
| | 83 | + $this->requestedHideUser = $request->getBool( 'wpHideUser' ); |
| 85 | 84 | |
| 86 | 85 | # bug 15810: blocked admins should have limited access here |
| 87 | 86 | $status = self::checkUnblockSelf( $this->target ); |
| — | — | @@ -88,10 +87,11 @@ |
| 89 | 88 | throw new ErrorPageError( 'badaccess', $status ); |
| 90 | 89 | } |
| 91 | 90 | |
| 92 | | - $wgOut->setPageTitle( wfMsg( 'blockip-title' ) ); |
| 93 | | - $wgOut->addModules( 'mediawiki.special', 'mediawiki.special.block' ); |
| | 91 | + $out = $this->getOutput(); |
| | 92 | + $out->setPageTitle( wfMsg( 'blockip-title' ) ); |
| | 93 | + $out->addModules( 'mediawiki.special', 'mediawiki.special.block' ); |
| 94 | 94 | |
| 95 | | - $fields = self::getFormFields(); |
| | 95 | + $fields = $this->getFormFields(); |
| 96 | 96 | $this->maybeAlterFormDefaults( $fields ); |
| 97 | 97 | |
| 98 | 98 | $form = new HTMLForm( $fields, $this->getContext() ); |
| — | — | @@ -108,8 +108,8 @@ |
| 109 | 109 | $this->doPostText( $form ); |
| 110 | 110 | |
| 111 | 111 | if( $form->show() ){ |
| 112 | | - $wgOut->setPageTitle( wfMsg( 'blockipsuccesssub' ) ); |
| 113 | | - $wgOut->addWikiMsg( 'blockipsuccesstext', $this->target ); |
| | 112 | + $out->setPageTitle( wfMsg( 'blockipsuccesssub' ) ); |
| | 113 | + $out->addWikiMsg( 'blockipsuccesstext', $this->target ); |
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
| — | — | @@ -117,9 +117,11 @@ |
| 118 | 118 | * Get the HTMLForm descriptor array for the block form |
| 119 | 119 | * @return Array |
| 120 | 120 | */ |
| 121 | | - protected static function getFormFields(){ |
| 122 | | - global $wgUser, $wgBlockAllowsUTEdit; |
| | 121 | + protected function getFormFields(){ |
| | 122 | + global $wgBlockAllowsUTEdit; |
| 123 | 123 | |
| | 124 | + $user = $this->getUser(); |
| | 125 | + |
| 124 | 126 | $a = array( |
| 125 | 127 | 'Target' => array( |
| 126 | 128 | 'type' => 'text', |
| — | — | @@ -150,7 +152,7 @@ |
| 151 | 153 | ), |
| 152 | 154 | ); |
| 153 | 155 | |
| 154 | | - if( self::canBlockEmail( $wgUser ) ) { |
| | 156 | + if( self::canBlockEmail( $user ) ) { |
| 155 | 157 | $a['DisableEmail'] = array( |
| 156 | 158 | 'type' => 'check', |
| 157 | 159 | 'label-message' => 'ipbemailban', |
| — | — | @@ -172,7 +174,7 @@ |
| 173 | 175 | ); |
| 174 | 176 | |
| 175 | 177 | # Allow some users to hide name from block log, blocklist and listusers |
| 176 | | - if( $wgUser->isAllowed( 'hideuser' ) ) { |
| | 178 | + if( $user->isAllowed( 'hideuser' ) ) { |
| 177 | 179 | $a['HideUser'] = array( |
| 178 | 180 | 'type' => 'check', |
| 179 | 181 | 'label-message' => 'ipbhidename', |
| — | — | @@ -181,7 +183,7 @@ |
| 182 | 184 | } |
| 183 | 185 | |
| 184 | 186 | # Watchlist their user page? (Only if user is logged in) |
| 185 | | - if( $wgUser->isLoggedIn() ) { |
| | 187 | + if( $user->isLoggedIn() ) { |
| 186 | 188 | $a['Watch'] = array( |
| 187 | 189 | 'type' => 'check', |
| 188 | 190 | 'label-message' => 'ipbwatchuser', |
| — | — | @@ -219,8 +221,6 @@ |
| 220 | 222 | * already blocked) |
| 221 | 223 | */ |
| 222 | 224 | protected function maybeAlterFormDefaults( &$fields ){ |
| 223 | | - global $wgRequest, $wgUser; |
| 224 | | - |
| 225 | 225 | # This will be overwritten by request data |
| 226 | 226 | $fields['Target']['default'] = (string)$this->target; |
| 227 | 227 | |
| — | — | @@ -252,7 +252,7 @@ |
| 253 | 253 | |
| 254 | 254 | $fields['Reason']['default'] = $block->mReason; |
| 255 | 255 | |
| 256 | | - if( $wgRequest->wasPosted() ){ |
| | 256 | + if( $this->getRequest()->wasPosted() ){ |
| 257 | 257 | # Ok, so we got a POST submission asking us to reblock a user. So show the |
| 258 | 258 | # confirm checkbox; the user will only see it if they haven't previously |
| 259 | 259 | $fields['Confirm']['type'] = 'check'; |
| — | — | @@ -281,7 +281,7 @@ |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | # Or if the user is trying to block themselves |
| 285 | | - if( (string)$this->target === $wgUser->getName() ){ |
| | 285 | + if( (string)$this->target === $this->getUser()->getName() ){ |
| 286 | 286 | $fields['Confirm']['type'] = 'check'; |
| 287 | 287 | unset( $fields['Confirm']['default'] ); |
| 288 | 288 | $this->preErrors[] = 'ipb-blockingself'; |
| — | — | @@ -331,10 +331,8 @@ |
| 332 | 332 | * @return void |
| 333 | 333 | */ |
| 334 | 334 | protected function doHeaderText( HTMLForm &$form ){ |
| 335 | | - global $wgRequest; |
| 336 | | - |
| 337 | 335 | # Don't need to do anything if the form has been posted |
| 338 | | - if( !$wgRequest->wasPosted() && $this->preErrors ){ |
| | 336 | + if( !$this->getRequest()->wasPosted() && $this->preErrors ){ |
| 339 | 337 | $s = HTMLForm::formatErrors( $this->preErrors ); |
| 340 | 338 | if( $s ){ |
| 341 | 339 | $form->addHeaderText( Html::rawElement( |
| — | — | @@ -352,8 +350,6 @@ |
| 353 | 351 | * @return void |
| 354 | 352 | */ |
| 355 | 353 | protected function doPostText( HTMLForm &$form ){ |
| 356 | | - global $wgUser, $wgLang; |
| 357 | | - |
| 358 | 354 | # Link to the user's contributions, if applicable |
| 359 | 355 | if( $this->target instanceof User ){ |
| 360 | 356 | $contribsPage = SpecialPage::getTitleFor( 'Contributions', $this->target->getName() ); |
| — | — | @@ -379,8 +375,10 @@ |
| 380 | 376 | wfMsg( 'ipb-blocklist' ) |
| 381 | 377 | ); |
| 382 | 378 | |
| | 379 | + $user = $this->getUser(); |
| | 380 | + |
| 383 | 381 | # Link to edit the block dropdown reasons, if applicable |
| 384 | | - if ( $wgUser->isAllowed( 'editinterface' ) ) { |
| | 382 | + if ( $user->isAllowed( 'editinterface' ) ) { |
| 385 | 383 | $links[] = Linker::link( |
| 386 | 384 | Title::makeTitle( NS_MEDIAWIKI, 'Ipbreason-dropdown' ), |
| 387 | 385 | wfMsgHtml( 'ipb-edit-dropdown' ), |
| — | — | @@ -392,7 +390,7 @@ |
| 393 | 391 | $form->addPostText( Html::rawElement( |
| 394 | 392 | 'p', |
| 395 | 393 | array( 'class' => 'mw-ipb-conveniencelinks' ), |
| 396 | | - $wgLang->pipeList( $links ) |
| | 394 | + $this->getLang()->pipeList( $links ) |
| 397 | 395 | ) ); |
| 398 | 396 | |
| 399 | 397 | if( $this->target instanceof User ){ |
| — | — | @@ -414,7 +412,7 @@ |
| 415 | 413 | $form->addPostText( $out ); |
| 416 | 414 | |
| 417 | 415 | # Add suppression block entries if allowed |
| 418 | | - if( $wgUser->isAllowed( 'suppressionlog' ) ) { |
| | 416 | + if( $user->isAllowed( 'suppressionlog' ) ) { |
| 419 | 417 | LogEventsList::showLogExtract( |
| 420 | 418 | $out, |
| 421 | 419 | 'suppress', |