r58078 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58077‎ | r58078 | r58079 >
Date:04:01, 24 October 2009
Author:aaron
Status:ok
Tags:
Comment:
* Don't use existing block values on "already blocked" form on submission
* Code style cleanups
Modified paths:
  • /trunk/phase3/includes/specials/SpecialBlockip.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialBlockip.php
@@ -67,10 +67,16 @@
6868 $this->BlockEmail = $wgRequest->getBool( 'wpEmailBan', false );
6969 }
7070 $this->BlockWatchUser = $wgRequest->getBool( 'wpWatchUser', false );
71 - # Re-check user's rights to hide names, very serious, defaults to 0
72 - $this->BlockHideName = ( $wgRequest->getBool( 'wpHideName', 0 ) && $wgUser->isAllowed( 'hideuser' ) ) ? 1 : 0;
 71+ # Re-check user's rights to hide names, very serious, defaults to null
 72+ if( $wgUser->isAllowed( 'hideuser' ) ) {
 73+ $this->BlockHideName = $wgRequest->getBool( 'wpHideName', null );
 74+ } else {
 75+ $this->BlockHideName = false;
 76+ }
7377 $this->BlockAllowUsertalk = ( $wgRequest->getBool( 'wpAllowUsertalk', $byDefault ) && $wgBlockAllowsUTEdit );
7478 $this->BlockReblock = $wgRequest->getBool( 'wpChangeBlock', false );
 79+
 80+ $this->wasPosted = $wgRequest->wasPosted();
7581 }
7682
7783 public function showForm( $err ) {
@@ -99,17 +105,17 @@
100106 $wgOut->setSubtitle( wfMsgHtml( 'formerror' ) );
101107 $wgOut->addHTML( Xml::tags( 'p', array( 'class' => 'error' ), $msg ) );
102108 } elseif( $this->BlockAddress ) {
103 - $userId = 0;
104 - if( is_object( $user ) )
105 - $userId = $user->getId();
 109+ $userId = is_object( $user ) ? $user->getId() : 0;
106110 $currentBlock = Block::newFromDB( $this->BlockAddress, $userId );
107111 if( !is_null( $currentBlock ) && !$currentBlock->mAuto && # The block exists and isn't an autoblock
108112 ( $currentBlock->mRangeStart == $currentBlock->mRangeEnd || # The block isn't a rangeblock
109113 # or if it is, the range is what we're about to block
110 - ( $currentBlock->mAddress == $this->BlockAddress ) ) ) {
111 - $wgOut->addWikiMsg( 'ipb-needreblock', $this->BlockAddress );
112 - $alreadyBlocked = true;
113 - # Set the block form settings to the existing block
 114+ ( $currentBlock->mAddress == $this->BlockAddress ) )
 115+ ) {
 116+ $wgOut->addWikiMsg( 'ipb-needreblock', $this->BlockAddress );
 117+ $alreadyBlocked = true;
 118+ # Set the block form settings to the existing block
 119+ if( !$this->wasPosted ) {
114120 $this->BlockAnonOnly = $currentBlock->mAnonOnly;
115121 $this->BlockCreateAccount = $currentBlock->mCreateAccount;
116122 $this->BlockEnableAutoblock = $currentBlock->mEnableAutoblock;
@@ -122,6 +128,7 @@
123129 $this->BlockOther = wfTimestamp( TS_ISO_8601, $currentBlock->mExpiry );
124130 }
125131 $this->BlockReason = $currentBlock->mReason;
 132+ }
126133 }
127134 }
128135
@@ -261,7 +268,8 @@
262269 <td class='mw-input'><strong>" .
263270 Xml::checkLabel( wfMsg( 'ipbhidename' ),
264271 'wpHideName', 'wpHideName', $this->BlockHideName,
265 - array( 'tabindex' => '10' ) ) . "
 272+ array( 'tabindex' => '10' )
 273+ ) . "
266274 </strong></td>
267275 </tr>"
268276 );
@@ -433,7 +441,8 @@
434442 $block = new Block( $this->BlockAddress, $userId, $wgUser->getId(),
435443 $reasonstr, wfTimestampNow(), 0, $expiry, $this->BlockAnonOnly,
436444 $this->BlockCreateAccount, $this->BlockEnableAutoblock, $this->BlockHideName,
437 - $this->BlockEmail, isset( $this->BlockAllowUsertalk ) ? $this->BlockAllowUsertalk : $wgBlockAllowsUTEdit
 445+ $this->BlockEmail,
 446+ isset( $this->BlockAllowUsertalk ) ? $this->BlockAllowUsertalk : $wgBlockAllowsUTEdit
438447 );
439448
440449 # Should this be privately logged?

Status & tagging log