MediaWiki REL1_40
UserDataAuthenticationRequest.php
Go to the documentation of this file.
1<?php
22namespace MediaWiki\Auth;
23
26use StatusValue;
27use User;
28
38 public $email;
39
41 public $realname;
42
47 public function getFieldInfo() {
48 $config = MediaWikiServices::getInstance()->getMainConfig();
49 $ret = [
50 'email' => [
51 'type' => 'string',
52 'label' => wfMessage( 'authmanager-email-label' ),
53 'help' => wfMessage( 'authmanager-email-help' ),
54 'optional' => true,
55 ],
56 'realname' => [
57 'type' => 'string',
58 'label' => wfMessage( 'authmanager-realname-label' ),
59 'help' => wfMessage( 'authmanager-realname-help' ),
60 'optional' => true,
61 ],
62 ];
63
64 if ( !$config->get( MainConfigNames::EnableEmail ) ) {
65 unset( $ret['email'] );
66 }
67
68 if ( in_array( 'realname', $config->get( MainConfigNames::HiddenPrefs ), true ) ) {
69 unset( $ret['realname'] );
70 }
71
72 return $ret;
73 }
74
83 public function populateUser( $user ) {
84 if ( $this->email !== null && $this->email !== '' ) {
85 if ( !\Sanitizer::validateEmail( $this->email ) ) {
86 return StatusValue::newFatal( 'invalidemailaddress' );
87 }
88 $user->setEmail( $this->email );
89 }
90 if ( $this->realname !== null && $this->realname !== '' ) {
91 $user->setRealName( $this->realname );
92 }
93 return StatusValue::newGood();
94 }
95
96}
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.This will be used in the AuthManager APIs and web UIs to define API input para...
A class containing constants representing the names of configuration variables.
const HiddenPrefs
Name constant for the HiddenPrefs setting, for use with Config::get()
const EnableEmail
Name constant for the EnableEmail setting, for use with Config::get()
Service locator for MediaWiki core services.
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.
internal since 1.36
Definition User.php:71