MediaWiki REL1_31
RenameuserHooks.php
Go to the documentation of this file.
1<?php
2
11 public static function onShowMissingArticle( $article ) {
12 $title = $article->getTitle();
13 $oldUser = User::newFromName( $title->getBaseText() );
14 if ( ( $title->getNamespace() === NS_USER || $title->getNamespace() === NS_USER_TALK ) &&
15 ( $oldUser && $oldUser->isAnon() )
16 ) {
17 // Get the title for the base userpage
18 $page = Title::makeTitle( NS_USER, str_replace( ' ', '_', $title->getBaseText() ) )
19 ->getPrefixedDBkey();
20 $out = $article->getContext()->getOutput();
22 $out,
23 'renameuser',
24 $page,
25 '',
26 [
27 'lim' => 10,
28 'showIfEmpty' => false,
29 'msgKey' => [ 'renameuser-renamed-notice', $title->getBaseText() ]
30 ]
31 );
32 }
33
34 return true;
35 }
36
45 public static function onContributionsToolLinks( $id, $nt, array &$tools, SpecialPage $sp ) {
46 if ( $id && $sp->getUser()->isAllowed( 'renameuser' ) ) {
47 $tools['renameuser'] = $sp->getLinkRenderer()->makeKnownLink(
48 SpecialPage::getTitleFor( 'Renameuser' ),
49 $sp->msg( 'renameuser-linkoncontribs' )->text(),
50 [ 'title' => $sp->msg( 'renameuser-linkoncontribs-text' )->parse() ],
51 [ 'oldusername' => $nt->getText() ]
52 );
53 }
54 }
55
61 public static function onGetLogTypesOnUser( array &$types ) {
62 $types[] = 'renameuser';
63
64 return true;
65 }
66}
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 onShowMissingArticle( $article)
Show a log if the user has been renamed and point to the new username.
static onContributionsToolLinks( $id, $nt, array &$tools, SpecialPage $sp)
Shows link to Special:Renameuser on Special:Contributions/foo.
Parent class for all special pages.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition User.php:591
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition hooks.txt:864
const NS_USER_TALK
Definition Defines.php:77