Debian Codegraph @

extensions/Nuke/includes/Hooks.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Extension\Nuke;
4
5 use MediaWiki\Hook\ContributionsToolLinksHook;
6 use MediaWiki\SpecialPage\SpecialPage;
7 use MediaWiki\Title\Title;
8 use Wikimedia\IPUtils;
9
10 class Hooks implements ContributionsToolLinksHook {
11
12 /**
13 * Shows link to Special:Nuke on Special:Contributions/username if applicable
14 *
15 * @param int $id
16 * @param Title $title
17 * @param string[] &$tools
18 * @param SpecialPage $specialPage
19 */
20 public function onContributionsToolLinks( $id, Title $title, array &$tools, SpecialPage $specialPage ) {
21 $username = $title->getText();
22 if ( $specialPage->getUser()->isAllowed( 'nuke' ) && !IPUtils::isValidRange( $username ) ) {
23 $tools['nuke'] = $specialPage->getLinkRenderer()->makeKnownLink(
24 SpecialPage::getTitleFor( 'Nuke' ),
25 $specialPage->msg( 'nuke-linkoncontribs' )->text(),
26 [
27 'title' => $specialPage->msg( 'nuke-linkoncontribs-text', $username )->text(),
28 'class' => 'mw-contributions-link-nuke'
29 ],
30 [ 'target' => $username ]
31 );
32 }
33 }
34
35 /**
36 * Registers Nuke tag for deletion logs
37 *
38 * @param string[] &$tags
39 */
40 public static function onRegisterTags( array &$tags ): bool {
41 $tags[] = 'Nuke';
42 return true;
43 }
44 }