Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -2080,6 +2080,7 @@ |
2081 | 2081 | 'unblockiptext', |
2082 | 2082 | 'ipusubmit', |
2083 | 2083 | 'unblocked', |
| 2084 | + 'unblocked-range', |
2084 | 2085 | 'unblocked-id', |
2085 | 2086 | 'ipblocklist', |
2086 | 2087 | 'ipblocklist-legend', |
— | — | @@ -2127,6 +2128,7 @@ |
2128 | 2129 | 'ipb_already_blocked', |
2129 | 2130 | 'ipb-needreblock', |
2130 | 2131 | 'ipb-otherblocks-header', |
| 2132 | + 'unblock-hideuser', |
2131 | 2133 | 'ipb_cant_unblock', |
2132 | 2134 | 'ipb_blocked_as_range', |
2133 | 2135 | 'ip_range_invalid', |
Index: trunk/phase3/includes/LogEventsList.php |
— | — | @@ -424,13 +424,10 @@ |
425 | 425 | } else if( self::typeAction( $row, array( 'block', 'suppress' ), array( 'block', 'reblock' ), 'block' ) ) { |
426 | 426 | $revert = '(' . |
427 | 427 | $this->skin->link( |
428 | | - SpecialPage::getTitleFor( 'Ipblocklist' ), |
| 428 | + SpecialPage::getTitleFor( 'Unblock', $row->log_title ), |
429 | 429 | $this->message['unblocklink'], |
430 | 430 | array(), |
431 | | - array( |
432 | | - 'action' => 'unblock', |
433 | | - 'ip' => $row->log_title |
434 | | - ), |
| 431 | + array(), |
435 | 432 | 'known' |
436 | 433 | ) . |
437 | 434 | $this->message['pipe-separator'] . |
Index: trunk/phase3/includes/api/ApiUnblock.php |
— | — | @@ -72,17 +72,19 @@ |
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | | - $id = $params['id']; |
77 | | - $user = $params['user']; |
78 | | - $reason = ( is_null( $params['reason'] ) ? '' : $params['reason'] ); |
79 | | - $retval = IPUnblockForm::doUnblock( $id, $user, $reason, $range ); |
80 | | - if ( $retval ) { |
81 | | - $this->dieUsageMsg( $retval ); |
| 76 | + $data = array( |
| 77 | + 'Target' => is_null( $params['id'] ) ? $params['user'] : "#{$params['id']}", |
| 78 | + 'Reason' => is_null( $params['reason'] ) ? '' : $params['reason'] |
| 79 | + ); |
| 80 | + $block = Block::newFromTarget( $data['Target'] ); |
| 81 | + $retval = SpecialUnblock::processUnblock( $data ); |
| 82 | + if ( $retval !== true ) { |
| 83 | + $this->dieUsageMsg( $retval[0] ); |
82 | 84 | } |
83 | 85 | |
84 | | - $res['id'] = intval( $id ); |
85 | | - $res['user'] = $user; |
86 | | - $res['reason'] = $reason; |
| 86 | + $res['id'] = $block->mId; |
| 87 | + $res['user'] = $block->getType() == Block::TYPE_AUTO ? '' : $block->getTarget(); |
| 88 | + $res['reason'] = $params['reason']; |
87 | 89 | $this->getResult()->addValue( null, $this->getModuleName(), $res ); |
88 | 90 | } |
89 | 91 | |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -674,6 +674,7 @@ |
675 | 675 | 'SpecialSpecialpages' => 'includes/specials/SpecialSpecialpages.php', |
676 | 676 | 'SpecialStatistics' => 'includes/specials/SpecialStatistics.php', |
677 | 677 | 'SpecialTags' => 'includes/specials/SpecialTags.php', |
| 678 | + 'SpecialUnblock' => 'includes/specials/SpecialUnblock.php', |
678 | 679 | 'SpecialUnlockdb' => 'includes/specials/SpecialUnlockdb.php', |
679 | 680 | 'SpecialUpload' => 'includes/specials/SpecialUpload.php', |
680 | 681 | 'SpecialUserlogout' => 'includes/specials/SpecialUserlogout.php', |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -4948,6 +4948,7 @@ |
4949 | 4949 | 'Listbots' => 'users', |
4950 | 4950 | 'Userrights' => 'users', |
4951 | 4951 | 'Block' => 'users', |
| 4952 | + 'Unblock' => 'users', |
4952 | 4953 | 'Preferences' => 'users', |
4953 | 4954 | 'Resetpass' => 'users', |
4954 | 4955 | 'DeletedContributions' => 'users', |
Index: trunk/phase3/includes/specials/SpecialUnblock.php |
— | — | @@ -0,0 +1,200 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * This program is free software; you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU General Public License as published by |
| 6 | + * the Free Software Foundation; either version 2 of the License, or |
| 7 | + * (at your option) any later version. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU General Public License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the GNU General Public License along |
| 15 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 16 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | + * http://www.gnu.org/copyleft/gpl.html |
| 18 | + * |
| 19 | + * @file |
| 20 | + * @ingroup SpecialPage |
| 21 | + */ |
| 22 | + |
| 23 | +/** |
| 24 | + * A special page for unblocking users |
| 25 | + * |
| 26 | + * @ingroup SpecialPage |
| 27 | + */ |
| 28 | +class SpecialUnblock extends SpecialPage { |
| 29 | + |
| 30 | + protected $target; |
| 31 | + protected $type; |
| 32 | + protected $block; |
| 33 | + |
| 34 | + public function __construct(){ |
| 35 | + parent::__construct( 'Unblock', 'block' ); |
| 36 | + } |
| 37 | + |
| 38 | + public function execute( $par ){ |
| 39 | + global $wgUser, $wgOut, $wgRequest; |
| 40 | + |
| 41 | + # Check permissions |
| 42 | + if( !$wgUser->isAllowed( 'block' ) ) { |
| 43 | + $wgOut->permissionRequired( 'block' ); |
| 44 | + return; |
| 45 | + } |
| 46 | + # Check for database lock |
| 47 | + if( wfReadOnly() ) { |
| 48 | + $wgOut->readOnlyPage(); |
| 49 | + return; |
| 50 | + } |
| 51 | + |
| 52 | + list( $this->target, $this->type ) = SpecialBlock::getTargetAndType( $par, $wgRequest ); |
| 53 | + $this->block = Block::newFromTargetAndType( $this->target, $this->type ); |
| 54 | + |
| 55 | + # bug 15810: blocked admins should have limited access here. This won't allow sysops |
| 56 | + # to remove autoblocks on themselves, but they should have ipblock-exempt anyway |
| 57 | + $status = SpecialBlock::checkUnblockSelf( $this->target ); |
| 58 | + if ( $status !== true ) { |
| 59 | + throw new ErrorPageError( 'badaccess', $status ); |
| 60 | + } |
| 61 | + |
| 62 | + $wgOut->setPageTitle( wfMsg( 'unblockip' ) ); |
| 63 | + $wgOut->addModules( 'mediawiki.special' ); |
| 64 | + |
| 65 | + $form = new HTMLForm( $this->getFields() ); |
| 66 | + $form->setTitle( $this->getTitle() ); |
| 67 | + $form->setWrapperLegend( wfMsg( 'unblockip' ) ); |
| 68 | + $form->setSubmitCallback( array( __CLASS__, 'processUnblock' ) ); |
| 69 | + $form->setSubmitText( wfMsg( 'ipusubmit' ) ); |
| 70 | + $form->addPreText( wfMsgExt( 'unblockiptext', 'parse' ) ); |
| 71 | + |
| 72 | + if( $form->show() ){ |
| 73 | + switch( $this->type ){ |
| 74 | + case Block::TYPE_USER: |
| 75 | + case Block::TYPE_IP: |
| 76 | + $wgOut->addWikiMsg( 'unblocked', $this->target ); |
| 77 | + break; |
| 78 | + case Block::TYPE_RANGE: |
| 79 | + $wgOut->addWikiMsg( 'unblocked-range', $this->target ); |
| 80 | + break; |
| 81 | + case Block::TYPE_ID: |
| 82 | + case Block::TYPE_AUTO: |
| 83 | + $wgOut->addWikiMsg( 'unblocked-id', $this->target ); |
| 84 | + break; |
| 85 | + } |
| 86 | + } |
| 87 | + } |
| 88 | + |
| 89 | + protected function getFields(){ |
| 90 | + $fields = array( |
| 91 | + 'Target' => array( |
| 92 | + 'type' => 'text', |
| 93 | + 'label-message' => 'ipadressorusername', |
| 94 | + 'tabindex' => '1', |
| 95 | + 'size' => '45', |
| 96 | + 'required' => true, |
| 97 | + ), |
| 98 | + 'Name' => array( |
| 99 | + 'type' => 'info', |
| 100 | + 'label-message' => 'ipadressorusername', |
| 101 | + ), |
| 102 | + 'Reason' => array( |
| 103 | + 'type' => 'text', |
| 104 | + 'label-message' => 'ipbreason', |
| 105 | + ) |
| 106 | + ); |
| 107 | + |
| 108 | + if( $this->block instanceof Block ){ |
| 109 | + list( $target, $type ) = $this->block->getTargetAndType(); |
| 110 | + |
| 111 | + # Autoblocks are logged as "autoblock #123 because the IP was recently used by |
| 112 | + # User:Foo, and we've just got any block, auto or not, that applies to a target |
| 113 | + # the user has specified. Someone could be fishing to connect IPs to autoblocks, |
| 114 | + # so don't show any distinction between unblocked IPs and autoblocked IPs |
| 115 | + if( $type == Block::TYPE_AUTO && $this->type == Block::TYPE_IP ){ |
| 116 | + $fields['Target']['default'] = $this->target; |
| 117 | + unset( $fields['Name'] ); |
| 118 | + |
| 119 | + } else { |
| 120 | + $fields['Target']['default'] = $target; |
| 121 | + $fields['Target']['type'] = 'hidden'; |
| 122 | + switch( $type ){ |
| 123 | + case Block::TYPE_USER: |
| 124 | + case Block::TYPE_IP: |
| 125 | + global $wgUser; |
| 126 | + $skin = $wgUser->getSkin(); |
| 127 | + $fields['Name']['default'] = $skin->link( |
| 128 | + $target->getUserPage(), |
| 129 | + $target->getName() |
| 130 | + ); |
| 131 | + $fields['Name']['raw'] = true; |
| 132 | + break; |
| 133 | + |
| 134 | + case Block::TYPE_RANGE: |
| 135 | + $fields['Name']['default'] = $target; |
| 136 | + break; |
| 137 | + |
| 138 | + case Block::TYPE_AUTO: |
| 139 | + $fields['Name']['default'] = $this->block->getRedactedName(); |
| 140 | + $fields['Name']['raw'] = true; |
| 141 | + # Don't expose the real target of the autoblock |
| 142 | + $fields['Target']['default'] = "#{$this->target}"; |
| 143 | + break; |
| 144 | + } |
| 145 | + } |
| 146 | + |
| 147 | + } else { |
| 148 | + $fields['Target']['default'] = $this->target; |
| 149 | + unset( $fields['Name'] ); |
| 150 | + } |
| 151 | + return $fields; |
| 152 | + } |
| 153 | + |
| 154 | + /** |
| 155 | + * Process the form |
| 156 | + * @return Array( Array(message key, parameters) ) on failure, True on success |
| 157 | + */ |
| 158 | + public static function processUnblock( array $data ){ |
| 159 | + global $wgUser; |
| 160 | + |
| 161 | + $target = $data['Target']; |
| 162 | + $block = Block::newFromTarget( $data['Target'] ); |
| 163 | + |
| 164 | + if( !$block instanceof Block ){ |
| 165 | + return array( array( 'ipb_cant_unblock', $target ) ); |
| 166 | + } |
| 167 | + |
| 168 | + # If the specified IP is a single address, and the block is a range block, don't |
| 169 | + # unblock the whole range. |
| 170 | + list( $target, $type ) = SpecialBlock::getTargetAndType( $target ); |
| 171 | + if( $block->getType() == Block::TYPE_RANGE && $type == Block::TYPE_IP ) { |
| 172 | + $range = $block->mAddress; |
| 173 | + return array( array( 'ipb_blocked_as_range', $target, $range ) ); |
| 174 | + } |
| 175 | + |
| 176 | + # If the name was hidden and the blocking user cannot hide |
| 177 | + # names, then don't allow any block removals... |
| 178 | + if( !$wgUser->isAllowed( 'hideuser' ) && $block->mHideName ) { |
| 179 | + return array( 'unblock-hideuser' ); |
| 180 | + } |
| 181 | + |
| 182 | + # Delete block |
| 183 | + if ( !$block->delete() ) { |
| 184 | + return array( 'ipb_cant_unblock', htmlspecialchars( $block->getTarget() ) ); |
| 185 | + } |
| 186 | + |
| 187 | + # Unset _deleted fields as needed |
| 188 | + if( $block->mHideName ) { |
| 189 | + RevisionDeleteUser::unsuppressUserName( $block->mAddress, $block->mUser ); |
| 190 | + } |
| 191 | + |
| 192 | + # Make log entry |
| 193 | + $log = new LogPage( 'block' ); |
| 194 | + $page = $block->getTarget() instanceof User |
| 195 | + ? $block->getTarget()->getUserpage() |
| 196 | + : Title::makeTitle( NS_USER, $block->getTarget() ); |
| 197 | + $log->addEntry( 'unblock', $page, $data['Reason'] ); |
| 198 | + |
| 199 | + return true; |
| 200 | + } |
| 201 | +} |
\ No newline at end of file |
Property changes on: trunk/phase3/includes/specials/SpecialUnblock.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 202 | + native |
Index: trunk/phase3/includes/specials/SpecialIpblocklist.php |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | * @ingroup SpecialPage |
30 | 30 | */ |
31 | 31 | class IPUnblockForm extends SpecialPage { |
32 | | - var $ip, $reason, $id; |
| 32 | + var $ip; |
33 | 33 | var $hideuserblocks, $hidetempblocks, $hideaddressblocks; |
34 | 34 | |
35 | 35 | function __construct() { |
— | — | @@ -48,223 +48,23 @@ |
49 | 49 | |
50 | 50 | $ip = $wgRequest->getVal( 'ip', $ip ); |
51 | 51 | $this->ip = trim( $wgRequest->getVal( 'wpUnblockAddress', $ip ) ); |
52 | | - $this->id = $wgRequest->getVal( 'id' ); |
53 | | - $this->reason = $wgRequest->getText( 'wpUnblockReason' ); |
54 | 52 | $this->hideuserblocks = $wgRequest->getBool( 'hideuserblocks' ); |
55 | 53 | $this->hidetempblocks = $wgRequest->getBool( 'hidetempblocks' ); |
56 | 54 | $this->hideaddressblocks = $wgRequest->getBool( 'hideaddressblocks' ); |
57 | 55 | |
58 | 56 | $action = $wgRequest->getText( 'action' ); |
59 | | - $successip = $wgRequest->getVal( 'successip' ); |
60 | 57 | |
61 | 58 | if( $action == 'unblock' || $action == 'submit' && $wgRequest->wasPosted() ) { |
62 | | - # Check permissions |
63 | | - if( !$wgUser->isAllowed( 'block' ) ) { |
64 | | - $wgOut->permissionRequired( 'block' ); |
65 | | - return; |
66 | | - } |
67 | | - # Check for database lock |
68 | | - if( wfReadOnly() ) { |
69 | | - $wgOut->readOnlyPage(); |
70 | | - return; |
71 | | - } |
72 | | - |
73 | | - # bug 15810: blocked admins should have limited access here |
74 | | - if ( $wgUser->isBlocked() ) { |
75 | | - if ( $this->id ) { |
76 | | - # This doesn't pick up on autoblocks, but admins |
77 | | - # should have the ipblock-exempt permission anyway |
78 | | - $block = Block::newFromID( $this->id ); |
79 | | - $user = User::newFromName( $block->mAddress ); |
80 | | - } else { |
81 | | - $user = User::newFromName( $ip ); |
82 | | - } |
83 | | - $status = SpecialBlock::checkUnblockSelf( $user ); |
84 | | - if ( $status !== true ) { |
85 | | - throw new ErrorPageError( 'badaccess', $status ); |
86 | | - } |
87 | | - } |
88 | | - |
89 | | - if( $action == 'unblock' ){ |
90 | | - # Show unblock form |
91 | | - $this->showForm(); |
92 | | - } elseif( $action == 'submit' |
93 | | - && $wgRequest->wasPosted() |
94 | | - && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) |
95 | | - { |
96 | | - # Remove blocks and redirect user to success page |
97 | | - $this->doSubmit(); |
98 | | - } |
99 | | - |
100 | | - } elseif( $action == 'success' ) { |
101 | | - # Inform the user of a successful unblock |
102 | | - # (No need to check permissions or locks here, |
103 | | - # if something was done, then it's too late!) |
104 | | - if ( substr( $successip, 0, 1) == '#' ) { |
105 | | - // A block ID was unblocked |
106 | | - $this->showList( $wgOut->parse( wfMsg( 'unblocked-id', $successip ) ) ); |
107 | | - } else { |
108 | | - // A username/IP was unblocked |
109 | | - $this->showList( $wgOut->parse( wfMsg( 'unblocked', $successip ) ) ); |
110 | | - } |
| 59 | + # B/C @since 1.18: Unblock interface is now at Special:Unblock |
| 60 | + $title = SpecialPage::getTitleFor( 'Unblock', $this->ip ); |
| 61 | + $wgOut->redirect( $title->getFullUrl() ); |
| 62 | + return; |
111 | 63 | } else { |
112 | 64 | # Just show the block list |
113 | 65 | $this->showList( '' ); |
114 | 66 | } |
115 | 67 | } |
116 | 68 | |
117 | | - /** |
118 | | - * Generates the unblock form |
119 | | - * |
120 | | - * @param $err String, Array or null: error message name or an array if |
121 | | - * there are parameters. Null indicates no error. |
122 | | - * @return $out string: HTML form |
123 | | - */ |
124 | | - function showForm( $err = null ) { |
125 | | - global $wgOut, $wgUser; |
126 | | - |
127 | | - $wgOut->addWikiMsg( 'unblockiptext' ); |
128 | | - |
129 | | - $action = $this->getTitle()->getLocalURL( 'action=submit' ); |
130 | | - |
131 | | - if ( $err !== null ) { |
132 | | - $wgOut->setSubtitle( wfMsg( 'formerror' ) ); |
133 | | - $wgOut->wrapWikiMsg( "<span class='error'>$1</span>\n", $err ); |
134 | | - } |
135 | | - |
136 | | - $addressPart = false; |
137 | | - if ( $this->id ) { |
138 | | - $block = Block::newFromID( $this->id ); |
139 | | - if ( $block ) { |
140 | | - $encName = htmlspecialchars( $block->getRedactedName() ); |
141 | | - $encId = $this->id; |
142 | | - $addressPart = $encName . Html::hidden( 'id', $encId ); |
143 | | - $ipa = wfMsgHtml( 'ipadressorusername' ); |
144 | | - } |
145 | | - } |
146 | | - if ( !$addressPart ) { |
147 | | - $addressPart = Xml::input( 'wpUnblockAddress', 40, $this->ip, array( 'type' => 'text', 'tabindex' => '1' ) ); |
148 | | - $ipa = Xml::label( wfMsg( 'ipadressorusername' ), 'wpUnblockAddress' ); |
149 | | - } |
150 | | - |
151 | | - $wgOut->addHTML( |
152 | | - Html::openElement( 'form', array( 'method' => 'post', 'action' => $action, 'id' => 'unblockip' ) ) . |
153 | | - Html::openElement( 'fieldset' ) . |
154 | | - Html::element( 'legend', null, wfMsg( 'ipb-unblock' ) ) . |
155 | | - Html::openElement( 'table', array( 'id' => 'mw-unblock-table' ) ). |
156 | | - "<tr> |
157 | | - <td class='mw-label'> |
158 | | - {$ipa} |
159 | | - </td> |
160 | | - <td class='mw-input'> |
161 | | - {$addressPart} |
162 | | - </td> |
163 | | - </tr> |
164 | | - <tr> |
165 | | - <td class='mw-label'>" . |
166 | | - Xml::label( wfMsg( 'ipbreason' ), 'wpUnblockReason' ) . |
167 | | - "</td> |
168 | | - <td class='mw-input'>" . |
169 | | - Xml::input( 'wpUnblockReason', 40, $this->reason, array( 'type' => 'text', 'tabindex' => '2' ) ) . |
170 | | - "</td> |
171 | | - </tr> |
172 | | - <tr> |
173 | | - <td> </td> |
174 | | - <td class='mw-submit'>" . |
175 | | - Xml::submitButton( wfMsg( 'ipusubmit' ), array( 'name' => 'wpBlock', 'tabindex' => '3' ) ) . |
176 | | - "</td> |
177 | | - </tr>" . |
178 | | - Html::closeElement( 'table' ) . |
179 | | - Html::closeElement( 'fieldset' ) . |
180 | | - Html::hidden( 'wpEditToken', $wgUser->editToken() ) . |
181 | | - Html::closeElement( 'form' ) . "\n" |
182 | | - ); |
183 | | - |
184 | | - } |
185 | | - |
186 | | - const UNBLOCK_SUCCESS = 0; // Success |
187 | | - const UNBLOCK_NO_SUCH_ID = 1; // No such block ID |
188 | | - const UNBLOCK_USER_NOT_BLOCKED = 2; // IP wasn't blocked |
189 | | - const UNBLOCK_BLOCKED_AS_RANGE = 3; // IP is part of a range block |
190 | | - const UNBLOCK_UNKNOWNERR = 4; // Unknown error |
191 | | - |
192 | | - /** |
193 | | - * Backend code for unblocking. doSubmit() wraps around this. |
194 | | - * $range is only used when UNBLOCK_BLOCKED_AS_RANGE is returned, in which |
195 | | - * case it contains the range $ip is part of. |
196 | | - * @return array array(message key, parameters) on failure, empty array on success |
197 | | - */ |
198 | | - public static function doUnblock( &$id, &$ip, &$reason, &$range = null, $blocker = null ) { |
199 | | - if ( $id ) { |
200 | | - $block = Block::newFromID( $id ); |
201 | | - if ( !$block ) { |
202 | | - return array( 'ipb_cant_unblock', htmlspecialchars( $id ) ); |
203 | | - } |
204 | | - $ip = $block->getRedactedName(); |
205 | | - } else { |
206 | | - $ip = trim( $ip ); |
207 | | - if ( substr( $ip, 0, 1 ) == "#" ) { |
208 | | - $id = substr( $ip, 1 ); |
209 | | - $block = Block::newFromID( $id ); |
210 | | - if( !$block ) { |
211 | | - return array( 'ipb_cant_unblock', htmlspecialchars( $id ) ); |
212 | | - } |
213 | | - $ip = $block->getRedactedName(); |
214 | | - } else { |
215 | | - # FIXME: do proper sanitisation/cleanup here |
216 | | - $ip = str_replace( '_', ' ', $ip ); |
217 | | - |
218 | | - $block = Block::newFromDB( $ip ); |
219 | | - if ( !$block ) { |
220 | | - return array( 'ipb_cant_unblock', htmlspecialchars( $id ) ); |
221 | | - } |
222 | | - if( $block->mRangeStart != $block->mRangeEnd && !strstr( $ip, "/" ) ) { |
223 | | - /* If the specified IP is a single address, and the block is |
224 | | - * a range block, don't unblock the range. */ |
225 | | - $range = $block->mAddress; |
226 | | - return array( 'ipb_blocked_as_range', $ip, $range ); |
227 | | - } |
228 | | - } |
229 | | - } |
230 | | - // Yes, this is really necessary |
231 | | - $id = $block->mId; |
232 | | - |
233 | | - # If the name was hidden and the blocking user cannot hide |
234 | | - # names, then don't allow any block removals... |
235 | | - if( $blocker && $block->mHideName && !$blocker->isAllowed( 'hideuser' ) ) { |
236 | | - return array( 'ipb_cant_unblock', htmlspecialchars( $id ) ); |
237 | | - } |
238 | | - |
239 | | - # Delete block |
240 | | - if ( !$block->delete() ) { |
241 | | - return array( 'ipb_cant_unblock', htmlspecialchars( $id ) ); |
242 | | - } |
243 | | - |
244 | | - # Unset _deleted fields as needed |
245 | | - if( $block->mHideName ) { |
246 | | - RevisionDeleteUser::unsuppressUserName( $block->mAddress, $block->mUser ); |
247 | | - } |
248 | | - |
249 | | - # Make log entry |
250 | | - $log = new LogPage( 'block' ); |
251 | | - $log->addEntry( 'unblock', Title::makeTitle( NS_USER, $ip ), $reason ); |
252 | | - return array(); |
253 | | - } |
254 | | - |
255 | | - function doSubmit() { |
256 | | - global $wgOut, $wgUser; |
257 | | - |
258 | | - $retval = self::doUnblock( $this->id, $this->ip, $this->reason, $range, $wgUser ); |
259 | | - if ( count( $retval ) ) { |
260 | | - $this->showForm( $retval ); |
261 | | - return; |
262 | | - } |
263 | | - |
264 | | - # Report to the user |
265 | | - $success = $this->getTitle()->getFullURL( 'action=success&successip=' . urlencode( $this->ip ) ); |
266 | | - $wgOut->redirect( $success ); |
267 | | - } |
268 | | - |
269 | 69 | function showList( $msg ) { |
270 | 70 | global $wgOut, $wgUser; |
271 | 71 | |
Index: trunk/phase3/includes/specials/SpecialContributions.php |
— | — | @@ -256,13 +256,8 @@ |
257 | 257 | wfMsgHtml( 'change-blocklink' ) |
258 | 258 | ); |
259 | 259 | $tools[] = $sk->linkKnown( # Unblock link |
260 | | - SpecialPage::getTitleFor( 'Ipblocklist' ), |
261 | | - wfMsgHtml( 'unblocklink' ), |
262 | | - array(), |
263 | | - array( |
264 | | - 'action' => 'unblock', |
265 | | - 'ip' => $username |
266 | | - ) |
| 260 | + SpecialPage::getTitleFor( 'Unblock', $username ), |
| 261 | + wfMsgHtml( 'unblocklink' ) |
267 | 262 | ); |
268 | 263 | } else { # User is not blocked |
269 | 264 | $tools[] = $sk->linkKnown( # Block link |
Index: trunk/phase3/includes/specials/SpecialBlock.php |
— | — | @@ -297,15 +297,14 @@ |
298 | 298 | } |
299 | 299 | |
300 | 300 | # Link to unblock the specified user, or to a blank unblock form |
301 | | - $list = SpecialPage::getTitleFor( 'Ipblocklist' ); |
302 | | - $query = array( 'action' => 'unblock' ); |
303 | 301 | if( $this->target instanceof User ) { |
304 | 302 | $message = wfMsgExt( 'ipb-unblock-addr', array( 'parseinline' ), $this->target->getName() ); |
305 | | - $query['ip'] = $this->target->getName(); |
| 303 | + $list = SpecialPage::getTitleFor( 'Unblock', $this->target->getName() ); |
306 | 304 | } else { |
307 | 305 | $message = wfMsgExt( 'ipb-unblock', array( 'parseinline' ) ); |
| 306 | + $list = SpecialPage::getTitleFor( 'Unblock' ); |
308 | 307 | } |
309 | | - $links[] = $skin->linkKnown( $list, $message, array(), $query ); |
| 308 | + $links[] = $skin->linkKnown( $list, $message, array() ); |
310 | 309 | |
311 | 310 | # Link to the block list |
312 | 311 | $links[] = $skin->linkKnown( |
— | — | @@ -492,7 +491,7 @@ |
493 | 492 | $userId = 0; |
494 | 493 | } else { |
495 | 494 | # This should have been caught in the form field validation |
496 | | - return wfMessage( 'badipaddress' ); |
| 495 | + return array( 'badipaddress' ); |
497 | 496 | } |
498 | 497 | |
499 | 498 | if( ( strlen( $data['Expiry'] ) == 0) || ( strlen( $data['Expiry'] ) > 50 ) |
Index: trunk/phase3/includes/Block.php |
— | — | @@ -920,7 +920,11 @@ |
921 | 921 | # FIXME: everything above here is a mess, needs much cleaning up |
922 | 922 | |
923 | 923 | /** |
924 | | - * Given a target and the target's type, get a Block object if possible |
| 924 | + * Given a target and the target's type, get an existing Block object if possible. |
| 925 | + * Note that passing an IP address will get an applicable rangeblock if the IP is |
| 926 | + * not individually blocked but falls within that range |
| 927 | + * TODO: check that that fallback handles nested rangeblocks nicely (should return |
| 928 | + * smallest one) |
925 | 929 | * @param $target String|User|Int a block target, which may be one of several types: |
926 | 930 | * * A user to block, in which case $target will be a User |
927 | 931 | * * An IP to block, in which case $target will be a User generated by using |
— | — | @@ -942,7 +946,7 @@ |
943 | 947 | } |
944 | 948 | |
945 | 949 | } elseif( $type == Block::TYPE_RANGE ){ |
946 | | - return Block::newFromDB( '', $target ); |
| 950 | + return Block::newFromDB( $target, 0 ); |
947 | 951 | |
948 | 952 | } elseif( $type == Block::TYPE_ID || $type == Block::TYPE_AUTO ){ |
949 | 953 | return Block::newFromID( $target ); |
— | — | @@ -1009,4 +1013,14 @@ |
1010 | 1014 | |
1011 | 1015 | return array( $target, $type ); |
1012 | 1016 | } |
| 1017 | + |
| 1018 | + public function getType(){ |
| 1019 | + list( $target, $type ) = $this->getTargetAndType(); |
| 1020 | + return $type; |
| 1021 | + } |
| 1022 | + |
| 1023 | + public function getTarget(){ |
| 1024 | + list( $target, $type ) = $this->getTargetAndType(); |
| 1025 | + return $target; |
| 1026 | + } |
1013 | 1027 | } |
Index: trunk/phase3/includes/SpecialPage.php |
— | — | @@ -137,8 +137,8 @@ |
138 | 138 | |
139 | 139 | # Users and rights |
140 | 140 | 'Block' => 'SpecialBlock', |
| 141 | + 'Unblock' => 'SpecialUnblock', |
141 | 142 | 'Ipblocklist' => 'IPUnblockForm', |
142 | | - 'Unblock' => array( 'SpecialRedirectToSpecial', 'Unblock', 'Ipblocklist', false, array( 'uselang', 'ip', 'id' ), array( 'action' => 'unblock' ) ), |
143 | 143 | 'Resetpass' => 'SpecialResetpass', |
144 | 144 | 'DeletedContributions' => 'DeletedContributionsPage', |
145 | 145 | 'Preferences' => 'SpecialPreferences', |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -3066,6 +3066,7 @@ |
3067 | 3067 | 'unblockiptext' => 'Use the form below to restore write access to a previously blocked IP address or username.', |
3068 | 3068 | 'ipusubmit' => 'Remove this block', |
3069 | 3069 | 'unblocked' => '[[User:$1|$1]] has been unblocked', |
| 3070 | +'unblocked-range' => '$1 has been unblocked', |
3070 | 3071 | 'unblocked-id' => 'Block $1 has been removed', |
3071 | 3072 | 'ipblocklist' => 'Blocked IP addresses and usernames', |
3072 | 3073 | 'ipblocklist-legend' => 'Find a blocked user', |
— | — | @@ -3120,6 +3121,7 @@ |
3121 | 3122 | $1 is already blocked. |
3122 | 3123 | Do you want to change the settings?', |
3123 | 3124 | 'ipb-otherblocks-header' => 'Other {{PLURAL:$1|block|blocks}}', |
| 3125 | +'unblock-hideuser' => 'You cannot unblock this user, as their username has been hidden.', |
3124 | 3126 | 'ipb_cant_unblock' => 'Error: Block ID $1 not found. |
3125 | 3127 | It may have been unblocked already.', |
3126 | 3128 | 'ipb_blocked_as_range' => 'Error: The IP address $1 is not blocked directly and cannot be unblocked. |