MediaWiki REL1_34
RenameuserHooks.php
Go to the documentation of this file.
1<?php
2
10 public static function onShowMissingArticle( Article $article ) {
11 $title = $article->getTitle();
12 $oldUser = User::newFromName( $title->getBaseText() );
13 if ( ( $title->getNamespace() === NS_USER || $title->getNamespace() === NS_USER_TALK ) &&
14 ( $oldUser && $oldUser->isAnon() )
15 ) {
16 // Get the title for the base userpage
17 $page = Title::makeTitle( NS_USER, str_replace( ' ', '_', $title->getBaseText() ) )
18 ->getPrefixedDBkey();
19 $out = $article->getContext()->getOutput();
21 $out,
22 'renameuser',
23 $page,
24 '',
25 [
26 'lim' => 10,
27 'showIfEmpty' => false,
28 'msgKey' => [ 'renameuser-renamed-notice', $title->getBaseText() ]
29 ]
30 );
31 }
32 }
33
42 public static function onContributionsToolLinks(
43 $id, Title $nt, array &$tools, SpecialPage $sp
44 ) {
45 if ( $id && $sp->getUser()->isAllowed( 'renameuser' ) ) {
46 $tools['renameuser'] = $sp->getLinkRenderer()->makeKnownLink(
47 SpecialPage::getTitleFor( 'Renameuser' ),
48 $sp->msg( 'renameuser-linkoncontribs', $nt->getText() )->text(),
49 [ 'title' => $sp->msg( 'renameuser-linkoncontribs-text', $nt->getText() )->parse() ],
50 [ 'oldusername' => $nt->getText() ]
51 );
52 }
53 }
54
59 public static function onGetLogTypesOnUser( array &$types ) {
60 $types[] = 'renameuser';
61 }
62}
Class for viewing MediaWiki article and history.
Definition Article.php:38
getContext()
Gets the context this Article is executed in.
Definition Article.php:2267
getTitle()
Get the title object of the article.
Definition Article.php:221
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
static onGetLogTypesOnUser(array &$types)
So users can just type in a username for target and it'll work.
static onContributionsToolLinks( $id, Title $nt, array &$tools, SpecialPage $sp)
Shows link to Special:Renameuser on Special:Contributions/foo.
static onShowMissingArticle(Article $article)
Show a log if the user has been renamed and point to the new username.
Parent class for all special pages.
getUser()
Shortcut to get the User executing this instance.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Represents a title within MediaWiki.
Definition Title.php:42
getText()
Get the text form (spaces not underscores) of the main part.
Definition Title.php:995
const NS_USER
Definition Defines.php:71
const NS_USER_TALK
Definition Defines.php:72