From 630d97d41a7ba98aec66fd50f69d087e8a8185f1 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 24 Oct 2009 04:01:52 +0000 Subject: [PATCH] * Don't use existing block values on "already blocked" form on submission * Code style cleanups --- includes/specials/SpecialBlockip.php | 31 ++++++++++++++++++---------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/includes/specials/SpecialBlockip.php b/includes/specials/SpecialBlockip.php index 09bf84deeb..a32092ee0c 100644 --- a/includes/specials/SpecialBlockip.php +++ b/includes/specials/SpecialBlockip.php @@ -67,10 +67,16 @@ class IPBlockForm { $this->BlockEmail = $wgRequest->getBool( 'wpEmailBan', false ); } $this->BlockWatchUser = $wgRequest->getBool( 'wpWatchUser', false ); - # Re-check user's rights to hide names, very serious, defaults to 0 - $this->BlockHideName = ( $wgRequest->getBool( 'wpHideName', 0 ) && $wgUser->isAllowed( 'hideuser' ) ) ? 1 : 0; + # Re-check user's rights to hide names, very serious, defaults to null + if( $wgUser->isAllowed( 'hideuser' ) ) { + $this->BlockHideName = $wgRequest->getBool( 'wpHideName', null ); + } else { + $this->BlockHideName = false; + } $this->BlockAllowUsertalk = ( $wgRequest->getBool( 'wpAllowUsertalk', $byDefault ) && $wgBlockAllowsUTEdit ); $this->BlockReblock = $wgRequest->getBool( 'wpChangeBlock', false ); + + $this->wasPosted = $wgRequest->wasPosted(); } public function showForm( $err ) { @@ -99,17 +105,17 @@ class IPBlockForm { $wgOut->setSubtitle( wfMsgHtml( 'formerror' ) ); $wgOut->addHTML( Xml::tags( 'p', array( 'class' => 'error' ), $msg ) ); } elseif( $this->BlockAddress ) { - $userId = 0; - if( is_object( $user ) ) - $userId = $user->getId(); + $userId = is_object( $user ) ? $user->getId() : 0; $currentBlock = Block::newFromDB( $this->BlockAddress, $userId ); if( !is_null( $currentBlock ) && !$currentBlock->mAuto && # The block exists and isn't an autoblock ( $currentBlock->mRangeStart == $currentBlock->mRangeEnd || # The block isn't a rangeblock # or if it is, the range is what we're about to block - ( $currentBlock->mAddress == $this->BlockAddress ) ) ) { - $wgOut->addWikiMsg( 'ipb-needreblock', $this->BlockAddress ); - $alreadyBlocked = true; - # Set the block form settings to the existing block + ( $currentBlock->mAddress == $this->BlockAddress ) ) + ) { + $wgOut->addWikiMsg( 'ipb-needreblock', $this->BlockAddress ); + $alreadyBlocked = true; + # Set the block form settings to the existing block + if( !$this->wasPosted ) { $this->BlockAnonOnly = $currentBlock->mAnonOnly; $this->BlockCreateAccount = $currentBlock->mCreateAccount; $this->BlockEnableAutoblock = $currentBlock->mEnableAutoblock; @@ -122,6 +128,7 @@ class IPBlockForm { $this->BlockOther = wfTimestamp( TS_ISO_8601, $currentBlock->mExpiry ); } $this->BlockReason = $currentBlock->mReason; + } } } @@ -261,7 +268,8 @@ class IPBlockForm { " . Xml::checkLabel( wfMsg( 'ipbhidename' ), 'wpHideName', 'wpHideName', $this->BlockHideName, - array( 'tabindex' => '10' ) ) . " + array( 'tabindex' => '10' ) + ) . " " ); @@ -433,7 +441,8 @@ class IPBlockForm { $block = new Block( $this->BlockAddress, $userId, $wgUser->getId(), $reasonstr, wfTimestampNow(), 0, $expiry, $this->BlockAnonOnly, $this->BlockCreateAccount, $this->BlockEnableAutoblock, $this->BlockHideName, - $this->BlockEmail, isset( $this->BlockAllowUsertalk ) ? $this->BlockAllowUsertalk : $wgBlockAllowsUTEdit + $this->BlockEmail, + isset( $this->BlockAllowUsertalk ) ? $this->BlockAllowUsertalk : $wgBlockAllowsUTEdit ); # Should this be privately logged? -- 2.20.1