From 31602656c58694ec18d3b2eedee6f3042bba0566 Mon Sep 17 00:00:00 2001 From: Alex Z Date: Thu, 30 Oct 2008 21:45:16 +0000 Subject: [PATCH] (bug 10080) (bug 15820) - Allow modification of blocks without unblocking, and show a notice if the user is already blocked when first visiting the form (if a user is specified). --- RELEASE-NOTES | 3 ++ includes/DefaultSettings.php | 1 + includes/LogPage.php | 2 +- includes/specials/SpecialBlockip.php | 46 +++++++++++++++++++++++----- languages/messages/MessagesEn.php | 4 +++ maintenance/language/messages.inc | 3 ++ 6 files changed, 50 insertions(+), 9 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 0582a7b1f6..c329308942 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -179,6 +179,9 @@ The following extensions are migrated into MediaWiki 1.14: * Make search matches bold only, not red as well * Added 'UserRights::showEditUserGroupsForm' hook to allow extensions to alter the groups that the user can be added to or removed from in Special:UserRights +* (bug 10080) Blocks can be modified without unblocking first +* (bug 15820) Special:BlockIP shows a notice if the user being blocked is already + directly blocked === Bug fixes in 1.14 === diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 7e75847d41..7fa87dab7a 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2762,6 +2762,7 @@ $wgLogHeaders = array( $wgLogActions = array( 'block/block' => 'blocklogentry', 'block/unblock' => 'unblocklogentry', + 'block/reblock' => 'reblock-logentry', 'protect/protect' => 'protectedarticle', 'protect/modify' => 'modifiedarticleprotection', 'protect/unprotect' => 'unprotectedarticle', diff --git a/includes/LogPage.php b/includes/LogPage.php index 00f2422ade..228c3fd630 100644 --- a/includes/LogPage.php +++ b/includes/LogPage.php @@ -196,7 +196,7 @@ class LogPage { } else { $details = ''; array_unshift( $params, $titleLink ); - if ( $key == 'block/block' || $key == 'suppress/block' ) { + if ( $key == 'block/block' || $key == 'suppress/block' || $key == 'block/reblock' ) { if ( $skin ) { $params[1] = '' . $wgLang->translateBlockExpiry( $params[1] ) . ''; diff --git a/includes/specials/SpecialBlockip.php b/includes/specials/SpecialBlockip.php index e449b6e3bb..e159f0bb8a 100644 --- a/includes/specials/SpecialBlockip.php +++ b/includes/specials/SpecialBlockip.php @@ -67,6 +67,7 @@ class IPBlockForm { # Re-check user's rights to hide names, very serious, defaults to 0 $this->BlockHideName = ( $wgRequest->getBool( 'wpHideName', 0 ) && $wgUser->isAllowed( 'hideuser' ) ) ? 1 : 0; $this->BlockAllowUsertalk = ( $wgRequest->getBool( 'wpAllowUsertalk', $byDefault ) && $wgBlockAllowsUTEdit ); + $this->BlockReblock = $wgRequest->getBool( 'wpChangeBlock', false ); } function showForm( $err ) { @@ -86,10 +87,19 @@ class IPBlockForm { $mIpbreason = Xml::label( wfMsg( 'ipbotherreason' ), 'mw-bi-reason' ); $titleObj = SpecialPage::getTitleFor( 'Blockip' ); - - if ( "" != $err ) { + + $alreadyBlocked = false; + if ( $err && $err[0] != 'ipb_already_blocked' ) { + $key = array_shift($err); + $msg = wfMsgReal($key, $err); $wgOut->setSubtitle( wfMsgHtml( 'formerror' ) ); - $wgOut->addHTML( Xml::tags( 'p', array( 'class' => 'error' ), $err ) ); + $wgOut->addHTML( Xml::tags( 'p', array( 'class' => 'error' ), $msg ) ); + } elseif ( $this->BlockAddress ) { + $currentBlock = Block::newFromDB( $this->BlockAddress ); + if ( !is_null($currentBlock) && !$currentBlock->mAuto && !($currentBlock->mRangeStart && $currentBlock->mAddress != $this->BlockAddress) ) { + $wgOut->addWikiMsg( 'ipb-needreblock', $this->BlockAddress ); + $alreadyBlocked = true; + } } $scBlockExpiryOptions = wfMsgForContent( 'ipboptions' ); @@ -253,6 +263,18 @@ class IPBlockForm { " ); } + if ( $alreadyBlocked ) { + $wgOut->addHTML(" + +   + " . + Xml::checkLabel( wfMsg( 'ipb-change-block' ), + 'wpChangeBlock', 'wpChangeBlock', $this->BlockReblock, + array( 'tabindex' => '13' ) ) . " + + " + ); + } $wgOut->addHTML(" @@ -379,9 +401,18 @@ class IPBlockForm { if ( wfRunHooks('BlockIp', array(&$block, &$wgUser)) ) { if ( !$block->insert() ) { - return array('ipb_already_blocked', htmlspecialchars($this->BlockAddress)); + if ( !$this->BlockReblock ) { + return array( 'ipb_already_blocked' ); + } else { + # This returns direct blocks before autoblocks/rangeblocks, since we should be sure the user is blocked by now it should work for our purposes + $currentBlock = Block::newFromDB( $this->BlockAddress ); + $currentBlock->delete(); + $block->insert(); + $log_action = 'reblock'; + } + } else { + $log_action = 'block'; } - wfRunHooks('BlockIpComplete', array($block, $wgUser)); if ( $this->BlockWatchUser ) { @@ -396,7 +427,7 @@ class IPBlockForm { # Make log entry, if the name is hidden, put it in the oversight log $log_type = ($this->BlockHideName) ? 'suppress' : 'block'; $log = new LogPage( $log_type ); - $log->addEntry( 'block', Title::makeTitle( NS_USER, $this->BlockAddress ), + $log->addEntry( $log_action, Title::makeTitle( NS_USER, $this->BlockAddress ), $reasonstr, $logParams ); # Report to the user @@ -420,8 +451,7 @@ class IPBlockForm { urlencode( $this->BlockAddress ) ) ); return; } - $key = array_shift($retval); - $this->showForm(wfMsgReal($key, $retval)); + $this->showForm( $retval ); } function showSuccess() { diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index ffbab167bb..ebb9351636 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2552,6 +2552,7 @@ Fill in a specific reason below (for example, citing particular pages that were 'ipbhidename' => 'Hide username from the block log, active block list and user list', 'ipbwatchuser' => "Watch this user's user and talk pages", 'ipballowusertalk' => 'Allow this user to edit own talk page while blocked', +'ipb-change-block' => 'Re-block the user with these settings', 'badipaddress' => 'Invalid IP address', 'blockipsuccesssub' => 'Block succeeded', 'blockipsuccesstext' => '[[Special:Contributions/$1|$1]] has been blocked.
@@ -2593,6 +2594,7 @@ The reason given for $1\'s block is: "$2"', 'blocklogpage' => 'Block log', 'blocklog-fulllog' => 'Full block log', 'blocklogentry' => 'blocked [[$1]] with an expiry time of $2 $3', +'reblock-logentry' => 'changed block settings for [[$1]] with an expiry time of $2 $3', 'blocklogtext' => 'This is a log of user blocking and unblocking actions. Automatically blocked IP addresses are not listed. See the [[Special:IPBlockList|IP block list]] for the list of currently operational bans and blocks.', @@ -2607,6 +2609,8 @@ See the [[Special:IPBlockList|IP block list]] for the list of currently operatio 'ipb_expiry_invalid' => 'Expiry time invalid.', 'ipb_expiry_temp' => 'Hidden username blocks must be permanent.', 'ipb_already_blocked' => '"$1" is already blocked', +'ipb-needreblock' => '== Already blocked == +$1 is already blocked. Do you want to change the settings?', '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. diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 40aed9955a..00012e1c7b 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1745,6 +1745,7 @@ $wgMessageStructure = array( 'ipbhidename', 'ipbwatchuser', 'ipballowusertalk', + 'ipb-change-block', 'badipaddress', 'blockipsuccesssub', 'blockipsuccesstext', @@ -1784,6 +1785,7 @@ $wgMessageStructure = array( 'blocklogpage', 'blocklog-fulllog', 'blocklogentry', + 'reblock-logentry', 'blocklogtext', 'unblocklogentry', 'block-log-flags-anononly', @@ -1796,6 +1798,7 @@ $wgMessageStructure = array( 'ipb_expiry_invalid', 'ipb_expiry_temp', 'ipb_already_blocked', + 'ipb-needreblock', 'ipb_cant_unblock', 'ipb_blocked_as_range', 'ip_range_invalid', -- 2.20.1