39 'usemodwiki-ipallowed' =>
false,
45 'excludenamed' =>
false,
46 'excludetemp' =>
false,
50 parent::__construct( $params );
59 if ( $value ===
'' ) {
60 return parent::validate( $value, $alldata );
67 if ( $this->mParams[
'exists'] && !(
68 $user->isRegistered() &&
70 !( $user->isHidden() && !( $this->mParent && $this->mParent->getUser()->isAllowed(
'hideuser' ) ) )
76 $excludeNamed = $this->mParams[
'excludenamed'] ??
null;
77 $excludeTemp = $this->mParams[
'excludetemp'] ??
null;
78 if ( ( $excludeTemp && $user->isTemp() ) || ( $excludeNamed && $user->isNamed() ) ) {
85 if ( $this->mParams[
'external'] && ExternalUserNames::isExternal( $value ) ) {
89 if ( $this->mParams[
'ipallowed'] ) {
90 $b = IPUtils::RE_IP_BYTE;
91 if ( IPUtils::isValid( $value ) ) {
93 } elseif ( $this->mParams[
'usemodwiki-ipallowed'] && preg_match(
"/^$b\.$b\.$b\.xxx$/", $value ) ) {
98 if ( $this->mParams[
'iprange'] ) {
100 if ( $rangeError ===
true ) {
102 } elseif ( $rangeError !==
false ) {
111 return parent::validate( $value, $alldata );
119 $cidrIPRanges = $this->mParams[
'iprangelimits'];
121 if ( !IPUtils::isValidRange( $value ) ) {
125 [ $ip, $range ] = explode(
'/', $value, 2 );
128 ( IPUtils::isIPv4( $ip ) && $cidrIPRanges[
'IPv4'] == 32 ) ||
129 ( IPUtils::isIPv6( $ip ) && $cidrIPRanges[
'IPv6'] == 128 )
132 return $this->
msg(
'ip_range_toolow' );
136 ( IPUtils::isIPv4( $ip ) && $range > 32 ) ||
137 ( IPUtils::isIPv6( $ip ) && $range > 128 )
140 return $this->
msg(
'ip_range_invalid' );
143 if ( IPUtils::isIPv4( $ip ) && $range < $cidrIPRanges[
'IPv4'] ) {
144 return $this->
msg(
'ip_range_exceeded', $cidrIPRanges[
'IPv4'] );
147 if ( IPUtils::isIPv6( $ip ) && $range < $cidrIPRanges[
'IPv6'] ) {
148 return $this->
msg(
'ip_range_exceeded', $cidrIPRanges[
'IPv6'] );
156 if ( isset( $this->mParams[
'excludenamed'] ) ) {
157 $params[
'excludenamed'] = $this->mParams[
'excludenamed'];
160 if ( isset( $this->mParams[
'excludetemp'] ) ) {
161 $params[
'excludetemp'] = $this->mParams[
'excludetemp'];
174 return [
'mediawiki.widgets.UserInputWidget' ];
180 $this->mParent->getOutput()->addModules(
'mediawiki.userSuggest' );
181 $this->mClass .=
' mw-autocomplete-user';
184 return parent::getInputHTML( $value );
189class_alias( HTMLUserTextField::class,
'HTMLUserTextField' );
wfEscapeWikiText( $input)
Escapes the given text so that it may be output using addWikiText() without any linking,...
wfArrayPlus2d(array $baseArray, array $newValues)
Merges two (possibly) 2 dimensional arrays into the target array ($baseArray).
Implements a text input field for user names.
validate( $value, $alldata)
Override this function to add specific validation checks on the field input.Don't forget to call pare...
shouldInfuseOOUI()
Whether the field should be automatically infused.Note that all OOUI HTMLForm fields are infusable (y...
getOOUIModules()
Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to...
getInputWidget( $params)
to overrideWidget