mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Nuke
synced 2024-11-15 03:35:39 +00:00
df1cd09150
Bug: T271020 Change-Id: Icd15d5f483dd0e73cedf5604ec27e42c8f7e341d
32 lines
926 B
PHP
32 lines
926 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Nuke;
|
|
|
|
use MediaWiki\Hook\ContributionsToolLinksHook;
|
|
use SpecialPage;
|
|
use Title;
|
|
use Wikimedia\IPUtils;
|
|
|
|
class Hooks implements ContributionsToolLinksHook {
|
|
|
|
/**
|
|
* Shows link to Special:Nuke on Special:Contributions/username if applicable
|
|
*
|
|
* @param int $id
|
|
* @param Title $title
|
|
* @param string[] &$tools
|
|
* @param SpecialPage $specialPage
|
|
*/
|
|
public function onContributionsToolLinks( $id, Title $title, array &$tools, SpecialPage $specialPage ) {
|
|
$username = $title->getText();
|
|
if ( $specialPage->getUser()->isAllowed( 'nuke' ) && !IPUtils::isValidRange( $username ) ) {
|
|
$tools['nuke'] = $specialPage->getLinkRenderer()->makeKnownLink(
|
|
SpecialPage::getTitleFor( 'Nuke' ),
|
|
$specialPage->msg( 'nuke-linkoncontribs' )->text(),
|
|
[ 'title' => $specialPage->msg( 'nuke-linkoncontribs-text', $username )->text() ],
|
|
[ 'target' => $username ]
|
|
);
|
|
}
|
|
}
|
|
}
|