From a1789ddde42033f1b05cc4929491214ee6e79383 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 17 Dec 2015 09:15:42 +0100 Subject: Update to MediaWiki 1.26.0 --- includes/htmlform/HTMLUserTextField.php | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 includes/htmlform/HTMLUserTextField.php (limited to 'includes/htmlform/HTMLUserTextField.php') diff --git a/includes/htmlform/HTMLUserTextField.php b/includes/htmlform/HTMLUserTextField.php new file mode 100644 index 00000000..9617c0a3 --- /dev/null +++ b/includes/htmlform/HTMLUserTextField.php @@ -0,0 +1,47 @@ + false, + 'ipallowed' => false, + ); + + parent::__construct( $params ); + } + + public function validate( $value, $alldata ) { + // check, if a user exists with the given username + $user = User::newFromName( $value, false ); + + if ( !$user ) { + return $this->msg( 'htmlform-user-not-valid', $value )->parse(); + } elseif ( + ( $this->mParams['exists'] && $user->getId() === 0 ) && + !( $this->mParams['ipallowed'] && User::isIP( $value ) ) + ) { + return $this->msg( 'htmlform-user-not-exists', $user->getName() )->parse(); + } + + return parent::validate( $value, $alldata ); + } + + protected function getInputWidget( $params ) { + $this->mParent->getOutput()->addModules( 'mediawiki.widgets.UserInputWidget' ); + + return new UserInputWidget( $params ); + } +} -- cgit v1.2.3-54-g00ecf