$log_action = 'reblock';
# Unset _deleted fields if requested
if( $currentBlock->mHideName && !$this->BlockHideName ) {
- $this->unsuppressUserName( $this->BlockAddress, $userId );
+ self::unsuppressUserName( $this->BlockAddress, $userId );
}
}
} else {
# Set *_deleted fields if requested
if( $this->BlockHideName ) {
- $this->suppressUserName( $this->BlockAddress, $userId );
+ self::suppressUserName( $this->BlockAddress, $userId );
}
if ( $this->BlockWatchUser &&
}
}
- private function suppressUserName( $name, $userId ) {
+ public static function suppressUserName( $name, $userId ) {
$op = '|'; // bitwise OR
- return $this->setUsernameBitfields( $name, $userId, $op );
+ return self::setUsernameBitfields( $name, $userId, $op );
}
- private function unsuppressUserName( $name, $userId ) {
+ public static function unsuppressUserName( $name, $userId ) {
$op = '&'; // bitwise AND
- return $this->setUsernameBitfields( $name, $userId, $op );
+ return self::setUsernameBitfields( $name, $userId, $op );
}
- private function setUsernameBitfields( $name, $userId, $op ) {
+ private static function setUsernameBitfields( $name, $userId, $op ) {
if( $op !== '|' && $op !== '&' ) return false; // sanity check
$dbw = wfGetDB( DB_MASTER );
$delUser = Revision::DELETED_USER | Revision::DELETED_RESTRICTED;
# current bitfields with the inverse of Revision::DELETED_USER. The
# username bit is made to 0 (x & 0 = 0), while others are unchanged (x & 1 = x).
# The same goes for the sysop-restricted *_deleted bit.
- if( $op == '&' ) $delUser = "~{$delUser}";
- if( $op == '&' ) $delAction = "~{$delAction}";
+ if( $op == '&' ) {
+ $delUser = "~{$delUser}";
+ $delAction = "~{$delAction}";
+ }
# Hide name from live edits
$dbw->update( 'revision', array("rev_deleted = rev_deleted $op $delUser"),
array('rev_user' => $userId), __METHOD__ );
* @return array array(message key, parameters) on failure, empty array on success
*/
- static function doUnblock(&$id, &$ip, &$reason, &$range = null) {
+ static function doUnblock(&$id, &$ip, &$reason, &$range = null, $blocker=null) {
if ( $id ) {
$block = Block::newFromID( $id );
if ( !$block ) {
if ( !$block ) {
return array('ipb_cant_unblock', htmlspecialchars($id));
}
- if( $block->mRangeStart != $block->mRangeEnd
- && !strstr( $ip, "/" ) ) {
+ if( $block->mRangeStart != $block->mRangeEnd && !strstr( $ip, "/" ) ) {
/* If the specified IP is a single address, and the block is
* a range block, don't unblock the range. */
$range = $block->mAddress;
}
// Yes, this is really necessary
$id = $block->mId;
+
+ # If the name was hidden and the blocking user cannot hide
+ # names, then don't allow any block removals...
+ if( $blocker && $block->mHideName && !$blocker->isAllowed('hideuser') ) {
+ return array('ipb_cant_unblock', htmlspecialchars($id));
+ }
# Delete block
if ( !$block->delete() ) {
return array('ipb_cant_unblock', htmlspecialchars($id));
}
+
+ # Unset _deleted fields as needed
+ if( $block->mHideName ) {
+ IPBlockForm::unsuppressUserName( $block->mAddress, $block->mUser );
+ }
# Make log entry
$log = new LogPage( 'block' );
}
function doSubmit() {
- global $wgOut;
- $retval = self::doUnblock($this->id, $this->ip, $this->reason, $range);
- if(!empty($retval))
- {
+ global $wgOut, $wgUser;
+ $retval = self::doUnblock($this->id, $this->ip, $this->reason, $range, $wgUser);
+ if( !empty($retval) ) {
$key = array_shift($retval);
$this->showForm(wfMsgReal($key, $retval));
return;