Follow-up r83794, r83792: restore new SpecialBlock.php code from r83786. This revisi...
[lhc/web/wiklou.git] / includes / specials / SpecialBlock.php
1 <?php
2 /**
3 * Implements Special:Block
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup SpecialPage
22 */
23
24 /**
25 * A special page that allows users with 'block' right to block users from
26 * editing pages and other actions
27 *
28 * @ingroup SpecialPage
29 */
30 class SpecialBlock extends SpecialPage {
31
32 # The maximum number of edits a user can have and still be hidden
33 # TODO: config setting?
34 const HIDEUSER_CONTRIBLIMIT = 1000;
35
36 # @var User user to be blocked, as passed either by parameter (url?wpTarget=Foo)
37 # or as subpage (Special:Block/Foo)
38 protected $target;
39
40 # @var Block::TYPE_ constant
41 protected $type;
42
43 # @var Bool
44 protected $alreadyBlocked;
45
46 public function __construct() {
47 parent::__construct( 'Block', 'block' );
48 }
49
50 public function execute( $par ) {
51 global $wgUser, $wgOut, $wgRequest;
52
53 # Can't block when the database is locked
54 if( wfReadOnly() ) {
55 $wgOut->readOnlyPage();
56 return;
57 }
58 # Permission check
59 if( !$this->userCanExecute( $wgUser ) ) {
60 $wgOut->permissionRequired( 'block' );
61 return;
62 }
63
64 # Extract variables from the request. Try not to get into a situation where we
65 # need to extract *every* variable from the form just for processing here, but
66 # there are legitimate uses for some variables
67 list( $this->target, $this->type ) = self::getTargetAndType( $par, $wgRequest );
68 if ( $this->target instanceof User ) {
69 # Set the 'relevant user' in the skin, so it displays links like Contributions,
70 # User logs, UserRights, etc.
71 $wgUser->getSkin()->setRelevantUser( $this->target );
72 }
73
74 # bug 15810: blocked admins should have limited access here
75 $status = self::checkUnblockSelf( $this->target );
76 if ( $status !== true ) {
77 throw new ErrorPageError( 'badaccess', $status );
78 }
79
80 $wgOut->setPageTitle( wfMsg( 'blockip-title' ) );
81 $wgOut->addModules( 'mediawiki.special', 'mediawiki.special.block' );
82
83 $fields = self::getFormFields();
84 $this->alreadyBlocked = $this->maybeAlterFormDefaults( $fields );
85
86 $form = new HTMLForm( $fields );
87 $form->setTitle( $this->getTitle() );
88 $form->setWrapperLegend( wfMsg( 'blockip-legend' ) );
89 $form->setSubmitCallback( array( __CLASS__, 'processForm' ) );
90
91 $t = $this->alreadyBlocked
92 ? wfMsg( 'ipb-change-block' )
93 : wfMsg( 'ipbsubmit' );
94 $form->setSubmitText( $t );
95
96 $this->doPreText( $form );
97 $this->doPostText( $form );
98
99 if( $form->show() ){
100 $wgOut->setPageTitle( wfMsg( 'blockipsuccesssub' ) );
101 $wgOut->addHTML( wfMsgExt( 'blockipsuccesstext', array( 'parse' ), $this->target ) );
102 }
103 }
104
105 /**
106 * Get the HTMLForm descriptor array for the block form
107 * @return Array
108 */
109 protected static function getFormFields(){
110 global $wgUser, $wgBlockAllowsUTEdit;
111
112 $a = array(
113 'Target' => array(
114 'type' => 'text',
115 'label-message' => 'ipadressorusername',
116 'tabindex' => '1',
117 'id' => 'mw-bi-target',
118 'size' => '45',
119 'required' => true,
120 ),
121 'Expiry' => array(
122 'type' => 'selectorother',
123 'label-message' => 'ipbexpiry',
124 'required' => true,
125 'tabindex' => '2',
126 'options' => self::getSuggestedDurations(),
127 'other' => wfMsg( 'ipbother' ),
128 ),
129 'Reason' => array(
130 'type' => 'selectandother',
131 'label-message' => 'ipbreason',
132 'options-message' => 'ipbreason-dropdown',
133 ),
134 'CreateAccount' => array(
135 'type' => 'check',
136 'label-message' => 'ipbcreateaccount',
137 'default' => true,
138 ),
139 );
140
141 if( wfMsgForContent( 'ipboptions' ) == '-' ){
142 $a['Expiry']['type'] = 'text';
143 }
144
145 if( self::canBlockEmail( $wgUser ) ) {
146 $a['DisableEmail'] = array(
147 'type' => 'check',
148 'label-message' => 'ipbemailban',
149 );
150 }
151
152 if( $wgBlockAllowsUTEdit ){
153 $a['DisableUTEdit'] = array(
154 'type' => 'check',
155 'label-message' => 'ipb-disableusertalk',
156 'default' => false,
157 );
158 }
159
160 $a['AutoBlock'] = array(
161 'type' => 'check',
162 'label-message' => 'ipbenableautoblock',
163 'default' => true,
164 );
165
166 # Allow some users to hide name from block log, blocklist and listusers
167 if( $wgUser->isAllowed( 'hideuser' ) ) {
168 $a['HideUser'] = array(
169 'type' => 'check',
170 'label-message' => 'ipbhidename',
171 'cssclass' => 'mw-block-hideuser',
172 );
173 }
174
175 # Watchlist their user page? (Only if user is logged in)
176 if( $wgUser->isLoggedIn() ) {
177 $a['Watch'] = array(
178 'type' => 'check',
179 'label-message' => 'ipbwatchuser',
180 );
181 }
182
183 $a['HardBlock'] = array(
184 'type' => 'check',
185 'label-message' => 'ipb-hardblock',
186 'default' => false,
187 );
188
189 $a['AlreadyBlocked'] = array(
190 'type' => 'hidden',
191 'default' => false,
192 );
193
194 return $a;
195 }
196
197 /**
198 * If the user has already been blocked with similar settings, load that block
199 * and change the defaults for the form fields to match the existing settings.
200 * @param &$fields Array HTMLForm descriptor array
201 * @return Bool whether fields were altered (that is, whether the target is
202 * already blocked)
203 */
204 protected function maybeAlterFormDefaults( &$fields ){
205 $fields['Target']['default'] = $this->target;
206
207 $block = self::getBlockFromTargetAndType( $this->target, $this->type );
208
209 if( $block instanceof Block && !$block->mAuto # The block exists and isn't an autoblock
210 && ( $this->type != Block::TYPE_RANGE # The block isn't a rangeblock
211 || $block->mAddress == $this->target ) # or if it is, the range is what we're about to block
212 )
213 {
214 $fields['HardBlock']['default'] = !$block->mAnonOnly;
215 $fields['CreateAccount']['default'] = $block->mCreateAccount;
216 $fields['AutoBlock']['default'] = $block->mEnableAutoblock;
217 $fields['DisableEmail']['default'] = $block->mBlockEmail;
218 $fields['HideUser']['default'] = $block->mHideName;
219 $fields['DisableUTEdit']['default'] = !$block->mAllowUsertalk;
220 $fields['Reason']['default'] = $block->mReason;
221 $fields['AlreadyBlocked']['default'] = true;
222
223 if( $block->mExpiry == 'infinity' ) {
224 $fields['Expiry']['default'] = 'indefinite';
225 } else {
226 $fields['Expiry']['default'] = wfTimestamp( TS_RFC2822, $block->mExpiry );
227 }
228
229 return true;
230 }
231 return false;
232 }
233
234 /**
235 * Add header elements like block log entries, etc.
236 * @param $form HTMLForm
237 * @return void
238 */
239 protected function doPreText( HTMLForm &$form ){
240 $form->addPreText( wfMsgExt( 'blockiptext', 'parse' ) );
241
242 $otherBlockMessages = array();
243 if( $this->target !== null ) {
244 # Get other blocks, i.e. from GlobalBlocking or TorBlock extension
245 wfRunHooks( 'OtherBlockLogLink', array( &$otherBlockMessages, $this->target ) );
246
247 if( count( $otherBlockMessages ) ) {
248 $s = Html::rawElement(
249 'h2',
250 array(),
251 wfMsgExt( 'ipb-otherblocks-header', 'parseinline', count( $otherBlockMessages ) )
252 ) . "\n";
253 $list = '';
254 foreach( $otherBlockMessages as $link ) {
255 $list .= Html::rawElement( 'li', array(), $link ) . "\n";
256 }
257 $s .= Html::rawElement(
258 'ul',
259 array( 'class' => 'mw-blockip-alreadyblocked' ),
260 $list
261 ) . "\n";
262 $form->addPreText( $s );
263 }
264 }
265
266 # Username/IP is blocked already locally
267 if( $this->alreadyBlocked ) {
268 $form->addPreText( Html::rawElement(
269 'div',
270 array( 'class' => 'mw-ipb-needreblock', ),
271 wfMsgExt(
272 'ipb-needreblock',
273 array( 'parseinline' ),
274 $this->target
275 ) ) );
276 }
277 }
278
279 /**
280 * Add footer elements to the form
281 * @param $form HTMLForm
282 * @return void
283 */
284 protected function doPostText( HTMLForm &$form ){
285 global $wgUser, $wgLang;
286
287 $skin = $wgUser->getSkin();
288
289 # Link to the user's contributions, if applicable
290 if( $this->target instanceof User ){
291 $contribsPage = SpecialPage::getTitleFor( 'Contributions', $this->target->getName() );
292 $links[] = $skin->link(
293 $contribsPage,
294 wfMsgExt( 'ipb-blocklist-contribs', 'escape', $this->target->getName() )
295 );
296 }
297
298 # Link to unblock the specified user, or to a blank unblock form
299 $list = SpecialPage::getTitleFor( 'Ipblocklist' );
300 $query = array( 'action' => 'unblock' );
301 if( $this->target instanceof User ) {
302 $message = wfMsgExt( 'ipb-unblock-addr', array( 'parseinline' ), $this->target->getName() );
303 $query['ip'] = $this->target->getName();
304 } else {
305 $message = wfMsgExt( 'ipb-unblock', array( 'parseinline' ) );
306 }
307 $links[] = $skin->linkKnown( $list, $message, array(), $query );
308
309 # Link to the block list
310 $links[] = $skin->linkKnown(
311 SpecialPage::getTitleFor( 'Ipblocklist' ),
312 wfMsg( 'ipb-blocklist' )
313 );
314
315 # Link to edit the block dropdown reasons, if applicable
316 if ( $wgUser->isAllowed( 'editinterface' ) ) {
317 $links[] = $skin->link(
318 Title::makeTitle( NS_MEDIAWIKI, 'Ipbreason-dropdown' ),
319 wfMsgHtml( 'ipb-edit-dropdown' ),
320 array(),
321 array( 'action' => 'edit' )
322 );
323 }
324
325 $form->addPostText( Html::rawElement(
326 'p',
327 array( 'class' => 'mw-ipb-conveniencelinks' ),
328 $wgLang->pipeList( $links )
329 ) );
330
331 if( $this->target instanceof User ){
332 # Get relevant extracts from the block and suppression logs, if possible
333 $userpage = $this->target->getUserPage();
334 $out = '';
335
336 LogEventsList::showLogExtract(
337 $out,
338 'block',
339 $userpage->getPrefixedText(),
340 '',
341 array(
342 'lim' => 10,
343 'msgKey' => array( 'blocklog-showlog', $userpage->getText() ),
344 'showIfEmpty' => false
345 )
346 );
347 $form->addPostText( $out );
348
349 # Add suppression block entries if allowed
350 if( $wgUser->isAllowed( 'suppressionlog' ) ) {
351 LogEventsList::showLogExtract(
352 $out,
353 'suppress',
354 $userpage->getPrefixedText(),
355 '',
356 array(
357 'lim' => 10,
358 'conds' => array( 'log_action' => array( 'block', 'reblock', 'unblock' ) ),
359 'msgKey' => array( 'blocklog-showsuppresslog', $userpage->getText() ),
360 'showIfEmpty' => false
361 )
362 );
363 $form->addPostText( $out );
364 }
365 }
366 }
367
368 /**
369 * Determine the target of the block, and the type of target
370 * TODO: should be in Block.php?
371 * @param $par String subpage parameter passed to setup, or data value from
372 * the HTMLForm
373 * @param $request WebRequest optionally try and get data from a request too
374 * @return void
375 */
376 public static function getTargetAndType( $par, WebRequest $request = null ){
377 $i = 0;
378 $target = null;
379 while( true ){
380 switch( $i++ ){
381 case 0:
382 # The HTMLForm will check wpTarget first and only if it doesn't get
383 # a value use the default, which will be generated from the options
384 # below; so this has to have a higher precedence here than $par, or
385 # we could end up with different values in $this->target and the HTMLForm!
386 if( $request instanceof WebRequest ){
387 $target = $request->getText( 'wpTarget', null );
388 }
389 break;
390 case 1:
391 $target = $par;
392 break;
393 case 2:
394 if( $request instanceof WebRequest ){
395 $target = $request->getText( 'ip', null );
396 }
397 break;
398 case 3:
399 # B/C @since 1.18
400 if( $request instanceof WebRequest ){
401 $target = $request->getText( 'wpBlockAddress', null );
402 }
403 break;
404 case 4:
405 break 2;
406 }
407
408 $userObj = User::newFromName( $target );
409 if( $userObj instanceof User ){
410 return array( $userObj, Block::TYPE_USER );
411 } elseif( IP::isValid( $target ) ){
412 # We can still create a User if it's an IP address, but we need to turn
413 # off validation checking (which would exclude IP addresses)
414 return array(
415 User::newFromName( IP::sanitizeIP( $target ), false ),
416 Block::TYPE_IP
417 );
418 break;
419 } elseif( IP::isValidBlock( $target ) ){
420 # Can't create a User from an IP range
421 return array( Block::normaliseRange( $target ), Block::TYPE_RANGE );
422 }
423 }
424 return array( null, null );
425 }
426
427 /**
428 * Given a target and the target's type, get a block object if possible
429 * @param $target String|User
430 * @param $type Block::TYPE_ constant
431 * @return Block|null
432 * TODO: this probably belongs in Block.php when that mess is cleared up
433 */
434 public static function getBlockFromTargetAndType( $target, $type ){
435 if( $target instanceof User ){
436 if( $type == Block::TYPE_IP ){
437 return Block::newFromDB( $target->getName(), 0 );
438 } elseif( $type == Block::TYPE_USER ) {
439 return Block::newFromDB( '', $target->getId() );
440 } else {
441 # Should be unreachable;
442 return null;
443 }
444 } elseif( $type == Block::TYPE_RANGE ){
445 return Block::newFromDB( '', $target );
446 } else {
447 return null;
448 }
449 }
450
451 /**
452 * Given the form data, actually implement a block
453 * @param $data Array
454 * @return Bool|String
455 */
456 public static function processForm( array $data ){
457 global $wgUser, $wgBlockAllowsUTEdit, $wgBlockCIDRLimit;
458
459 list( $target, $type ) = self::getTargetAndType( $data['Target'] );
460
461 if( $type == Block::TYPE_USER ){
462 # TODO: why do we not have a User->exists() method?
463 if( !$target->getId() ){
464 return array( array( 'nosuchusershort', $target->getName() ) );
465 }
466
467 $status = self::checkUnblockSelf( $target );
468 if ( $status !== true ) {
469 return array( array( 'badaccess', $status ) );
470 }
471
472 $user = $target;
473 $target = $user->getName();
474 $userId = $user->getId();
475
476 } elseif( $type == Block::TYPE_RANGE ){
477 list( $ip, $range ) = explode( '/', $target, 2 );
478
479 if( ( IP::isIPv4( $ip ) && $wgBlockCIDRLimit['IPv4'] == 32 )
480 || ( IP::isIPv6( $ip ) && $wgBlockCIDRLimit['IPV6'] == 128 ) )
481 {
482 # Range block effectively disabled
483 return array( 'range_block_disabled' );
484 }
485
486 if( ( IP::isIPv4( $ip ) && $range > 32 )
487 || ( IP::isIPv6( $ip ) && $range > 128 ) )
488 {
489 # Dodgy range
490 return array( 'ip_range_invalid' );
491 }
492
493 if( IP::isIPv4( $ip ) && $range < $wgBlockCIDRLimit['IPv4'] ) {
494 return array( array( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv4'] ) );
495 }
496
497 if( IP::isIPv6( $ip ) && $range < $wgBlockCIDRLimit['IPv6'] ) {
498 return array( array( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv6'] ) );
499 }
500
501 $userId = 0;
502
503 } elseif( $type == Block::TYPE_IP ){
504 # All is well
505 $target = $target->getName();
506 $userId = 0;
507
508 } else {
509 return array( 'badipaddress' );
510 }
511
512 if( ( strlen( $data['Expiry'] ) == 0) || ( strlen( $data['Expiry'] ) > 50 )
513 || !Block::parseExpiryInput( $data['Expiry'] ) )
514 {
515 return array( 'ipb_expiry_invalid' );
516 }
517
518 if( !$wgBlockAllowsUTEdit ){
519 $data['PreventUTEdit'] = true;
520 }
521
522 # If the user has done the form 'properly', they won't even have been given the
523 # option to suppress-block unless they have the 'hideuser' permission
524 if( !isset( $data['HideUser'] ) ){
525 $data['HideUser'] = false;
526 }
527 if( $data['HideUser'] ) {
528 if( !$wgUser->isAllowed('hideuser') ){
529 # this codepath is unreachable except by a malicious user spoofing forms,
530 # or by race conditions (user has oversight and sysop, loads block form,
531 # and is de-oversighted before submission); so need to fail completely
532 # rather than just silently disable hiding
533 return array( 'badaccess-group0' );
534 }
535
536 # Recheck params here...
537 if( $type != Block::TYPE_USER ) {
538 $data['HideUser'] = false; # IP users should not be hidden
539
540 } elseif( !in_array( $data['Expiry'], array( 'inifinite', 'infinity', 'indefinite' ) ) ) {
541 # Bad expiry.
542 return array( 'ipb_expiry_temp' );
543
544 } elseif( $user->getEditCount() > self::HIDEUSER_CONTRIBLIMIT ) {
545 # Typically, the user should have a handful of edits.
546 # Disallow hiding users with many edits for performance.
547 return array( 'ipb_hide_invalid' );
548 }
549 }
550
551 # Create block object. Note that for a user block, ipb_address is only for display purposes
552 # FIXME: Why do we need to pass fourteen optional parameters to do this!?!
553 $block = new Block(
554 $target, # IP address or User name
555 $userId, # User id
556 $wgUser->getId(), # Blocker id
557 $data['Reason'][0], # Reason string
558 wfTimestampNow(), # Block Timestamp
559 0, # Is this an autoblock (no)
560 Block::parseExpiryInput( $data['Expiry'] ), # Expiry time
561 !$data['HardBlock'], # Block anon only
562 $data['CreateAccount'],
563 $data['AutoBlock'],
564 $data['HideUser'],
565 $data['DisableEmail'],
566 !$data['DisableUTEdit'] # *Allow* UTEdit
567 );
568
569 if( !wfRunHooks( 'BlockIp', array( &$block, &$wgUser ) ) ) {
570 return array( 'hookaborted' );
571 }
572
573 # Try to insert block. Is there a conflicting block?
574 if( !$block->insert() ) {
575
576 # Show form unless the user is already aware of this...
577 if( !$data['AlreadyBlocked'] ) {
578 return array( array( 'ipb_already_blocked', $data['Target'] ) );
579
580 # Otherwise, try to update the block...
581 } else {
582
583 # This returns direct blocks before autoblocks/rangeblocks, since we should
584 # be sure the user is blocked by now it should work for our purposes
585 $currentBlock = Block::newFromDB( $target, $userId );
586
587 if( $block->equals( $currentBlock ) ) {
588 return array( 'ipb_already_blocked' );
589 }
590
591 # If the name was hidden and the blocking user cannot hide
592 # names, then don't allow any block changes...
593 if( $currentBlock->mHideName && !$wgUser->isAllowed( 'hideuser' ) ) {
594 return array( 'cant-see-hidden-user' );
595 }
596
597 $currentBlock->delete();
598 $block->insert();
599 $logaction = 'reblock';
600
601 # Unset _deleted fields if requested
602 if( $currentBlock->mHideName && !$data['HideUser'] ) {
603 RevisionDeleteUser::unsuppressUserName( $target, $userId );
604 }
605
606 # If hiding/unhiding a name, this should go in the private logs
607 if( (bool)$currentBlock->mHideName ){
608 $data['HideUser'] = true;
609 }
610 }
611
612 } else {
613 $logaction = 'block';
614 }
615
616 wfRunHooks( 'BlockIpComplete', array( $block, $wgUser ) );
617
618 # Set *_deleted fields if requested
619 if( $data['HideUser'] ) {
620 RevisionDeleteUser::suppressUserName( $target, $userId );
621 }
622
623 # Can't watch a rangeblock
624 if( $type != Block::TYPE_RANGE && $data['Watch'] ) {
625 $wgUser->addWatch( Title::makeTitle( NS_USER, $target ) );
626 }
627
628 # Block constructor sanitizes certain block options on insert
629 $data['BlockEmail'] = $block->mBlockEmail;
630 $data['AutoBlock'] = $block->mEnableAutoblock;
631
632 # Prepare log parameters
633 $logParams = array();
634 $logParams[] = $data['Expiry'];
635 $logParams[] = self::blockLogFlags( $data, $type );
636
637 # Make log entry, if the name is hidden, put it in the oversight log
638 $log_type = $data['HideUser'] ? 'suppress' : 'block';
639 $log = new LogPage( $log_type );
640 $log->addEntry(
641 $logaction,
642 Title::makeTitle( NS_USER, $target ),
643 $data['Reason'][0],
644 $logParams
645 );
646
647 # Report to the user
648 return true;
649 }
650
651 /**
652 * Get an array of suggested block durations from MediaWiki:Ipboptions
653 * FIXME: this uses a rather odd syntax for the options, should it be converted
654 * to the standard "**<duration>|<displayname>" format?
655 * @return Array
656 */
657 protected static function getSuggestedDurations(){
658 $a = array();
659 foreach( explode( ',', wfMsgForContent( 'ipboptions' ) ) as $option ) {
660 if( strpos( $option, ':' ) === false ) $option = "$option:$option";
661 list( $show, $value ) = explode( ':', $option );
662 $a[htmlspecialchars( $show )] = htmlspecialchars( $value );
663 }
664 return $a;
665 }
666
667 /**
668 * Can we do an email block?
669 * @param $user User: the sysop wanting to make a block
670 * @return Boolean
671 */
672 public static function canBlockEmail( $user ) {
673 global $wgEnableUserEmail, $wgSysopEmailBans;
674 return ( $wgEnableUserEmail && $wgSysopEmailBans && $user->isAllowed( 'blockemail' ) );
675 }
676
677 /**
678 * bug 15810: blocked admins should not be able to block/unblock
679 * others, and probably shouldn't be able to unblock themselves
680 * either.
681 * @param $user User|Int|String
682 */
683 public static function checkUnblockSelf( $user ) {
684 global $wgUser;
685 if ( is_int( $user ) ) {
686 $user = User::newFromId( $user );
687 } elseif ( is_string( $user ) ) {
688 $user = User::newFromName( $user );
689 }
690 if( $wgUser->isBlocked() ){
691 if( $user instanceof User && $user->getId() == $wgUser->getId() ) {
692 # User is trying to unblock themselves
693 if ( $wgUser->isAllowed( 'unblockself' ) ) {
694 return true;
695 } else {
696 return 'ipbnounblockself';
697 }
698 } else {
699 # User is trying to block/unblock someone else
700 return 'ipbblocked';
701 }
702 } else {
703 return true;
704 }
705 }
706
707 /**
708 * Return a comma-delimited list of "flags" to be passed to the log
709 * reader for this block, to provide more information in the logs
710 * @param $data Array from HTMLForm data
711 * @param $type Block::TYPE_ constant
712 * @return array
713 */
714 protected static function blockLogFlags( array $data, $type ) {
715 global $wgBlockAllowsUTEdit;
716 $flags = array();
717
718 # when blocking a user the option 'anononly' is not available/has no effect -> do not write this into log
719 if( !$data['HardBlock'] && $type != Block::TYPE_USER ){
720 $flags[] = 'anononly';
721 }
722
723 if( $data['CreateAccount'] ){
724 $flags[] = 'nocreate';
725 }
726
727 # Same as anononly, this is not displayed when blocking an IP address
728 if( !$data['AutoBlock'] && $type != Block::TYPE_IP ){
729 $flags[] = 'noautoblock';
730 }
731
732 if( $data['DisableEmail'] ){
733 $flags[] = 'noemail';
734 }
735
736 if( $data['DisableUTEdit'] && $wgBlockAllowsUTEdit ){
737 $flags[] = 'nousertalk';
738 }
739
740 if( $data['HideUser'] ){
741 $flags[] = 'hiddenname';
742 }
743
744 return implode( ',', $flags );
745 }
746 }
747
748 # BC @since 1.18
749 class IPBlockForm extends SpecialBlock {}