MediaWiki  1.30.0
Renameuser.hooks.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 
46  public static function onContributionsToolLinks( $id, $nt, &$tools ) {
48 
49  if ( $id && $wgUser->isAllowed( 'renameuser' ) ) {
50  $tools[] = Linker::link(
51  SpecialPage::getTitleFor( 'Renameuser' ),
52  wfMessage( 'renameuser-linkoncontribs' )->escaped(),
53  [ 'title' => wfMessage( 'renameuser-linkoncontribs-text' )->parse() ],
54  [ 'oldusername' => $nt->getText() ]
55  );
56  }
57 
58  return true;
59  }
60 
66  public static function onGetLogTypesOnUser( array &$types ) {
67  $types[] = 'renameuser';
68 
69  return true;
70  }
71 }
$wgUser
$wgUser
Definition: Setup.php:809
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:550
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:82
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:932
RenameuserHooks::onContributionsToolLinks
static onContributionsToolLinks( $id, $nt, &$tools)
Shows link to Special:Renameuser on Special:Contributions/foo.
Definition: Renameuser.hooks.php:46
$article
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
Definition: hooks.txt:77
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:529
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
LogEventsList\showLogExtract
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Definition: LogEventsList.php:594
NS_USER_TALK
const NS_USER_TALK
Definition: Defines.php:68
Linker\link
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
Definition: Linker.php:107
RenameuserHooks
Definition: Renameuser.hooks.php:3
RenameuserHooks::onGetLogTypesOnUser
static onGetLogTypesOnUser(array &$types)
So users can just type in a username for target and it'll work.
Definition: Renameuser.hooks.php:66
NS_USER
const NS_USER
Definition: Defines.php:67
wfMessage
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
RenameuserHooks::onShowMissingArticle
static onShowMissingArticle( $article)
Show a log if the user has been renamed and point to the new username.
Definition: Renameuser.hooks.php:11
array
the array() calling protocol came about after MediaWiki 1.4rc1.
$out
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:781