MediaWiki master
SpecialMypage.php
Go to the documentation of this file.
1<?php
9
13
20
21 private TempUserConfig $tempUserConfig;
22
23 public function __construct( TempUserConfig $tempUserConfig ) {
24 parent::__construct( 'Mypage' );
25
26 $this->tempUserConfig = $tempUserConfig;
27 }
28
30 public function execute( $subpage ) {
31 // Redirect to login for anon users when temp accounts are enabled.
32 if ( $this->tempUserConfig->isEnabled() && $this->getUser()->isAnon() ) {
33 $this->requireLogin();
34 }
35 parent::execute( $subpage );
36 }
37
39 public function getRedirect( $subpage ) {
40 if ( $this->tempUserConfig->isEnabled() && $this->getUser()->isAnon() ) {
41 return false;
42 }
43
44 if ( $subpage === null || $subpage === '' ) {
45 return Title::makeTitle( NS_USER, $this->getUser()->getName() );
46 }
47
48 return Title::makeTitle( NS_USER, $this->getUser()->getName() . '/' . $subpage );
49 }
50
57 public function personallyIdentifiableTarget() {
58 return true;
59 }
60}
61
66class_alias( SpecialMypage::class, 'SpecialMypage' );
const NS_USER
Definition Defines.php:53
makeTitle( $linkId)
Convert a link ID to a Title.to override Title
Helper for any RedirectSpecialPage which redirects the user to a particular article (as opposed to us...
getUser()
Shortcut to get the User executing this instance.
requireLogin( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin')
If the user is not logged in, throws UserNotLoggedIn error.
getName()
Get the canonical, unlocalized name of this special page without namespace.
Redirect to the current user's user page.
getRedirect( $subpage)
If the special page is a redirect, then get the Title object it redirects to.False otherwise....
__construct(TempUserConfig $tempUserConfig)
personallyIdentifiableTarget()
Target identifies a specific User.
Represents a title within MediaWiki.
Definition Title.php:69
Interface for temporary user creation config and name matching.