MediaWiki master
SpecialMypage.php
Go to the documentation of this file.
1<?php
9
13
20
21 public function __construct( private readonly TempUserConfig $tempUserConfig ) {
22 parent::__construct( 'Mypage' );
23 }
24
26 public function execute( $subpage ) {
27 // Redirect to login for anon users when temp accounts are enabled.
28 if ( $this->tempUserConfig->isEnabled() && $this->getUser()->isAnon() ) {
29 $this->requireLogin();
30 }
31 parent::execute( $subpage );
32 }
33
35 public function getRedirect( $subpage ) {
36 if ( $this->tempUserConfig->isEnabled() && $this->getUser()->isAnon() ) {
37 return false;
38 }
39
40 if ( $subpage === null || $subpage === '' ) {
41 return Title::makeTitle( NS_USER, $this->getUser()->getName() );
42 }
43
44 return Title::makeTitle( NS_USER, $this->getUser()->getName() . '/' . $subpage );
45 }
46
53 public function personallyIdentifiableTarget() {
54 return true;
55 }
56}
57
62class_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(private readonly 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.