mediawiki-extensions-Nuke/includes/NukeHooks.php
Ammarpad 2ae6a87f6a Replace deprecated IP class with IPUtils
Raise required MW version to >= 1.35.0

Bug: T242556
Change-Id: I1a61cf5e1a66fcde3edd5b010eb8c34de4b47dc3
2020-02-18 21:12:21 +00:00

29 lines
766 B
PHP

<?php
use Wikimedia\IPUtils;
class NukeHooks {
/**
* Shows link to Special:Nuke on Special:Contributions/username if applicable
*
* @param int $userId
* @param Title $userPageTitle
* @param string[] &$toolLinks
* @param SpecialPage $sp
*/
public static function nukeContributionsLinks( $userId, $userPageTitle, &$toolLinks,
SpecialPage $sp
) {
$username = $userPageTitle->getText();
if ( $sp->getUser()->isAllowed( 'nuke' ) && !IPUtils::isValidRange( $username ) ) {
$toolLinks['nuke'] = $sp->getLinkRenderer()->makeKnownLink(
SpecialPage::getTitleFor( 'Nuke' ),
$sp->msg( 'nuke-linkoncontribs' )->text(),
[ 'title' => $sp->msg( 'nuke-linkoncontribs-text', $username )->text() ],
[ 'target' => $username ]
);
}
}
}