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(),
149 'type' => 'selectandother',
150 'label-message' => 'ipbreason',
151 'options-message' => 'ipbreason-dropdown',
153 'CreateAccount' => array(
155 'label-message' => 'ipbcreateaccount',
160 if( self
::canBlockEmail( $user ) ) {
161 $a['DisableEmail'] = array(
163 'label-message' => 'ipbemailban',
167 if( $wgBlockAllowsUTEdit ){
168 $a['DisableUTEdit'] = array(
170 'label-message' => 'ipb-disableusertalk',
175 $a['AutoBlock'] = array(
177 'label-message' => 'ipbenableautoblock',
181 # Allow some users to hide name from block log, blocklist and listusers
182 if( $user->isAllowed( 'hideuser' ) ) {
183 $a['HideUser'] = array(
185 'label-message' => 'ipbhidename',
186 'cssclass' => 'mw-block-hideuser',
190 # Watchlist their user page? (Only if user is logged in)
191 if( $user->isLoggedIn() ) {
194 'label-message' => 'ipbwatchuser',
198 $a['HardBlock'] = array(
200 'label-message' => 'ipb-hardblock',
204 # This is basically a copy of the Target field, but the user can't change it, so we
205 # can see if the warnings we maybe showed to the user before still apply
206 $a['PreviousTarget'] = array(
211 # We'll turn this into a checkbox if we need to
212 $a['Confirm'] = array(
215 'label-message' => 'ipb-confirm',
218 $this->maybeAlterFormDefaults( $a );
224 * If the user has already been blocked with similar settings, load that block
225 * and change the defaults for the form fields to match the existing settings.
226 * @param $fields Array HTMLForm descriptor array
227 * @return Bool whether fields were altered (that is, whether the target is
230 protected function maybeAlterFormDefaults( &$fields ){
231 # This will be overwritten by request data
232 $fields['Target']['default'] = (string)$this->target
;
235 $fields['PreviousTarget']['default'] = (string)$this->target
;
237 $block = Block
::newFromTarget( $this->target
);
239 if( $block instanceof Block
&& !$block->mAuto
# The block exists and isn't an autoblock
240 && ( $this->type
!= Block
::TYPE_RANGE
# The block isn't a rangeblock
241 ||
$block->getTarget() == $this->target
) # or if it is, the range is what we're about to block
244 $fields['HardBlock']['default'] = $block->isHardblock();
245 $fields['CreateAccount']['default'] = $block->prevents( 'createaccount' );
246 $fields['AutoBlock']['default'] = $block->isAutoblocking();
248 if( isset( $fields['DisableEmail'] ) ){
249 $fields['DisableEmail']['default'] = $block->prevents( 'sendemail' );
252 if( isset( $fields['HideUser'] ) ){
253 $fields['HideUser']['default'] = $block->mHideName
;
256 if( isset( $fields['DisableUTEdit'] ) ){
257 $fields['DisableUTEdit']['default'] = $block->prevents( 'editownusertalk' );
260 $fields['Reason']['default'] = $block->mReason
;
262 if( $this->getRequest()->wasPosted() ){
263 # Ok, so we got a POST submission asking us to reblock a user. So show the
264 # confirm checkbox; the user will only see it if they haven't previously
265 $fields['Confirm']['type'] = 'check';
267 # We got a target, but it wasn't a POST request, so the user must have gone
268 # to a link like [[Special:Block/User]]. We don't need to show the checkbox
269 # as long as they go ahead and block *that* user
270 $fields['Confirm']['default'] = 1;
273 if( $block->mExpiry
== 'infinity' ) {
274 $fields['Expiry']['default'] = 'indefinite';
276 $fields['Expiry']['default'] = wfTimestamp( TS_RFC2822
, $block->mExpiry
);
279 $this->alreadyBlocked
= true;
280 $this->preErrors
[] = array( 'ipb-needreblock', (string)$block->getTarget() );
283 # We always need confirmation to do HideUser
284 if( $this->requestedHideUser
){
285 $fields['Confirm']['type'] = 'check';
286 unset( $fields['Confirm']['default'] );
287 $this->preErrors
[] = 'ipb-confirmhideuser';
290 # Or if the user is trying to block themselves
291 if( (string)$this->target
=== $this->getUser()->getName() ){
292 $fields['Confirm']['type'] = 'check';
293 unset( $fields['Confirm']['default'] );
294 $this->preErrors
[] = 'ipb-blockingself';
299 * Add header elements like block log entries, etc.
302 protected function preText(){
303 $text = $this->msg( 'blockiptext' )->parse();
305 $otherBlockMessages = array();
306 if( $this->target
!== null ) {
307 # Get other blocks, i.e. from GlobalBlocking or TorBlock extension
308 wfRunHooks( 'OtherBlockLogLink', array( &$otherBlockMessages, $this->target
) );
310 if( count( $otherBlockMessages ) ) {
311 $s = Html
::rawElement(
314 $this->msg( 'ipb-otherblocks-header', count( $otherBlockMessages ) )->parse()
319 foreach( $otherBlockMessages as $link ) {
320 $list .= Html
::rawElement( 'li', array(), $link ) . "\n";
323 $s .= Html
::rawElement(
325 array( 'class' => 'mw-blockip-alreadyblocked' ),
337 * Add footer elements to the form
340 protected function postText(){
341 # Link to the user's contributions, if applicable
342 if( $this->target
instanceof User
){
343 $contribsPage = SpecialPage
::getTitleFor( 'Contributions', $this->target
->getName() );
344 $links[] = Linker
::link(
346 $this->msg( 'ipb-blocklist-contribs', $this->target
->getName() )->escaped()
350 # Link to unblock the specified user, or to a blank unblock form
351 if( $this->target
instanceof User
) {
352 $message = $this->msg( 'ipb-unblock-addr', $this->target
->getName() )->parse();
353 $list = SpecialPage
::getTitleFor( 'Unblock', $this->target
->getName() );
355 $message = $this->msg( 'ipb-unblock' )->parse();
356 $list = SpecialPage
::getTitleFor( 'Unblock' );
358 $links[] = Linker
::linkKnown( $list, $message, array() );
360 # Link to the block list
361 $links[] = Linker
::linkKnown(
362 SpecialPage
::getTitleFor( 'BlockList' ),
363 $this->msg( 'ipb-blocklist' )->escaped()
366 $user = $this->getUser();
368 # Link to edit the block dropdown reasons, if applicable
369 if ( $user->isAllowed( 'editinterface' ) ) {
370 $links[] = Linker
::link(
371 Title
::makeTitle( NS_MEDIAWIKI
, 'Ipbreason-dropdown' ),
372 $this->msg( 'ipb-edit-dropdown' )->escaped(),
374 array( 'action' => 'edit' )
378 $text = Html
::rawElement(
380 array( 'class' => 'mw-ipb-conveniencelinks' ),
381 $this->getLanguage()->pipeList( $links )
384 $userTitle = self
::getTargetUserTitle( $this->target
);
386 # Get relevant extracts from the block and suppression logs, if possible
389 LogEventsList
::showLogExtract(
396 'msgKey' => array( 'blocklog-showlog', $userTitle->getText() ),
397 'showIfEmpty' => false
402 # Add suppression block entries if allowed
403 if( $user->isAllowed( 'suppressionlog' ) ) {
404 LogEventsList
::showLogExtract(
411 'conds' => array( 'log_action' => array( 'block', 'reblock', 'unblock' ) ),
412 'msgKey' => array( 'blocklog-showsuppresslog', $userTitle->getText() ),
413 'showIfEmpty' => false
425 * Get a user page target for things like logs.
426 * This handles account and IP range targets.
427 * @param $target User|string
430 protected static function getTargetUserTitle( $target ) {
431 if( $target instanceof User
) {
432 return $target->getUserPage();
433 } elseif ( IP
::isIPAddress( $target ) ) {
434 return Title
::makeTitleSafe( NS_USER
, $target );
440 * Determine the target of the block, and the type of target
441 * TODO: should be in Block.php?
442 * @param $par String subpage parameter passed to setup, or data value from
444 * @param $request WebRequest optionally try and get data from a request too
445 * @return array( User|string|null, Block::TYPE_ constant|null )
447 public static function getTargetAndType( $par, WebRequest
$request = null ){
454 # The HTMLForm will check wpTarget first and only if it doesn't get
455 # a value use the default, which will be generated from the options
456 # below; so this has to have a higher precedence here than $par, or
457 # we could end up with different values in $this->target and the HTMLForm!
458 if( $request instanceof WebRequest
){
459 $target = $request->getText( 'wpTarget', null );
466 if( $request instanceof WebRequest
){
467 $target = $request->getText( 'ip', null );
472 if( $request instanceof WebRequest
){
473 $target = $request->getText( 'wpBlockAddress', null );
480 list( $target, $type ) = Block
::parseTarget( $target );
482 if( $type !== null ){
483 return array( $target, $type );
487 return array( null, null );
491 * HTMLForm field validation-callback for Target field.
493 * @param $value String
494 * @param $alldata Array
495 * @param $form HTMLForm
498 public static function validateTargetField( $value, $alldata, $form ) {
499 global $wgBlockCIDRLimit;
501 list( $target, $type ) = self
::getTargetAndType( $value );
503 if( $type == Block
::TYPE_USER
){
504 # TODO: why do we not have a User->exists() method?
505 if( !$target->getId() ){
506 return $form->msg( 'nosuchusershort',
507 wfEscapeWikiText( $target->getName() ) );
510 $status = self
::checkUnblockSelf( $target, $form->getUser() );
511 if ( $status !== true ) {
512 return $form->msg( 'badaccess', $status );
515 } elseif( $type == Block
::TYPE_RANGE
){
516 list( $ip, $range ) = explode( '/', $target, 2 );
518 if( ( IP
::isIPv4( $ip ) && $wgBlockCIDRLimit['IPv4'] == 32 )
519 ||
( IP
::isIPv6( $ip ) && $wgBlockCIDRLimit['IPv6'] == 128 ) )
521 # Range block effectively disabled
522 return $form->msg( 'range_block_disabled' );
525 if( ( IP
::isIPv4( $ip ) && $range > 32 )
526 ||
( IP
::isIPv6( $ip ) && $range > 128 ) )
529 return $form->msg( 'ip_range_invalid' );
532 if( IP
::isIPv4( $ip ) && $range < $wgBlockCIDRLimit['IPv4'] ) {
533 return $form->msg( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv4'] );
536 if( IP
::isIPv6( $ip ) && $range < $wgBlockCIDRLimit['IPv6'] ) {
537 return $form->msg( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv6'] );
539 } elseif( $type == Block
::TYPE_IP
){
542 return $form->msg( 'badipaddress' );
549 * Submit callback for an HTMLForm object, will simply pass
551 * @param $form HTMLForm
552 * @return Bool|String
554 public static function processUIForm( array $data, HTMLForm
$form ) {
555 return self
::processForm( $data, $form->getContext() );
559 * Given the form data, actually implement a block
561 * @param $context IContextSource
562 * @return Bool|String
564 public static function processForm( array $data, IContextSource
$context ){
565 global $wgBlockAllowsUTEdit;
567 $performer = $context->getUser();
569 // Handled by field validator callback
570 // self::validateTargetField( $data['Target'] );
572 # This might have been a hidden field or a checkbox, so interesting data
574 $data['Confirm'] = !in_array( $data['Confirm'], array( '', '0', null, false ), true );
576 list( $target, $type ) = self
::getTargetAndType( $data['Target'] );
577 if( $type == Block
::TYPE_USER
){
579 $target = $user->getName();
580 $userId = $user->getId();
582 # Give admins a heads-up before they go and block themselves. Much messier
583 # to do this for IPs, but it's pretty unlikely they'd ever get the 'block'
584 # permission anyway, although the code does allow for it.
585 # Note: Important to use $target instead of $data['Target']
586 # since both $data['PreviousTarget'] and $target are normalized
587 # but $data['target'] gets overriden by (non-normalized) request variable
588 # from previous request.
589 if( $target === $performer->getName() &&
590 ( $data['PreviousTarget'] !== $target ||
!$data['Confirm'] ) )
592 return array( 'ipb-blockingself' );
594 } elseif( $type == Block
::TYPE_RANGE
){
596 } elseif( $type == Block
::TYPE_IP
){
597 $target = $target->getName();
600 # This should have been caught in the form field validation
601 return array( 'badipaddress' );
604 if( ( strlen( $data['Expiry'] ) == 0) ||
( strlen( $data['Expiry'] ) > 50 )
605 ||
!self
::parseExpiryInput( $data['Expiry'] ) )
607 return array( 'ipb_expiry_invalid' );
610 if( !isset( $data['DisableEmail'] ) ){
611 $data['DisableEmail'] = false;
614 # If the user has done the form 'properly', they won't even have been given the
615 # option to suppress-block unless they have the 'hideuser' permission
616 if( !isset( $data['HideUser'] ) ){
617 $data['HideUser'] = false;
620 if( $data['HideUser'] ) {
621 if( !$performer->isAllowed('hideuser') ){
622 # this codepath is unreachable except by a malicious user spoofing forms,
623 # or by race conditions (user has oversight and sysop, loads block form,
624 # and is de-oversighted before submission); so need to fail completely
625 # rather than just silently disable hiding
626 return array( 'badaccess-group0' );
629 # Recheck params here...
630 if( $type != Block
::TYPE_USER
) {
631 $data['HideUser'] = false; # IP users should not be hidden
632 } elseif( !in_array( $data['Expiry'], array( 'infinite', 'infinity', 'indefinite' ) ) ) {
634 return array( 'ipb_expiry_temp' );
635 } elseif( $user->getEditCount() > self
::HIDEUSER_CONTRIBLIMIT
) {
636 # Typically, the user should have a handful of edits.
637 # Disallow hiding users with many edits for performance.
638 return array( 'ipb_hide_invalid' );
639 } elseif( !$data['Confirm'] ){
640 return array( 'ipb-confirmhideuser' );
644 # Create block object.
645 $block = new Block();
646 $block->setTarget( $target );
647 $block->setBlocker( $performer );
648 $block->mReason
= $data['Reason'][0];
649 $block->mExpiry
= self
::parseExpiryInput( $data['Expiry'] );
650 $block->prevents( 'createaccount', $data['CreateAccount'] );
651 $block->prevents( 'editownusertalk', ( !$wgBlockAllowsUTEdit ||
$data['DisableUTEdit'] ) );
652 $block->prevents( 'sendemail', $data['DisableEmail'] );
653 $block->isHardblock( $data['HardBlock'] );
654 $block->isAutoblocking( $data['AutoBlock'] );
655 $block->mHideName
= $data['HideUser'];
657 if( !wfRunHooks( 'BlockIp', array( &$block, &$performer ) ) ) {
658 return array( 'hookaborted' );
661 # Try to insert block. Is there a conflicting block?
662 $status = $block->insert();
664 # Show form unless the user is already aware of this...
665 if( !$data['Confirm'] ||
( array_key_exists( 'PreviousTarget', $data )
666 && $data['PreviousTarget'] !== $target ) )
668 return array( array( 'ipb_already_blocked', $block->getTarget() ) );
669 # Otherwise, try to update the block...
671 # This returns direct blocks before autoblocks/rangeblocks, since we should
672 # be sure the user is blocked by now it should work for our purposes
673 $currentBlock = Block
::newFromTarget( $target );
675 if( $block->equals( $currentBlock ) ) {
676 return array( array( 'ipb_already_blocked', $block->getTarget() ) );
679 # If the name was hidden and the blocking user cannot hide
680 # names, then don't allow any block changes...
681 if( $currentBlock->mHideName
&& !$performer->isAllowed( 'hideuser' ) ) {
682 return array( 'cant-see-hidden-user' );
685 $currentBlock->delete();
686 $status = $block->insert();
687 $logaction = 'reblock';
689 # Unset _deleted fields if requested
690 if( $currentBlock->mHideName
&& !$data['HideUser'] ) {
691 RevisionDeleteUser
::unsuppressUserName( $target, $userId );
694 # If hiding/unhiding a name, this should go in the private logs
695 if( (bool)$currentBlock->mHideName
){
696 $data['HideUser'] = true;
700 $logaction = 'block';
703 wfRunHooks( 'BlockIpComplete', array( $block, $performer ) );
705 # Set *_deleted fields if requested
706 if( $data['HideUser'] ) {
707 RevisionDeleteUser
::suppressUserName( $target, $userId );
710 # Can't watch a rangeblock
711 if( $type != Block
::TYPE_RANGE
&& $data['Watch'] ) {
712 $performer->addWatch( Title
::makeTitle( NS_USER
, $target ) );
715 # Block constructor sanitizes certain block options on insert
716 $data['BlockEmail'] = $block->prevents( 'sendemail' );
717 $data['AutoBlock'] = $block->isAutoblocking();
719 # Prepare log parameters
720 $logParams = array();
721 $logParams[] = $data['Expiry'];
722 $logParams[] = self
::blockLogFlags( $data, $type );
724 # Make log entry, if the name is hidden, put it in the oversight log
725 $log_type = $data['HideUser'] ?
'suppress' : 'block';
726 $log = new LogPage( $log_type );
727 $log_id = $log->addEntry(
729 Title
::makeTitle( NS_USER
, $target ),
733 # Relate log ID to block IDs (bug 25763)
734 $blockIds = array_merge( array( $status['id'] ), $status['autoIds'] );
735 $log->addRelations( 'ipb_id', $blockIds, $log_id );
742 * Get an array of suggested block durations from MediaWiki:Ipboptions
743 * @todo FIXME: This uses a rather odd syntax for the options, should it be converted
744 * to the standard "**<duration>|<displayname>" format?
745 * @param $lang Language|null the language to get the durations in, or null to use
746 * the wiki's content language
749 public static function getSuggestedDurations( $lang = null ){
751 $msg = $lang === null
752 ?
wfMessage( 'ipboptions' )->inContentLanguage()->text()
753 : wfMessage( 'ipboptions' )->inLanguage( $lang )->text();
759 foreach( explode( ',', $msg ) as $option ) {
760 if( strpos( $option, ':' ) === false ){
761 $option = "$option:$option";
764 list( $show, $value ) = explode( ':', $option );
765 $a[htmlspecialchars( $show )] = htmlspecialchars( $value );
772 * Convert a submitted expiry time, which may be relative ("2 weeks", etc) or absolute
773 * ("24 May 2034", etc), into an absolute timestamp we can put into the database.
774 * @param $expiry String: whatever was typed into the form
775 * @return String: timestamp or "infinity" string for the DB implementation
777 public static function parseExpiryInput( $expiry ) {
779 if( $infinity == null ){
780 $infinity = wfGetDB( DB_SLAVE
)->getInfinity();
783 if ( $expiry == 'infinite' ||
$expiry == 'indefinite' ) {
786 $expiry = strtotime( $expiry );
788 if ( $expiry < 0 ||
$expiry === false ) {
792 $expiry = wfTimestamp( TS_MW
, $expiry );
799 * Can we do an email block?
800 * @param $user User: the sysop wanting to make a block
803 public static function canBlockEmail( $user ) {
804 global $wgEnableUserEmail, $wgSysopEmailBans;
806 return ( $wgEnableUserEmail && $wgSysopEmailBans && $user->isAllowed( 'blockemail' ) );
810 * bug 15810: blocked admins should not be able to block/unblock
811 * others, and probably shouldn't be able to unblock themselves
813 * @param $user User|Int|String
814 * @param $performer User user doing the request
815 * @return Bool|String true or error message key
817 public static function checkUnblockSelf( $user, User
$performer ) {
818 if ( is_int( $user ) ) {
819 $user = User
::newFromId( $user );
820 } elseif ( is_string( $user ) ) {
821 $user = User
::newFromName( $user );
824 if( $performer->isBlocked() ){
825 if( $user instanceof User
&& $user->getId() == $performer->getId() ) {
826 # User is trying to unblock themselves
827 if ( $performer->isAllowed( 'unblockself' ) ) {
829 # User blocked themselves and is now trying to reverse it
830 } elseif ( $performer->blockedBy() === $performer->getName() ) {
833 return 'ipbnounblockself';
836 # User is trying to block/unblock someone else
845 * Return a comma-delimited list of "flags" to be passed to the log
846 * reader for this block, to provide more information in the logs
847 * @param $data Array from HTMLForm data
848 * @param $type Block::TYPE_ constant (USER, RANGE, or IP)
851 protected static function blockLogFlags( array $data, $type ) {
852 global $wgBlockAllowsUTEdit;
855 # when blocking a user the option 'anononly' is not available/has no effect -> do not write this into log
856 if( !$data['HardBlock'] && $type != Block
::TYPE_USER
){
857 // For grepping: message block-log-flags-anononly
858 $flags[] = 'anononly';
861 if( $data['CreateAccount'] ){
862 // For grepping: message block-log-flags-nocreate
863 $flags[] = 'nocreate';
866 # Same as anononly, this is not displayed when blocking an IP address
867 if( !$data['AutoBlock'] && $type == Block
::TYPE_USER
){
868 // For grepping: message block-log-flags-noautoblock
869 $flags[] = 'noautoblock';
872 if( $data['DisableEmail'] ){
873 // For grepping: message block-log-flags-noemail
874 $flags[] = 'noemail';
877 if( $wgBlockAllowsUTEdit && $data['DisableUTEdit'] ){
878 // For grepping: message block-log-flags-nousertalk
879 $flags[] = 'nousertalk';
882 if( $data['HideUser'] ){
883 // For grepping: message block-log-flags-hiddenname
884 $flags[] = 'hiddenname';
887 return implode( ',', $flags );
891 * Process the form on POST submission.
893 * @return Bool|Array true for success, false for didn't-try, array of errors on failure
895 public function onSubmit( array $data ) {
896 // This isn't used since we need that HTMLForm that's passed in the
897 // second parameter. See alterForm for the real function
901 * Do something exciting on successful processing of the form, most likely to show a
902 * confirmation message
904 public function onSuccess() {
905 $out = $this->getOutput();
906 $out->setPageTitle( $this->msg( 'blockipsuccesssub' ) );
907 $out->addWikiMsg( 'blockipsuccesstext', $this->target
);
912 class IPBlockForm
extends SpecialBlock
{}