MediaWiki master
SpecialListGrants.php
Go to the documentation of this file.
1<?php
24namespace MediaWiki\Specials;
25
31
39 private GrantsLocalization $grantsLocalization;
40
41 public function __construct( GrantsLocalization $grantsLocalization ) {
42 parent::__construct( 'Listgrants' );
43 $this->grantsLocalization = $grantsLocalization;
44 }
45
50 public function execute( $par ) {
51 $this->setHeaders();
52 $this->outputHeader();
53
54 $out = $this->getOutput();
55 $out->addModuleStyles( 'mediawiki.special' );
56
57 $out->addHTML(
58 Html::openElement( 'table', [ 'class' => 'wikitable mw-listgrouprights-table' ] ) .
59 '<tr>' .
60 Html::element( 'th', [], $this->msg( 'listgrants-grant' )->text() ) .
61 Html::element( 'th', [], $this->msg( 'listgrants-rights' )->text() ) .
62 '</tr>'
63 );
64
65 $lang = $this->getLanguage();
66
67 foreach (
68 $this->getConfig()->get( MainConfigNames::GrantPermissions ) as $grant => $rights
69 ) {
70 $descs = [];
71 $rights = array_filter( $rights ); // remove ones with 'false'
72 foreach ( $rights as $permission => $granted ) {
73 $descs[] = $this->msg( 'listgrouprights-right-display' )
74 ->params( User::getRightDescription( $permission ) )
75 ->rawParams( Html::element(
76 'span',
77 [ 'class' => 'mw-listgrants-right-name' ],
78 $permission
79 ) )
80 ->parse();
81 }
82 if ( $descs === [] ) {
83 $grantCellHtml = '';
84 } else {
85 sort( $descs );
86 $grantCellHtml = '<ul><li>' . implode( "</li>\n<li>", $descs ) . '</li></ul>';
87 }
88
89 $out->addHTML( Html::rawElement( 'tr', [ 'id' => $grant ],
90 "<td>" .
91 $this->msg( 'listgrants-grant-display' )
92 ->params( $this->grantsLocalization->getGrantDescription( $grant, $lang ) )
93 ->rawParams( Html::element(
94 'span',
95 [ 'class' => 'mw-listgrants-grant-name' ],
96 $grant
97 ) )
98 ->parse() .
99 "</td>" .
100 "<td>" . $grantCellHtml . "</td>"
101 ) );
102 }
103
104 $out->addHTML( Html::closeElement( 'table' ) );
105 }
106
107 protected function getGroupName() {
108 return 'users';
109 }
110}
111
113class_alias( SpecialListGrants::class, 'SpecialListGrants' );
This class is a collection of static functions that serve two purposes:
Definition Html.php:56
A class containing constants representing the names of configuration variables.
const GrantPermissions
Name constant for the GrantPermissions setting, for use with Config::get()
This separate service is needed because the ::getGrantsLink method requires a LinkRenderer and if we ...
Parent class for all special pages.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getConfig()
Shortcut to get main config object.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
getLanguage()
Shortcut to get user's language.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
This special page lists all defined rights grants and the associated rights.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
__construct(GrantsLocalization $grantsLocalization)
execute( $par)
Show the special page.
internal since 1.36
Definition User.php:93
element(SerializerNode $parent, SerializerNode $node, $contents)
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...