MediaWiki REL1_40
SpecialListGrants.php
Go to the documentation of this file.
1<?php
26
35 private $grantsLocalization;
36
37 public function __construct( GrantsLocalization $grantsLocalization ) {
38 parent::__construct( 'Listgrants' );
39 $this->grantsLocalization = $grantsLocalization;
40 }
41
46 public function execute( $par ) {
47 $this->setHeaders();
48 $this->outputHeader();
49
50 $out = $this->getOutput();
51 $out->addModuleStyles( 'mediawiki.special' );
52
53 $out->addHTML(
54 \MediaWiki\Html\Html::openElement( 'table',
55 [ 'class' => 'wikitable mw-listgrouprights-table' ] ) .
56 '<tr>' .
57 \MediaWiki\Html\Html::element( 'th', [], $this->msg( 'listgrants-grant' )->text() ) .
58 \MediaWiki\Html\Html::element( 'th', [], $this->msg( 'listgrants-rights' )->text() ) .
59 '</tr>'
60 );
61
62 $lang = $this->getLanguage();
63
64 foreach (
65 $this->getConfig()->get( MainConfigNames::GrantPermissions ) as $grant => $rights
66 ) {
67 $descs = [];
68 $rights = array_filter( $rights ); // remove ones with 'false'
69 foreach ( $rights as $permission => $granted ) {
70 $descs[] = $this->msg(
71 'listgrouprights-right-display',
72 \User::getRightDescription( $permission ),
73 '<span class="mw-listgrants-right-name">' . $permission . '</span>'
74 )->parse();
75 }
76 if ( $descs === [] ) {
77 $grantCellHtml = '';
78 } else {
79 sort( $descs );
80 $grantCellHtml = '<ul><li>' . implode( "</li>\n<li>", $descs ) . '</li></ul>';
81 }
82
83 $id = Sanitizer::escapeIdForAttribute( $grant );
84 $out->addHTML( \MediaWiki\Html\Html::rawElement( 'tr', [ 'id' => $id ],
85 "<td>" .
86 $this->msg(
87 "listgrants-grant-display",
88 $this->grantsLocalization->getGrantDescription( $grant, $lang ),
89 "<span class='mw-listgrants-grant-name'>" . $id . "</span>"
90 )->parse() .
91 "</td>" .
92 "<td>" . $grantCellHtml . "</td>"
93 ) );
94 }
95
96 $out->addHTML( \MediaWiki\Html\Html::closeElement( 'table' ) );
97 }
98
99 protected function getGroupName() {
100 return 'users';
101 }
102}
A class containing constants representing the names of configuration variables.
This separate service is needed because the ::getGrantsLink method requires a LinkRenderer and if we ...
This special page lists all defined rights grants and the associated rights.
__construct(GrantsLocalization $grantsLocalization)
execute( $par)
Show the special page.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Parent class for all special pages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getLanguage()
Shortcut to get user's language.
static getRightDescription( $right)
Get the description of a given right.
Definition User.php:3352
A helper class for throttling authentication attempts.
if(!isset( $args[0])) $lang