Merge "Add mediawiki.userSuggest to Special:Block/Unblock/BlockList"
[lhc/web/wiklou.git] / includes / specials / SpecialBlock.php
index f8b2e8d..a4269d1 100644 (file)
@@ -98,6 +98,7 @@ class SpecialBlock extends FormSpecialPage {
                $form->setWrapperLegendMsg( 'blockip-legend' );
                $form->setHeaderText( '' );
                $form->setSubmitCallback( array( __CLASS__, 'processUIForm' ) );
+               $form->setSubmitDestructive();
 
                $msg = $this->alreadyBlocked ? 'ipb-change-block' : 'ipbsubmit';
                $form->setSubmitTextMsg( $msg );
@@ -135,6 +136,7 @@ class SpecialBlock extends FormSpecialPage {
                                'autofocus' => true,
                                'required' => true,
                                'validation-callback' => array( __CLASS__, 'validateTargetField' ),
+                               'cssclass' => 'mw-autocomplete-user', // used by mediawiki.userSuggest
                        ),
                        'Expiry' => array(
                                'type' => !count( $suggestedDurations ) ? 'text' : 'selectorother',
@@ -146,6 +148,7 @@ class SpecialBlock extends FormSpecialPage {
                        ),
                        'Reason' => array(
                                'type' => 'selectandother',
+                               'maxlength' => 255,
                                'label-message' => 'ipbreason',
                                'options-message' => 'ipbreason-dropdown',
                        ),
@@ -307,7 +310,7 @@ class SpecialBlock extends FormSpecialPage {
         * @return string
         */
        protected function preText() {
-               $this->getOutput()->addModules( 'mediawiki.special.block' );
+               $this->getOutput()->addModules( array( 'mediawiki.special.block', 'mediawiki.userSuggest' ) );
 
                $text = $this->msg( 'blockiptext' )->parse();
 
@@ -600,7 +603,7 @@ class SpecialBlock extends FormSpecialPage {
         * @return bool|string
         */
        public static function processForm( array $data, IContextSource $context ) {
-               global $wgBlockAllowsUTEdit, $wgHideUserContribLimit;
+               global $wgBlockAllowsUTEdit, $wgHideUserContribLimit, $wgContLang;
 
                $performer = $context->getUser();
 
@@ -687,7 +690,8 @@ class SpecialBlock extends FormSpecialPage {
                $block = new Block();
                $block->setTarget( $target );
                $block->setBlocker( $performer );
-               $block->mReason = $data['Reason'][0];
+               # Truncate reason for whole multibyte characters
+               $block->mReason = $wgContLang->truncate( $data['Reason'][0], 255 );
                $block->mExpiry = self::parseExpiryInput( $data['Expiry'] );
                $block->prevents( 'createaccount', $data['CreateAccount'] );
                $block->prevents( 'editownusertalk', ( !$wgBlockAllowsUTEdit || $data['DisableUTEdit'] ) );