3 * Implements Special:Block
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.
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.
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
21 * @ingroup SpecialPage
25 * A special page that allows users with 'block' right to block users from
26 * editing pages and other actions
28 * @ingroup SpecialPage
30 class SpecialBlock
extends FormSpecialPage
{
31 /** The maximum number of edits a user can have and still be hidden
32 * TODO: config setting? */
33 const HIDEUSER_CONTRIBLIMIT
= 1000;
35 /** @var User user to be blocked, as passed either by parameter (url?wpTarget=Foo)
36 * or as subpage (Special:Block/Foo) */
39 /// @var Block::TYPE_ constant
42 /// @var User|String the previous block target
43 protected $previousTarget;
45 /// @var Bool whether the previous submission of the form asked for HideUser
46 protected $requestedHideUser;
49 protected $alreadyBlocked;
52 protected $preErrors = array();
54 public function __construct() {
55 parent
::__construct( 'Block', 'block' );
59 * Checks that the user can unblock themselves if they are trying to do so
62 * @throws ErrorPageError
64 protected function checkExecutePermissions( User
$user ) {
65 parent
::checkExecutePermissions( $user );
67 # bug 15810: blocked admins should have limited access here
68 $status = self
::checkUnblockSelf( $this->target
, $user );
69 if ( $status !== true ) {
70 throw new ErrorPageError( 'badaccess', $status );
75 * Handle some magic here
79 protected function setParameter( $par ) {
80 # Extract variables from the request. Try not to get into a situation where we
81 # need to extract *every* variable from the form just for processing here, but
82 # there are legitimate uses for some variables
83 $request = $this->getRequest();
84 list( $this->target
, $this->type
) = self
::getTargetAndType( $par, $request );
85 if ( $this->target
instanceof User
) {
86 # Set the 'relevant user' in the skin, so it displays links like Contributions,
87 # User logs, UserRights, etc.
88 $this->getSkin()->setRelevantUser( $this->target
);
91 list( $this->previousTarget
, /*...*/ ) = Block
::parseTarget( $request->getVal( 'wpPreviousTarget' ) );
92 $this->requestedHideUser
= $request->getBool( 'wpHideUser' );
96 * Customizes the HTMLForm a bit
98 * @param $form HTMLForm
100 protected function alterForm( HTMLForm
$form ) {
101 $form->setWrapperLegendMsg( 'blockip-legend' );
102 $form->setHeaderText( '' );
103 $form->setSubmitCallback( array( __CLASS__
, 'processUIForm' ) );
105 $msg = $this->alreadyBlocked ?
'ipb-change-block' : 'ipbsubmit';
106 $form->setSubmitTextMsg( $msg );
108 # Don't need to do anything if the form has been posted
109 if( !$this->getRequest()->wasPosted() && $this->preErrors
){
110 $s = HTMLForm
::formatErrors( $this->preErrors
);
112 $form->addHeaderText( Html
::rawElement(
114 array( 'class' => 'error' ),
122 * Get the HTMLForm descriptor array for the block form
125 protected function getFormFields(){
126 global $wgBlockAllowsUTEdit;
128 $user = $this->getUser();
133 'label-message' => 'ipadressorusername',
135 'id' => 'mw-bi-target',
138 'validation-callback' => array( __CLASS__
, 'validateTargetField' ),
141 'type' => !count( self
::getSuggestedDurations() ) ?
'text' : 'selectorother',
142 'label-message' => 'ipbexpiry',
145 'options' => self
::getSuggestedDurations(),
146 'other' => $this->msg( 'ipbother' )->text(),
147 'default' => $this->msg( 'ipb-default-expiry' )->inContentLanguage()->text(),
150 'type' => 'selectandother',
151 'label-message' => 'ipbreason',
152 'options-message' => 'ipbreason-dropdown',
154 'CreateAccount' => array(
156 'label-message' => 'ipbcreateaccount',
161 if( self
::canBlockEmail( $user ) ) {
162 $a['DisableEmail'] = array(
164 'label-message' => 'ipbemailban',
168 if( $wgBlockAllowsUTEdit ){
169 $a['DisableUTEdit'] = array(
171 'label-message' => 'ipb-disableusertalk',
176 $a['AutoBlock'] = array(
178 'label-message' => 'ipbenableautoblock',
182 # Allow some users to hide name from block log, blocklist and listusers
183 if( $user->isAllowed( 'hideuser' ) ) {
184 $a['HideUser'] = array(
186 'label-message' => 'ipbhidename',
187 'cssclass' => 'mw-block-hideuser',
191 # Watchlist their user page? (Only if user is logged in)
192 if( $user->isLoggedIn() ) {
195 'label-message' => 'ipbwatchuser',
199 $a['HardBlock'] = array(
201 'label-message' => 'ipb-hardblock',
205 # This is basically a copy of the Target field, but the user can't change it, so we
206 # can see if the warnings we maybe showed to the user before still apply
207 $a['PreviousTarget'] = array(
212 # We'll turn this into a checkbox if we need to
213 $a['Confirm'] = array(
216 'label-message' => 'ipb-confirm',
219 $this->maybeAlterFormDefaults( $a );
225 * If the user has already been blocked with similar settings, load that block
226 * and change the defaults for the form fields to match the existing settings.
227 * @param $fields Array HTMLForm descriptor array
228 * @return Bool whether fields were altered (that is, whether the target is
231 protected function maybeAlterFormDefaults( &$fields ){
232 # This will be overwritten by request data
233 $fields['Target']['default'] = (string)$this->target
;
236 $fields['PreviousTarget']['default'] = (string)$this->target
;
238 $block = Block
::newFromTarget( $this->target
);
240 if( $block instanceof Block
&& !$block->mAuto
# The block exists and isn't an autoblock
241 && ( $this->type
!= Block
::TYPE_RANGE
# The block isn't a rangeblock
242 ||
$block->getTarget() == $this->target
) # or if it is, the range is what we're about to block
245 $fields['HardBlock']['default'] = $block->isHardblock();
246 $fields['CreateAccount']['default'] = $block->prevents( 'createaccount' );
247 $fields['AutoBlock']['default'] = $block->isAutoblocking();
249 if( isset( $fields['DisableEmail'] ) ){
250 $fields['DisableEmail']['default'] = $block->prevents( 'sendemail' );
253 if( isset( $fields['HideUser'] ) ){
254 $fields['HideUser']['default'] = $block->mHideName
;
257 if( isset( $fields['DisableUTEdit'] ) ){
258 $fields['DisableUTEdit']['default'] = $block->prevents( 'editownusertalk' );
261 $fields['Reason']['default'] = $block->mReason
;
263 if( $this->getRequest()->wasPosted() ){
264 # Ok, so we got a POST submission asking us to reblock a user. So show the
265 # confirm checkbox; the user will only see it if they haven't previously
266 $fields['Confirm']['type'] = 'check';
268 # We got a target, but it wasn't a POST request, so the user must have gone
269 # to a link like [[Special:Block/User]]. We don't need to show the checkbox
270 # as long as they go ahead and block *that* user
271 $fields['Confirm']['default'] = 1;
274 if( $block->mExpiry
== 'infinity' ) {
275 $fields['Expiry']['default'] = 'infinite';
277 $fields['Expiry']['default'] = wfTimestamp( TS_RFC2822
, $block->mExpiry
);
280 $this->alreadyBlocked
= true;
281 $this->preErrors
[] = array( 'ipb-needreblock', wfEscapeWikiText( (string)$block->getTarget() ) );
284 # We always need confirmation to do HideUser
285 if( $this->requestedHideUser
){
286 $fields['Confirm']['type'] = 'check';
287 unset( $fields['Confirm']['default'] );
288 $this->preErrors
[] = 'ipb-confirmhideuser';
291 # Or if the user is trying to block themselves
292 if( (string)$this->target
=== $this->getUser()->getName() ){
293 $fields['Confirm']['type'] = 'check';
294 unset( $fields['Confirm']['default'] );
295 $this->preErrors
[] = 'ipb-blockingself';
300 * Add header elements like block log entries, etc.
303 protected function preText(){
304 $text = $this->msg( 'blockiptext' )->parse();
306 $otherBlockMessages = array();
307 if( $this->target
!== null ) {
308 # Get other blocks, i.e. from GlobalBlocking or TorBlock extension
309 wfRunHooks( 'OtherBlockLogLink', array( &$otherBlockMessages, $this->target
) );
311 if( count( $otherBlockMessages ) ) {
312 $s = Html
::rawElement(
315 $this->msg( 'ipb-otherblocks-header', count( $otherBlockMessages ) )->parse()
320 foreach( $otherBlockMessages as $link ) {
321 $list .= Html
::rawElement( 'li', array(), $link ) . "\n";
324 $s .= Html
::rawElement(
326 array( 'class' => 'mw-blockip-alreadyblocked' ),
338 * Add footer elements to the form
341 protected function postText(){
344 # Link to the user's contributions, if applicable
345 if( $this->target
instanceof User
){
346 $contribsPage = SpecialPage
::getTitleFor( 'Contributions', $this->target
->getName() );
347 $links[] = Linker
::link(
349 $this->msg( 'ipb-blocklist-contribs', $this->target
->getName() )->escaped()
353 # Link to unblock the specified user, or to a blank unblock form
354 if( $this->target
instanceof User
) {
355 $message = $this->msg( 'ipb-unblock-addr', wfEscapeWikiText( $this->target
->getName() ) )->parse();
356 $list = SpecialPage
::getTitleFor( 'Unblock', $this->target
->getName() );
358 $message = $this->msg( 'ipb-unblock' )->parse();
359 $list = SpecialPage
::getTitleFor( 'Unblock' );
361 $links[] = Linker
::linkKnown( $list, $message, array() );
363 # Link to the block list
364 $links[] = Linker
::linkKnown(
365 SpecialPage
::getTitleFor( 'BlockList' ),
366 $this->msg( 'ipb-blocklist' )->escaped()
369 $user = $this->getUser();
371 # Link to edit the block dropdown reasons, if applicable
372 if ( $user->isAllowed( 'editinterface' ) ) {
373 $links[] = Linker
::link(
374 Title
::makeTitle( NS_MEDIAWIKI
, 'Ipbreason-dropdown' ),
375 $this->msg( 'ipb-edit-dropdown' )->escaped(),
377 array( 'action' => 'edit' )
381 $text = Html
::rawElement(
383 array( 'class' => 'mw-ipb-conveniencelinks' ),
384 $this->getLanguage()->pipeList( $links )
387 $userTitle = self
::getTargetUserTitle( $this->target
);
389 # Get relevant extracts from the block and suppression logs, if possible
392 LogEventsList
::showLogExtract(
399 'msgKey' => array( 'blocklog-showlog', $userTitle->getText() ),
400 'showIfEmpty' => false
405 # Add suppression block entries if allowed
406 if( $user->isAllowed( 'suppressionlog' ) ) {
407 LogEventsList
::showLogExtract(
414 'conds' => array( 'log_action' => array( 'block', 'reblock', 'unblock' ) ),
415 'msgKey' => array( 'blocklog-showsuppresslog', $userTitle->getText() ),
416 'showIfEmpty' => false
428 * Get a user page target for things like logs.
429 * This handles account and IP range targets.
430 * @param $target User|string
433 protected static function getTargetUserTitle( $target ) {
434 if( $target instanceof User
) {
435 return $target->getUserPage();
436 } elseif ( IP
::isIPAddress( $target ) ) {
437 return Title
::makeTitleSafe( NS_USER
, $target );
443 * Determine the target of the block, and the type of target
444 * TODO: should be in Block.php?
445 * @param $par String subpage parameter passed to setup, or data value from
447 * @param $request WebRequest optionally try and get data from a request too
448 * @return array( User|string|null, Block::TYPE_ constant|null )
450 public static function getTargetAndType( $par, WebRequest
$request = null ){
457 # The HTMLForm will check wpTarget first and only if it doesn't get
458 # a value use the default, which will be generated from the options
459 # below; so this has to have a higher precedence here than $par, or
460 # we could end up with different values in $this->target and the HTMLForm!
461 if( $request instanceof WebRequest
){
462 $target = $request->getText( 'wpTarget', null );
469 if( $request instanceof WebRequest
){
470 $target = $request->getText( 'ip', null );
475 if( $request instanceof WebRequest
){
476 $target = $request->getText( 'wpBlockAddress', null );
483 list( $target, $type ) = Block
::parseTarget( $target );
485 if( $type !== null ){
486 return array( $target, $type );
490 return array( null, null );
494 * HTMLForm field validation-callback for Target field.
496 * @param $value String
497 * @param $alldata Array
498 * @param $form HTMLForm
501 public static function validateTargetField( $value, $alldata, $form ) {
502 global $wgBlockCIDRLimit;
504 list( $target, $type ) = self
::getTargetAndType( $value );
506 if( $type == Block
::TYPE_USER
){
507 # TODO: why do we not have a User->exists() method?
508 if( !$target->getId() ){
509 return $form->msg( 'nosuchusershort',
510 wfEscapeWikiText( $target->getName() ) );
513 $status = self
::checkUnblockSelf( $target, $form->getUser() );
514 if ( $status !== true ) {
515 return $form->msg( 'badaccess', $status );
518 } elseif( $type == Block
::TYPE_RANGE
){
519 list( $ip, $range ) = explode( '/', $target, 2 );
521 if( ( IP
::isIPv4( $ip ) && $wgBlockCIDRLimit['IPv4'] == 32 )
522 ||
( IP
::isIPv6( $ip ) && $wgBlockCIDRLimit['IPv6'] == 128 ) )
524 # Range block effectively disabled
525 return $form->msg( 'range_block_disabled' );
528 if( ( IP
::isIPv4( $ip ) && $range > 32 )
529 ||
( IP
::isIPv6( $ip ) && $range > 128 ) )
532 return $form->msg( 'ip_range_invalid' );
535 if( IP
::isIPv4( $ip ) && $range < $wgBlockCIDRLimit['IPv4'] ) {
536 return $form->msg( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv4'] );
539 if( IP
::isIPv6( $ip ) && $range < $wgBlockCIDRLimit['IPv6'] ) {
540 return $form->msg( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv6'] );
542 } elseif( $type == Block
::TYPE_IP
){
545 return $form->msg( 'badipaddress' );
552 * Submit callback for an HTMLForm object, will simply pass
554 * @param $form HTMLForm
555 * @return Bool|String
557 public static function processUIForm( array $data, HTMLForm
$form ) {
558 return self
::processForm( $data, $form->getContext() );
562 * Given the form data, actually implement a block
564 * @param $context IContextSource
565 * @return Bool|String
567 public static function processForm( array $data, IContextSource
$context ){
568 global $wgBlockAllowsUTEdit;
570 $performer = $context->getUser();
572 // Handled by field validator callback
573 // self::validateTargetField( $data['Target'] );
575 # This might have been a hidden field or a checkbox, so interesting data
577 $data['Confirm'] = !in_array( $data['Confirm'], array( '', '0', null, false ), true );
579 list( $target, $type ) = self
::getTargetAndType( $data['Target'] );
580 if( $type == Block
::TYPE_USER
){
582 $target = $user->getName();
583 $userId = $user->getId();
585 # Give admins a heads-up before they go and block themselves. Much messier
586 # to do this for IPs, but it's pretty unlikely they'd ever get the 'block'
587 # permission anyway, although the code does allow for it.
588 # Note: Important to use $target instead of $data['Target']
589 # since both $data['PreviousTarget'] and $target are normalized
590 # but $data['target'] gets overriden by (non-normalized) request variable
591 # from previous request.
592 if( $target === $performer->getName() &&
593 ( $data['PreviousTarget'] !== $target ||
!$data['Confirm'] ) )
595 return array( 'ipb-blockingself' );
597 } elseif( $type == Block
::TYPE_RANGE
){
599 } elseif( $type == Block
::TYPE_IP
){
600 $target = $target->getName();
603 # This should have been caught in the form field validation
604 return array( 'badipaddress' );
607 if( ( strlen( $data['Expiry'] ) == 0) ||
( strlen( $data['Expiry'] ) > 50 )
608 ||
!self
::parseExpiryInput( $data['Expiry'] ) )
610 return array( 'ipb_expiry_invalid' );
613 if( !isset( $data['DisableEmail'] ) ){
614 $data['DisableEmail'] = false;
617 # If the user has done the form 'properly', they won't even have been given the
618 # option to suppress-block unless they have the 'hideuser' permission
619 if( !isset( $data['HideUser'] ) ){
620 $data['HideUser'] = false;
623 if( $data['HideUser'] ) {
624 if( !$performer->isAllowed('hideuser') ){
625 # this codepath is unreachable except by a malicious user spoofing forms,
626 # or by race conditions (user has oversight and sysop, loads block form,
627 # and is de-oversighted before submission); so need to fail completely
628 # rather than just silently disable hiding
629 return array( 'badaccess-group0' );
632 # Recheck params here...
633 if( $type != Block
::TYPE_USER
) {
634 $data['HideUser'] = false; # IP users should not be hidden
635 } elseif( !in_array( $data['Expiry'], array( 'infinite', 'infinity', 'indefinite' ) ) ) {
637 return array( 'ipb_expiry_temp' );
638 } elseif( $user->getEditCount() > self
::HIDEUSER_CONTRIBLIMIT
) {
639 # Typically, the user should have a handful of edits.
640 # Disallow hiding users with many edits for performance.
641 return array( 'ipb_hide_invalid' );
642 } elseif( !$data['Confirm'] ){
643 return array( 'ipb-confirmhideuser' );
647 # Create block object.
648 $block = new Block();
649 $block->setTarget( $target );
650 $block->setBlocker( $performer );
651 $block->mReason
= $data['Reason'][0];
652 $block->mExpiry
= self
::parseExpiryInput( $data['Expiry'] );
653 $block->prevents( 'createaccount', $data['CreateAccount'] );
654 $block->prevents( 'editownusertalk', ( !$wgBlockAllowsUTEdit ||
$data['DisableUTEdit'] ) );
655 $block->prevents( 'sendemail', $data['DisableEmail'] );
656 $block->isHardblock( $data['HardBlock'] );
657 $block->isAutoblocking( $data['AutoBlock'] );
658 $block->mHideName
= $data['HideUser'];
660 if( !wfRunHooks( 'BlockIp', array( &$block, &$performer ) ) ) {
661 return array( 'hookaborted' );
664 # Try to insert block. Is there a conflicting block?
665 $status = $block->insert();
667 # Show form unless the user is already aware of this...
668 if( !$data['Confirm'] ||
( array_key_exists( 'PreviousTarget', $data )
669 && $data['PreviousTarget'] !== $target ) )
671 return array( array( 'ipb_already_blocked', $block->getTarget() ) );
672 # Otherwise, try to update the block...
674 # This returns direct blocks before autoblocks/rangeblocks, since we should
675 # be sure the user is blocked by now it should work for our purposes
676 $currentBlock = Block
::newFromTarget( $target );
678 if( $block->equals( $currentBlock ) ) {
679 return array( array( 'ipb_already_blocked', $block->getTarget() ) );
682 # If the name was hidden and the blocking user cannot hide
683 # names, then don't allow any block changes...
684 if( $currentBlock->mHideName
&& !$performer->isAllowed( 'hideuser' ) ) {
685 return array( 'cant-see-hidden-user' );
688 $currentBlock->delete();
689 $status = $block->insert();
690 $logaction = 'reblock';
692 # Unset _deleted fields if requested
693 if( $currentBlock->mHideName
&& !$data['HideUser'] ) {
694 RevisionDeleteUser
::unsuppressUserName( $target, $userId );
697 # If hiding/unhiding a name, this should go in the private logs
698 if( (bool)$currentBlock->mHideName
){
699 $data['HideUser'] = true;
703 $logaction = 'block';
706 wfRunHooks( 'BlockIpComplete', array( $block, $performer ) );
708 # Set *_deleted fields if requested
709 if( $data['HideUser'] ) {
710 RevisionDeleteUser
::suppressUserName( $target, $userId );
713 # Can't watch a rangeblock
714 if( $type != Block
::TYPE_RANGE
&& $data['Watch'] ) {
715 $performer->addWatch( Title
::makeTitle( NS_USER
, $target ) );
718 # Block constructor sanitizes certain block options on insert
719 $data['BlockEmail'] = $block->prevents( 'sendemail' );
720 $data['AutoBlock'] = $block->isAutoblocking();
722 # Prepare log parameters
723 $logParams = array();
724 $logParams[] = $data['Expiry'];
725 $logParams[] = self
::blockLogFlags( $data, $type );
727 # Make log entry, if the name is hidden, put it in the oversight log
728 $log_type = $data['HideUser'] ?
'suppress' : 'block';
729 $log = new LogPage( $log_type );
730 $log_id = $log->addEntry(
732 Title
::makeTitle( NS_USER
, $target ),
736 # Relate log ID to block IDs (bug 25763)
737 $blockIds = array_merge( array( $status['id'] ), $status['autoIds'] );
738 $log->addRelations( 'ipb_id', $blockIds, $log_id );
745 * Get an array of suggested block durations from MediaWiki:Ipboptions
746 * @todo FIXME: This uses a rather odd syntax for the options, should it be converted
747 * to the standard "**<duration>|<displayname>" format?
748 * @param $lang Language|null the language to get the durations in, or null to use
749 * the wiki's content language
752 public static function getSuggestedDurations( $lang = null ){
754 $msg = $lang === null
755 ?
wfMessage( 'ipboptions' )->inContentLanguage()->text()
756 : wfMessage( 'ipboptions' )->inLanguage( $lang )->text();
762 foreach( explode( ',', $msg ) as $option ) {
763 if( strpos( $option, ':' ) === false ){
764 $option = "$option:$option";
767 list( $show, $value ) = explode( ':', $option );
768 $a[htmlspecialchars( $show )] = htmlspecialchars( $value );
775 * Convert a submitted expiry time, which may be relative ("2 weeks", etc) or absolute
776 * ("24 May 2034", etc), into an absolute timestamp we can put into the database.
777 * @param $expiry String: whatever was typed into the form
778 * @return String: timestamp or "infinity" string for the DB implementation
780 public static function parseExpiryInput( $expiry ) {
782 if( $infinity == null ){
783 $infinity = wfGetDB( DB_SLAVE
)->getInfinity();
786 if ( $expiry == 'infinite' ||
$expiry == 'indefinite' ) {
789 $expiry = strtotime( $expiry );
791 if ( $expiry < 0 ||
$expiry === false ) {
795 $expiry = wfTimestamp( TS_MW
, $expiry );
802 * Can we do an email block?
803 * @param $user User: the sysop wanting to make a block
806 public static function canBlockEmail( $user ) {
807 global $wgEnableUserEmail, $wgSysopEmailBans;
809 return ( $wgEnableUserEmail && $wgSysopEmailBans && $user->isAllowed( 'blockemail' ) );
813 * bug 15810: blocked admins should not be able to block/unblock
814 * others, and probably shouldn't be able to unblock themselves
816 * @param $user User|Int|String
817 * @param $performer User user doing the request
818 * @return Bool|String true or error message key
820 public static function checkUnblockSelf( $user, User
$performer ) {
821 if ( is_int( $user ) ) {
822 $user = User
::newFromId( $user );
823 } elseif ( is_string( $user ) ) {
824 $user = User
::newFromName( $user );
827 if( $performer->isBlocked() ){
828 if( $user instanceof User
&& $user->getId() == $performer->getId() ) {
829 # User is trying to unblock themselves
830 if ( $performer->isAllowed( 'unblockself' ) ) {
832 # User blocked themselves and is now trying to reverse it
833 } elseif ( $performer->blockedBy() === $performer->getName() ) {
836 return 'ipbnounblockself';
839 # User is trying to block/unblock someone else
848 * Return a comma-delimited list of "flags" to be passed to the log
849 * reader for this block, to provide more information in the logs
850 * @param $data Array from HTMLForm data
851 * @param $type Block::TYPE_ constant (USER, RANGE, or IP)
854 protected static function blockLogFlags( array $data, $type ) {
855 global $wgBlockAllowsUTEdit;
858 # when blocking a user the option 'anononly' is not available/has no effect -> do not write this into log
859 if( !$data['HardBlock'] && $type != Block
::TYPE_USER
){
860 // For grepping: message block-log-flags-anononly
861 $flags[] = 'anononly';
864 if( $data['CreateAccount'] ){
865 // For grepping: message block-log-flags-nocreate
866 $flags[] = 'nocreate';
869 # Same as anononly, this is not displayed when blocking an IP address
870 if( !$data['AutoBlock'] && $type == Block
::TYPE_USER
){
871 // For grepping: message block-log-flags-noautoblock
872 $flags[] = 'noautoblock';
875 if( $data['DisableEmail'] ){
876 // For grepping: message block-log-flags-noemail
877 $flags[] = 'noemail';
880 if( $wgBlockAllowsUTEdit && $data['DisableUTEdit'] ){
881 // For grepping: message block-log-flags-nousertalk
882 $flags[] = 'nousertalk';
885 if( $data['HideUser'] ){
886 // For grepping: message block-log-flags-hiddenname
887 $flags[] = 'hiddenname';
890 return implode( ',', $flags );
894 * Process the form on POST submission.
896 * @return Bool|Array true for success, false for didn't-try, array of errors on failure
898 public function onSubmit( array $data ) {
899 // This isn't used since we need that HTMLForm that's passed in the
900 // second parameter. See alterForm for the real function
904 * Do something exciting on successful processing of the form, most likely to show a
905 * confirmation message
907 public function onSuccess() {
908 $out = $this->getOutput();
909 $out->setPageTitle( $this->msg( 'blockipsuccesssub' ) );
910 $out->addWikiMsg( 'blockipsuccesstext', wfEscapeWikiText( $this->target
) );
915 class IPBlockForm
extends SpecialBlock
{}