Index: trunk/phase3/includes/specials/SpecialIpblocklist.php |
— | — | @@ -162,7 +162,7 @@ |
163 | 163 | * @return array array(message key, parameters) on failure, empty array on success |
164 | 164 | */ |
165 | 165 | |
166 | | - static function doUnblock(&$id, &$ip, &$reason, &$range = null) { |
| 166 | + static function doUnblock(&$id, &$ip, &$reason, &$range = null, $blocker=null) { |
167 | 167 | if ( $id ) { |
168 | 168 | $block = Block::newFromID( $id ); |
169 | 169 | if ( !$block ) { |
— | — | @@ -184,8 +184,7 @@ |
185 | 185 | if ( !$block ) { |
186 | 186 | return array('ipb_cant_unblock', htmlspecialchars($id)); |
187 | 187 | } |
188 | | - if( $block->mRangeStart != $block->mRangeEnd |
189 | | - && !strstr( $ip, "/" ) ) { |
| 188 | + if( $block->mRangeStart != $block->mRangeEnd && !strstr( $ip, "/" ) ) { |
190 | 189 | /* If the specified IP is a single address, and the block is |
191 | 190 | * a range block, don't unblock the range. */ |
192 | 191 | $range = $block->mAddress; |
— | — | @@ -195,11 +194,22 @@ |
196 | 195 | } |
197 | 196 | // Yes, this is really necessary |
198 | 197 | $id = $block->mId; |
| 198 | + |
| 199 | + # If the name was hidden and the blocking user cannot hide |
| 200 | + # names, then don't allow any block removals... |
| 201 | + if( $blocker && $block->mHideName && !$blocker->isAllowed('hideuser') ) { |
| 202 | + return array('ipb_cant_unblock', htmlspecialchars($id)); |
| 203 | + } |
199 | 204 | |
200 | 205 | # Delete block |
201 | 206 | if ( !$block->delete() ) { |
202 | 207 | return array('ipb_cant_unblock', htmlspecialchars($id)); |
203 | 208 | } |
| 209 | + |
| 210 | + # Unset _deleted fields as needed |
| 211 | + if( $block->mHideName ) { |
| 212 | + IPBlockForm::unsuppressUserName( $block->mAddress, $block->mUser ); |
| 213 | + } |
204 | 214 | |
205 | 215 | # Make log entry |
206 | 216 | $log = new LogPage( 'block' ); |
— | — | @@ -208,10 +218,9 @@ |
209 | 219 | } |
210 | 220 | |
211 | 221 | function doSubmit() { |
212 | | - global $wgOut; |
213 | | - $retval = self::doUnblock($this->id, $this->ip, $this->reason, $range); |
214 | | - if(!empty($retval)) |
215 | | - { |
| 222 | + global $wgOut, $wgUser; |
| 223 | + $retval = self::doUnblock($this->id, $this->ip, $this->reason, $range, $wgUser); |
| 224 | + if( !empty($retval) ) { |
216 | 225 | $key = array_shift($retval); |
217 | 226 | $this->showForm(wfMsgReal($key, $retval)); |
218 | 227 | return; |
Index: trunk/phase3/includes/specials/SpecialBlockip.php |
— | — | @@ -445,7 +445,7 @@ |
446 | 446 | $log_action = 'reblock'; |
447 | 447 | # Unset _deleted fields if requested |
448 | 448 | if( $currentBlock->mHideName && !$this->BlockHideName ) { |
449 | | - $this->unsuppressUserName( $this->BlockAddress, $userId ); |
| 449 | + self::unsuppressUserName( $this->BlockAddress, $userId ); |
450 | 450 | } |
451 | 451 | } |
452 | 452 | } else { |
— | — | @@ -455,7 +455,7 @@ |
456 | 456 | |
457 | 457 | # Set *_deleted fields if requested |
458 | 458 | if( $this->BlockHideName ) { |
459 | | - $this->suppressUserName( $this->BlockAddress, $userId ); |
| 459 | + self::suppressUserName( $this->BlockAddress, $userId ); |
460 | 460 | } |
461 | 461 | |
462 | 462 | if ( $this->BlockWatchUser && |
— | — | @@ -486,17 +486,17 @@ |
487 | 487 | } |
488 | 488 | } |
489 | 489 | |
490 | | - private function suppressUserName( $name, $userId ) { |
| 490 | + public static function suppressUserName( $name, $userId ) { |
491 | 491 | $op = '|'; // bitwise OR |
492 | | - return $this->setUsernameBitfields( $name, $userId, $op ); |
| 492 | + return self::setUsernameBitfields( $name, $userId, $op ); |
493 | 493 | } |
494 | 494 | |
495 | | - private function unsuppressUserName( $name, $userId ) { |
| 495 | + public static function unsuppressUserName( $name, $userId ) { |
496 | 496 | $op = '&'; // bitwise AND |
497 | | - return $this->setUsernameBitfields( $name, $userId, $op ); |
| 497 | + return self::setUsernameBitfields( $name, $userId, $op ); |
498 | 498 | } |
499 | 499 | |
500 | | - private function setUsernameBitfields( $name, $userId, $op ) { |
| 500 | + private static function setUsernameBitfields( $name, $userId, $op ) { |
501 | 501 | if( $op !== '|' && $op !== '&' ) return false; // sanity check |
502 | 502 | $dbw = wfGetDB( DB_MASTER ); |
503 | 503 | $delUser = Revision::DELETED_USER | Revision::DELETED_RESTRICTED; |
— | — | @@ -509,8 +509,10 @@ |
510 | 510 | # current bitfields with the inverse of Revision::DELETED_USER. The |
511 | 511 | # username bit is made to 0 (x & 0 = 0), while others are unchanged (x & 1 = x). |
512 | 512 | # The same goes for the sysop-restricted *_deleted bit. |
513 | | - if( $op == '&' ) $delUser = "~{$delUser}"; |
514 | | - if( $op == '&' ) $delAction = "~{$delAction}"; |
| 513 | + if( $op == '&' ) { |
| 514 | + $delUser = "~{$delUser}"; |
| 515 | + $delAction = "~{$delAction}"; |
| 516 | + } |
515 | 517 | # Hide name from live edits |
516 | 518 | $dbw->update( 'revision', array("rev_deleted = rev_deleted $op $delUser"), |
517 | 519 | array('rev_user' => $userId), __METHOD__ ); |