%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/www/varak.net/wiki.varak.net/extensions/Renameuser/
Upload File :
Create Path :
Current File : //proc/self/root/www/varak.net/wiki.varak.net/extensions/Renameuser/Renameuser.hooks.php

<?php

class RenameuserHooks {
	/**
	 * Show a log if the user has been renamed and point to the new username.
	 * Don't show the log if the $oldUserName exists as a user.
	 *
	 * @param $article Article
	 * @return bool
	 */
	public static function onShowMissingArticle( $article ) {
		$title = $article->getTitle();
		$oldUser = User::newFromName( $title->getBaseText() );
		if ( ( $title->getNamespace() === NS_USER || $title->getNamespace() === NS_USER_TALK ) &&
			( $oldUser && $oldUser->isAnon() )
		) {
			// Get the title for the base userpage
			$page = Title::makeTitle( NS_USER, str_replace( ' ', '_', $title->getBaseText() ) )
				->getPrefixedDBkey();
			$out = $article->getContext()->getOutput();
			LogEventsList::showLogExtract(
				$out,
				'renameuser',
				$page,
				'',
				[
					'lim' => 10,
					'showIfEmpty' => false,
					'msgKey' => [ 'renameuser-renamed-notice', $title->getBaseText() ]
				]
			);
		}

		return true;
	}

	/**
	 * Shows link to Special:Renameuser on Special:Contributions/foo
	 *
	 * @param $id
	 * @param $nt Title
	 * @param $tools
	 *
	 * @return bool
	 */
	public static function onContributionsToolLinks( $id, $nt, &$tools ) {
		global $wgUser;

		if ( $id && $wgUser->isAllowed( 'renameuser' ) ) {
			$tools[] = Linker::link(
				SpecialPage::getTitleFor( 'Renameuser' ),
				wfMessage( 'renameuser-linkoncontribs' )->escaped(),
				[ 'title' => wfMessage( 'renameuser-linkoncontribs-text' )->parse() ],
				[ 'oldusername' => $nt->getText() ]
			);
		}

		return true;
	}

	/**
	 * So users can just type in a username for target and it'll work
	 * @param array $types
	 * @return bool
	 */
	public static function onGetLogTypesOnUser( array &$types ) {
		$types[] = 'renameuser';

		return true;
	}
}

Zerion Mini Shell 1.0