36 parent::__construct( $params );
41 if ( $value ===
null ) {
46 if ( $value ===
'' ) {
47 return parent::validate( $value, $alldata );
54 if ( $this->mParams[
'exists'] && !(
55 $user->isRegistered() &&
57 !( $user->isHidden() && !( $this->mParent && $this->mParent->getUser()->isAllowed(
'hideuser' ) ) )
59 return $this->
msg(
'htmlform-user-not-exists', $user->getName() );
65 if ( $this->mParams[
'ipallowed'] && IPUtils::isValid( $value ) ) {
69 if ( $this->mParams[
'iprange'] ) {
71 if ( $rangeError ===
true ) {
73 } elseif ( $rangeError !==
false ) {
78 return $this->
msg(
'htmlform-user-not-valid', $value );
82 return parent::validate( $value, $alldata );
86 $cidrIPRanges = $this->mParams[
'iprangelimits'];
88 if ( !IPUtils::isValidRange( $value ) ) {
92 [ $ip, $range ] = explode(
'/', $value, 2 );
95 ( IPUtils::isIPv4( $ip ) && $cidrIPRanges[
'IPv4'] == 32 ) ||
96 ( IPUtils::isIPv6( $ip ) && $cidrIPRanges[
'IPv6'] == 128 )
99 return $this->
msg(
'ip_range_toolow' );
103 ( IPUtils::isIPv4( $ip ) && $range > 32 ) ||
104 ( IPUtils::isIPv6( $ip ) && $range > 128 )
107 return $this->
msg(
'ip_range_invalid' );
110 if ( IPUtils::isIPv4( $ip ) && $range < $cidrIPRanges[
'IPv4'] ) {
111 return $this->
msg(
'ip_range_exceeded', $cidrIPRanges[
'IPv4'] );
114 if ( IPUtils::isIPv6( $ip ) && $range < $cidrIPRanges[
'IPv6'] ) {
115 return $this->
msg(
'ip_range_exceeded', $cidrIPRanges[
'IPv6'] );
130 return [
'mediawiki.widgets.UserInputWidget' ];
135 $this->mParent->getOutput()->addModules(
'mediawiki.userSuggest' );
136 $this->mClass .=
' mw-autocomplete-user';
139 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.
static newFromName( $name, $validate='valid')