MediaWiki REL1_37
UserDataAuthenticationRequest.php
Go to the documentation of this file.
1<?php
22namespace MediaWiki\Auth;
23
25use StatusValue;
26use User;
27
37 public $email;
38
40 public $realname;
41
46 public function getFieldInfo() {
47 $config = MediaWikiServices::getInstance()->getMainConfig();
48 $ret = [
49 'email' => [
50 'type' => 'string',
51 'label' => wfMessage( 'authmanager-email-label' ),
52 'help' => wfMessage( 'authmanager-email-help' ),
53 'optional' => true,
54 ],
55 'realname' => [
56 'type' => 'string',
57 'label' => wfMessage( 'authmanager-realname-label' ),
58 'help' => wfMessage( 'authmanager-realname-help' ),
59 'optional' => true,
60 ],
61 ];
62
63 if ( !$config->get( 'EnableEmail' ) ) {
64 unset( $ret['email'] );
65 }
66
67 if ( in_array( 'realname', $config->get( 'HiddenPrefs' ), true ) ) {
68 unset( $ret['realname'] );
69 }
70
71 return $ret;
72 }
73
82 public function populateUser( $user ) {
83 if ( $this->email !== null && $this->email !== '' ) {
84 if ( !\Sanitizer::validateEmail( $this->email ) ) {
85 return StatusValue::newFatal( 'invalidemailaddress' );
86 }
87 $user->setEmail( $this->email );
88 }
89 if ( $this->realname !== null && $this->realname !== '' ) {
90 $user->setRealName( $this->realname );
91 }
92 return StatusValue::newGood();
93 }
94
95}
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
This is a value object for authentication requests.
This represents additional user data requested on the account creation form.
getFieldInfo()
Fetch input field info.The field info is an associative array mapping field names to info arrays....
MediaWikiServices is the service locator for the application scope of MediaWiki.
static getInstance()
Returns the global default instance of the top level service locator.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:69