51 $this->block = DatabaseBlock::newFromTarget( $this->target );
52 if ( $this->target instanceof
User ) {
53 # Set the 'relevant user' in the skin, so it displays links like Contributions,
54 # User logs, UserRights, etc.
55 $this->
getSkin()->setRelevantUser( $this->target );
63 $out->setPageTitle( $this->
msg(
'unblockip' ) );
64 $out->addModules( [
'mediawiki.userSuggest' ] );
67 $form->setWrapperLegendMsg(
'unblockip' );
68 $form->setSubmitCallback( [ __CLASS__,
'processUIUnblock' ] );
69 $form->setSubmitTextMsg(
'ipusubmit' );
70 $form->addPreText( $this->
msg(
'unblockiptext' )->parseAsBlock() );
72 if ( $form->show() ) {
73 switch ( $this->type ) {
74 case DatabaseBlock::TYPE_IP:
77 case DatabaseBlock::TYPE_USER:
80 case DatabaseBlock::TYPE_RANGE:
83 case DatabaseBlock::TYPE_ID:
84 case DatabaseBlock::TYPE_AUTO:
184 public static function processUnblock( array $data, IContextSource $context ) {
185 $performer = $context->getUser();
186 $target = $data['Target'];
187 $block = DatabaseBlock::newFromTarget( $data['Target'] );
189 if ( !$block instanceof DatabaseBlock ) {
190 return [ [ 'ipb_cant_unblock', $target ] ];
193 # T17810: blocked admins should have limited access here. This
194 # won't allow sysops to remove autoblocks on themselves, but they
195 # should have ipblock-exempt anyway
196 $status = SpecialBlock::checkUnblockSelf( $target, $performer );
197 if ( $status !== true ) {
198 throw new ErrorPageError( 'badaccess', $status );
201 # If the specified IP is a single address, and the block is a range block, don't
202 # unblock the whole range.
203 list( $target, $type ) = SpecialBlock::getTargetAndType( $target );
204 if ( $block->getType() == DatabaseBlock::TYPE_RANGE && $type == DatabaseBlock::TYPE_IP ) {
205 $range = $block->getTarget();
207 return [ [ 'ipb_blocked_as_range', $target, $range ] ];
210 # If the name was hidden and the blocking user cannot hide
211 # names, then don't allow any block removals...
212 if ( !MediaWikiServices::getInstance()
213 ->getPermissionManager()
214 ->userHasRight( $performer, 'hideuser' ) && $block->getHideName()
216 return [ 'unblock-hideuser' ];
219 $reason = [ 'hookaborted' ];
220 if ( !Hooks::run( 'UnblockUser', [ &$block, &$performer, &$reason ] ) ) {
225 if ( !$block->delete() ) {
226 return [ [ 'ipb_cant_unblock', htmlspecialchars( $block->getTarget() ) ] ];
229 Hooks::run( 'UnblockUserComplete', [ $block, $performer ] );
231 # Unset _deleted fields as needed
232 if ( $block->getHideName() ) {
233 # Something is deeply FUBAR if this is not a User object, but who knows?
234 $id = $block->getTarget() instanceof User
235 ? $block->getTarget()->getId()
236 : User::idFromName( $block->getTarget() );
238 RevisionDeleteUser::unsuppressUserName( $block->getTarget(), $id );
241 # Redact the name (IP address) for autoblocks
242 if ( $block->getType() == DatabaseBlock::TYPE_AUTO ) {
243 $page = Title::makeTitle( NS_USER, '#' . $block->getId() );
245 $page = $block->getTarget() instanceof User
246 ? $block->getTarget()->getUserPage()
247 : Title::makeTitle( NS_USER, $block->getTarget() );
251 $logEntry = new ManualLogEntry( 'block', 'unblock' );
252 $logEntry->setTarget( $page );
253 $logEntry->setComment( $data['Reason'] );
254 $logEntry->setPerformer( $performer );
255 if ( isset( $data['Tags'] ) ) {
256 $logEntry->addTags( $data['Tags'] );
258 $logEntry->setRelations( [ 'ipb_id' => $block->getId() ] );
259 $logId = $logEntry->insert();
260 $logEntry->publish( $logId );