180 public static function processUnblock( array $data, IContextSource $context ) {
181 $performer = $context->getUser();
182 $target = $data['Target'];
183 $block = Block::newFromTarget( $data['Target'] );
185 if ( !$block instanceof Block ) {
186 return [ [ 'ipb_cant_unblock', $target ] ];
189 # bug 15810: blocked admins should have limited access here. This
190 # won't allow sysops to remove autoblocks on themselves, but they
191 # should have ipblock-exempt anyway
192 $status = SpecialBlock::checkUnblockSelf( $target, $performer );
193 if ( $status !== true ) {
194 throw new ErrorPageError( 'badaccess', $status );
197 # If the specified IP is a single address, and the block is a range block, don't
198 # unblock the whole range.
199 list( $target, $type ) = SpecialBlock::getTargetAndType( $target );
200 if ( $block->getType() == Block::TYPE_RANGE && $type == Block::TYPE_IP ) {
201 $range = $block->getTarget();
203 return [ [ 'ipb_blocked_as_range', $target, $range ] ];
206 # If the name was hidden and the blocking user cannot hide
207 # names, then don't allow any block removals...
208 if ( !$performer->isAllowed( 'hideuser' ) && $block->mHideName ) {
209 return [ 'unblock-hideuser' ];
213 if ( !$block->delete() ) {
214 return [ 'ipb_cant_unblock', htmlspecialchars( $block->getTarget() ) ];
217 # Unset _deleted fields as needed
218 if ( $block->mHideName ) {
219 # Something is deeply FUBAR if this is not a User object, but who knows?
220 $id = $block->getTarget() instanceof User
221 ? $block->getTarget()->getId()
222 : User::idFromName( $block->getTarget() );
224 RevisionDeleteUser::unsuppressUserName( $block->getTarget(), $id );
227 # Redact the name (IP address) for autoblocks
228 if ( $block->getType() == Block::TYPE_AUTO ) {
229 $page = Title::makeTitle( NS_USER, '#' . $block->getId() );
231 $page = $block->getTarget() instanceof User
232 ? $block->getTarget()->getUserPage()
233 : Title::makeTitle( NS_USER, $block->getTarget() );
237 $logEntry = new ManualLogEntry( 'block', 'unblock' );
238 $logEntry->setTarget( $page );
239 $logEntry->setComment( $data['Reason'] );
240 $logEntry->setPerformer( $performer );
241 if ( isset( $data['Tags'] ) ) {
242 $logEntry->setTags( $data['Tags'] );
244 $logId = $logEntry->insert();
245 $logEntry->publish( $logId );
258 public function prefixSearchSubpages( $search, $limit, $offset ) {
259 $user = User::newFromName( $search );
261 // No prefix suggestion for invalid user
264 // Autocomplete subpage as user list - public to allow caching
265 return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );