From: Chad Horohoe Date: Thu, 5 Jun 2008 00:11:24 +0000 (+0000) Subject: Bug 10080 - Sysops can now modify a block without unblocking first. Patch by Huji... X-Git-Tag: 1.31.0-rc.0~47159 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=e7c9dad7c2dda3d8f99b78d576362b1a4393171d;p=lhc%2Fweb%2Fwiklou.git Bug 10080 - Sysops can now modify a block without unblocking first. Patch by Huji with some tweaks to allow for silent unblocking (no log entry). --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 776f82934c..f7e78c8ecf 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -334,6 +334,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 14385) "Move subpages" option no longer tries to move to invalid titles * (bug 14386) Fix subpage namespace oddity when moving a talk page * (bug 11771) Signup form now not shown if in read-only mode. +* (bug 10080) Users can now modify an existing block without unblocking first. === API changes in 1.13 === diff --git a/includes/SpecialBlockip.php b/includes/SpecialBlockip.php index 903c116a62..bf3efaf5d7 100644 --- a/includes/SpecialBlockip.php +++ b/includes/SpecialBlockip.php @@ -47,10 +47,32 @@ class IPBlockForm { # var $BlockEmail; function IPBlockForm( $par ) { - global $wgRequest, $wgUser; + global $wgRequest, $wgUser, $wgLang; $this->BlockAddress = $wgRequest->getVal( 'wpBlockAddress', $wgRequest->getVal( 'ip', $par ) ); $this->BlockAddress = strtr( $this->BlockAddress, '_', ' ' ); + $this->AlreadyBlocked = false; + + if( $this->BlockAddress && !$wgRequest->wasPosted() ){ + $this->mBlock = new Block(); + if( $this->mBlock->load($this->BlockAddress) ) { + $this->AlreadyBlocked = true; + $this->BlockReason = wfMsgForContent( 'ipb_modifying_block' ); + $this->BlockReasonList = $wgRequest->getText( 'wpBlockReasonList' ); + $this->BlockExpiry = wfMsg('ipbotheroption'); + $this->BlockOther = $wgLang->timeanddate( $this->mBlock->mExpiry ); + $this->BlockAnonOnly = $wgRequest->getBool( 'wpAnonOnly', true ); + $this->BlockCreateAccount = $wgRequest->getBool( 'wpCreateAccount', true ); + $this->BlockEnableAutoblock = $wgRequest->getBool( 'wpEnableAutoblock', true ); + $this->BlockEmail = $wgRequest->getBool( 'wpEmailBan', false ); + $this->BlockEmail = $this->mBlock->mBlockEmail; + $this->BlockWatchUser = $wgRequest->getBool( 'wpWatchUser', false ); + # Re-check user's rights to hide names, very serious, defaults to 0 + $this->BlockHideName = ( $this->mBlock->mHideName && $wgUser->isAllowed( 'hideuser' ) ) ? 1 : 0; + return true; + } + } + $this->BlockReason = $wgRequest->getText( 'wpBlockReason' ); $this->BlockReasonList = $wgRequest->getText( 'wpBlockReasonList' ); $this->BlockExpiry = $wgRequest->getVal( 'wpBlockExpiry', wfMsg('ipbotheroption') ); @@ -111,6 +133,10 @@ class IPBlockForm { wfMsgForContent( 'ipbreasonotherlist' ), '', 'wpBlockDropDown', 4 ); global $wgStylePath, $wgStyleVersion; + if( $this->AlreadyBlocked ) { + $wgOut->addHTML( Xml::element( 'p', array ( 'class' => 'error' ), + wfMsg( 'ipb_already_blocked', $this->BlockAddress ) ) ); + } $wgOut->addHTML( Xml::tags( 'script', array( 'type' => 'text/javascript', 'src' => "$wgStylePath/common/block.js?$wgStyleVersion" ), '' ) . Xml::openElement( 'form', array( 'method' => 'post', 'action' => $titleObj->getLocalURL( "action=submit" ), 'id' => 'blockip' ) ) . @@ -358,7 +384,10 @@ class IPBlockForm { if (wfRunHooks('BlockIp', array(&$block, &$wgUser))) { if ( !$block->insert() ) { - return array('ipb_already_blocked', htmlspecialchars($this->BlockAddress)); + // Block already exists. Silently delete the existing block and insert it again + $oldblock = Block::newFromDB( $this->BlockAddress ); + $oldblock->delete(); + $block->insert(); } wfRunHooks('BlockIpComplete', array($block, $wgUser)); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index ed74ad7187..01bc2ca98d 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2356,7 +2356,8 @@ See the [[Special:Ipblocklist|IP block list]] for the list of currently operatio 'block-log-flags-noemail' => 'e-mail blocked', 'range_block_disabled' => 'The sysop ability to create range blocks is disabled.', 'ipb_expiry_invalid' => 'Expiry time invalid.', -'ipb_already_blocked' => '"$1" is already blocked', +'ipb_already_blocked' => 'Caution: "$1" is alrady blocked. You can modify the block settings by using this form.', +'ipb_modifying_block' => 'Modifying existing block:', 'ipb_cant_unblock' => 'Error: Block ID $1 not found. It may have been unblocked already.', 'ipb_blocked_as_range' => 'Error: The IP $1 is not blocked directly and cannot be unblocked. It is, however, blocked as part of the range $2, which can be unblocked.',