Make mediawiki.special.pageLanguage work again
[lhc/web/wiklou.git] / includes / specials / SpecialBlock.php
index cd6cc76..d198ea1 100644 (file)
@@ -51,6 +51,10 @@ class SpecialBlock extends FormSpecialPage {
                parent::__construct( 'Block', 'block' );
        }
 
+       public function doesWrites() {
+               return true;
+       }
+
        /**
         * Checks that the user can unblock themselves if they are trying to do so
         *
@@ -321,7 +325,8 @@ class SpecialBlock extends FormSpecialPage {
        protected function preText() {
                $this->getOutput()->addModules( array( 'mediawiki.special.block', 'mediawiki.userSuggest' ) );
 
-               $text = $this->msg( 'blockiptext' )->parse();
+               $blockCIDRLimit = $this->getConfig()->get( 'BlockCIDRLimit' );
+               $text = $this->msg( 'blockiptext', $blockCIDRLimit['IPv4'], $blockCIDRLimit['IPv6'] )->parse();
 
                $otherBlockMessages = array();
                if ( $this->target !== null ) {
@@ -361,6 +366,8 @@ class SpecialBlock extends FormSpecialPage {
        protected function postText() {
                $links = array();
 
+               $this->getOutput()->addModuleStyles( 'mediawiki.special' );
+
                # Link to the user's contributions, if applicable
                if ( $this->target instanceof User ) {
                        $contribsPage = SpecialPage::getTitleFor( 'Contributions', $this->target->getName() );
@@ -643,12 +650,25 @@ class SpecialBlock extends FormSpecialPage {
                        return array( 'badipaddress' );
                }
 
-               if ( ( strlen( $data['Expiry'] ) == 0 ) || ( strlen( $data['Expiry'] ) > 50 )
-                       || !self::parseExpiryInput( $data['Expiry'] )
+               $expiryTime = self::parseExpiryInput( $data['Expiry'] );
+
+               if (
+                       // an expiry time is needed
+                       ( strlen( $data['Expiry'] ) == 0 ) ||
+                       // can't be a larger string as 50 (it should be a time format in any way)
+                       ( strlen( $data['Expiry'] ) > 50 ) ||
+                       // check, if the time could be parsed
+                       !$expiryTime
                ) {
                        return array( 'ipb_expiry_invalid' );
                }
 
+               // an expiry time should be in the future, not in the
+               // past (wouldn't make any sense) - bug T123069
+               if ( $expiryTime < wfTimestampNow() ) {
+                       return array( 'ipb_expiry_old' );
+               }
+
                if ( !isset( $data['DisableEmail'] ) ) {
                        $data['DisableEmail'] = false;
                }
@@ -692,7 +712,7 @@ class SpecialBlock extends FormSpecialPage {
                $block->setBlocker( $performer );
                # Truncate reason for whole multibyte characters
                $block->mReason = $wgContLang->truncate( $data['Reason'][0], 255 );
-               $block->mExpiry = self::parseExpiryInput( $data['Expiry'] );
+               $block->mExpiry = $expiryTime;
                $block->prevents( 'createaccount', $data['CreateAccount'] );
                $block->prevents( 'editownusertalk', ( !$wgBlockAllowsUTEdit || $data['DisableUTEdit'] ) );
                $block->prevents( 'sendemail', $data['DisableEmail'] );
@@ -969,6 +989,24 @@ class SpecialBlock extends FormSpecialPage {
                $out->addWikiMsg( 'blockipsuccesstext', wfEscapeWikiText( $this->target ) );
        }
 
+       /**
+        * Return an array of subpages beginning with $search that this special page will accept.
+        *
+        * @param string $search Prefix to search for
+        * @param int $limit Maximum number of results to return (usually 10)
+        * @param int $offset Number of results to skip (usually 0)
+        * @return string[] Matching subpages
+        */
+       public function prefixSearchSubpages( $search, $limit, $offset ) {
+               $user = User::newFromName( $search );
+               if ( !$user ) {
+                       // No prefix suggestion for invalid user
+                       return array();
+               }
+               // Autocomplete subpage as user list - public to allow caching
+               return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );
+       }
+
        protected function getGroupName() {
                return 'users';
        }