mediawiki-extensions-Nuke/includes/Hooks.php
Fomafix 4ce660a73c Use namespaced classes
Change-Id: I7ed3d04a7c4922d6ccfd21dc275751155da9e643
2023-10-02 21:09:38 +00:00

35 lines
1,019 B
PHP

<?php
namespace MediaWiki\Extension\Nuke;
use MediaWiki\Hook\ContributionsToolLinksHook;
use MediaWiki\SpecialPage\SpecialPage;
use MediaWiki\Title\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(),
'class' => 'mw-contributions-link-nuke'
],
[ 'target' => $username ]
);
}
}
}