MediaWiki  1.34.0
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 }
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:792
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:515
RenameuserHooks\onShowMissingArticle
static onShowMissingArticle(Article $article)
Show a log if the user has been renamed and point to the new username.
Definition: RenameuserHooks.php:10
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Definition: SpecialPage.php:83
Article\getTitle
getTitle()
Get the title object of the article.
Definition: Article.php:221
RenameuserHooks\onContributionsToolLinks
static onContributionsToolLinks( $id, Title $nt, array &$tools, SpecialPage $sp)
Shows link to Special:Renameuser on Special:Contributions/foo.
Definition: RenameuserHooks.php:42
Article\getContext
getContext()
Gets the context this Article is executed in.
Definition: Article.php:2267
$title
$title
Definition: testCompression.php:34
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:729
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:586
LogEventsList\showLogExtract
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Definition: LogEventsList.php:624
NS_USER_TALK
const NS_USER_TALK
Definition: Defines.php:63
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:37
RenameuserHooks
Definition: RenameuserHooks.php:3
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:904
Title
Represents a title within MediaWiki.
Definition: Title.php:42
RenameuserHooks\onGetLogTypesOnUser
static onGetLogTypesOnUser(array &$types)
So users can just type in a username for target and it'll work.
Definition: RenameuserHooks.php:59
NS_USER
const NS_USER
Definition: Defines.php:62
Article
Class for viewing MediaWiki article and history.
Definition: Article.php:38
Title\getText
getText()
Get the text form (spaces not underscores) of the main part.
Definition: Title.php:995