MediaWiki  1.28.3
UserDataAuthenticationRequest.php
Go to the documentation of this file.
1 <?php
22 namespace MediaWiki\Auth;
23 
25 use User;
26 
35  public $email;
36 
38  public $realname;
39 
40  public function getFieldInfo() {
41  $config = \ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
42  $ret = [
43  'email' => [
44  'type' => 'string',
45  'label' => wfMessage( 'authmanager-email-label' ),
46  'help' => wfMessage( 'authmanager-email-help' ),
47  'optional' => true,
48  ],
49  'realname' => [
50  'type' => 'string',
51  'label' => wfMessage( 'authmanager-realname-label' ),
52  'help' => wfMessage( 'authmanager-realname-help' ),
53  'optional' => true,
54  ],
55  ];
56 
57  if ( !$config->get( 'EnableEmail' ) ) {
58  unset( $ret['email'] );
59  }
60 
61  if ( in_array( 'realname', $config->get( 'HiddenPrefs' ), true ) ) {
62  unset( $ret['realname'] );
63  }
64 
65  return $ret;
66  }
67 
75  public function populateUser( $user ) {
76  if ( $this->email !== null && $this->email !== '' ) {
77  if ( !\Sanitizer::validateEmail( $this->email ) ) {
78  return StatusValue::newFatal( 'invalidemailaddress' );
79  }
80  $user->setEmail( $this->email );
81  }
82  if ( $this->realname !== null && $this->realname !== '' ) {
83  $user->setRealName( $this->realname );
84  }
85  return StatusValue::newGood();
86  }
87 
88 }
Config $config
Definition: MediaWiki.php:38
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition: hooks.txt:1940
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
static newFatal($message)
Factory function for fatal errors.
Definition: StatusValue.php:63
get($name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition: hooks.txt:1940
This represents additional user data requested on the account creation form.
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock()-offset Set to overwrite offset parameter in $wgRequest set to ''to unsetoffset-wrap String Wrap the message in html(usually something like"&lt
static newGood($value=null)
Factory function for good results.
Definition: StatusValue.php:76
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
Definition: hooks.txt:246
static getDefaultInstance()
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
static validateEmail($addr)
Does a string look like an e-mail address?
Definition: Sanitizer.php:1942
This is a value object for authentication requests.