From 79d67881f02d49504e0d3d1b15a4889684a85b7a Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Fri, 6 Jun 2008 18:11:05 +0000 Subject: [PATCH] I think we've fixed the UI issues with the new modify block features. Shows up fine in FF2 and IE7/8. Need additional testing if someone would be so kind :-) --- RELEASE-NOTES | 1 + includes/SpecialBlockip.php | 39 +++++++++++++++++++++++++++---- languages/messages/MessagesEn.php | 4 +++- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 508df838c4..4ef45595fa 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -338,6 +338,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. * (bug 12859) $wgRateLimitsExcludedGroups has been deprecated in favor of $wgGroupPermissions[]['noratelimit']. * (Bug 13828) Split parameter $1 of MediaWiki:Missingarticle into $1 (=title) diff --git a/includes/SpecialBlockip.php b/includes/SpecialBlockip.php index 903c116a62..b3630eb082 100644 --- a/includes/SpecialBlockip.php +++ b/includes/SpecialBlockip.php @@ -32,8 +32,10 @@ function wfSpecialBlockip( $par ) { } else if ( $wgRequest->wasPosted() && 'submit' == $action && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { $ipb->doSubmit(); + } else if ( $ipb->AlreadyBlocked ) { + $ipb->showForm( wfMsg('ipb_already_blocked', $ipb->BlockAddress ) ); } else { - $ipb->showForm( '' ); + $ipb->showForm(''); } } @@ -47,10 +49,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') ); @@ -69,7 +93,7 @@ class IPBlockForm { } function showForm( $err ) { - global $wgOut, $wgUser, $wgSysopUserBans; + global $wgOut, $wgUser, $wgSysopUserBans, $wgRequest; $wgOut->setPagetitle( wfMsg( 'blockip' ) ); $wgOut->addWikiMsg( 'blockiptext' ); @@ -86,8 +110,10 @@ class IPBlockForm { $titleObj = SpecialPage::getTitleFor( 'Blockip' ); - if ( "" != $err ) { + if ( $wgRequest->wasPosted() ) { $wgOut->setSubtitle( wfMsgHtml( 'formerror' ) ); + } + if ( "" != $err ) { $wgOut->addHTML( Xml::tags( 'p', array( 'class' => 'error' ), $err ) ); } @@ -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 23d1fc0ed9..3ecea9d79d 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2360,7 +2360,9 @@ 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 already 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.', -- 2.20.1