40 parent::__construct( $params );
45 if ( $value ===
null ) {
50 if ( $value ===
'' ) {
51 return parent::validate( $value, $alldata );
55 $user = MediaWikiServices::getInstance()->getUserFactory()->newFromName( $value );
58 if ( $this->mParams[
'exists'] && !(
59 $user->isRegistered() &&
61 !( $user->isHidden() && !( $this->mParent && $this->mParent->getUser()->isAllowed(
'hideuser' ) ) )
63 return $this->
msg(
'htmlform-user-not-exists', $user->getName() );
69 if ( $this->mParams[
'external'] && ExternalUserNames::isExternal( $value ) ) {
73 if ( $this->mParams[
'ipallowed'] && IPUtils::isValid( $value ) ) {
77 if ( $this->mParams[
'iprange'] ) {
79 if ( $rangeError ===
true ) {
81 } elseif ( $rangeError !==
false ) {
86 return $this->
msg(
'htmlform-user-not-valid', $value );
90 return parent::validate( $value, $alldata );
94 $cidrIPRanges = $this->mParams[
'iprangelimits'];
96 if ( !IPUtils::isValidRange( $value ) ) {
100 [ $ip, $range ] = explode(
'/', $value, 2 );
103 ( IPUtils::isIPv4( $ip ) && $cidrIPRanges[
'IPv4'] == 32 ) ||
104 ( IPUtils::isIPv6( $ip ) && $cidrIPRanges[
'IPv6'] == 128 )
107 return $this->
msg(
'ip_range_toolow' );
111 ( IPUtils::isIPv4( $ip ) && $range > 32 ) ||
112 ( IPUtils::isIPv6( $ip ) && $range > 128 )
115 return $this->
msg(
'ip_range_invalid' );
118 if ( IPUtils::isIPv4( $ip ) && $range < $cidrIPRanges[
'IPv4'] ) {
119 return $this->
msg(
'ip_range_exceeded', $cidrIPRanges[
'IPv4'] );
122 if ( IPUtils::isIPv6( $ip ) && $range < $cidrIPRanges[
'IPv6'] ) {
123 return $this->
msg(
'ip_range_exceeded', $cidrIPRanges[
'IPv6'] );
138 return [
'mediawiki.widgets.UserInputWidget' ];
143 $this->mParent->getOutput()->addModules(
'mediawiki.userSuggest' );
144 $this->mClass .=
' mw-autocomplete-user';
147 return parent::getInputHTML( $value );
wfArrayPlus2d(array $baseArray, array $newValues)
Merges two (possibly) 2 dimensional arrays into the target array ($baseArray).
Implements a text input field for user names.
shouldInfuseOOUI()
Whether the field should be automatically infused.
getOOUIModules()
Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to...
validate( $value, $alldata)
Override this function to add specific validation checks on the field input.