parent::__construct( 'Block', 'block' );
}
+ public function doesWrites() {
+ return true;
+ }
+
/**
* Checks that the user can unblock themselves if they are trying to do so
*
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 ) {
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;
}
$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'] );
$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';
}