[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/extensions/Renameuser/ -> Renameuser.hooks.php (source)

   1  <?php
   2  
   3  class RenameuserHooks {
   4      /**
   5       * Show a log if the user has been renamed and point to the new username.
   6       * Don't show the log if the $oldUserName exists as a user.
   7       *
   8       * @param $article Article
   9       * @return bool
  10       */
  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 ) && ($oldUser && $oldUser->isAnon() )) {
  15              // Get the title for the base userpage
  16              $page = Title::makeTitle( NS_USER, str_replace( ' ', '_', $title->getBaseText() ) )->getPrefixedDBkey();
  17              $out = $article->getContext()->getOutput();
  18              LogEventsList::showLogExtract(
  19                  $out,
  20                  'renameuser',
  21                  $page,
  22                  '',
  23                  array(
  24                      'lim' => 10,
  25                      'showIfEmpty' => false,
  26                      'msgKey' => array( 'renameuser-renamed-notice', $title->getBaseText() )
  27                  )
  28              );
  29          }
  30  
  31          return true;
  32      }
  33  
  34      /**
  35       * Shows link to Special:Renameuser on Special:Contributions/foo
  36       *
  37       * @param $id
  38       * @param $nt Title
  39       * @param $tools
  40       *
  41       * @return bool
  42       */
  43  	public static function onContributionsToolLinks( $id, $nt, &$tools ) {
  44          global $wgUser;
  45  
  46          if ( $wgUser->isAllowed( 'renameuser' ) && $id ) {
  47              $tools[] = Linker::link(
  48                  SpecialPage::getTitleFor( 'Renameuser' ),
  49                  wfMessage( 'renameuser-linkoncontribs' )->text(),
  50                  array( 'title' => wfMessage( 'renameuser-linkoncontribs-text' )->parse() ),
  51                  array( 'oldusername' => $nt->getText() )
  52              );
  53          }
  54          return true;
  55      }
  56  
  57      /**
  58       * So users can just type in a username for target and it'll work
  59       * @param array $types
  60       * @return bool
  61       */
  62  	public static function onGetLogTypesOnUser( array &$types ) {
  63          $types[] = 'renameuser';
  64          return true;
  65      }
  66  }


Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1