Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 44 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| SpecialListGrants | |
0.00% |
0 / 44 |
|
0.00% |
0 / 3 |
42 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| execute | |
0.00% |
0 / 42 |
|
0.00% |
0 / 1 |
20 | |||
| getGroupName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | */ |
| 6 | |
| 7 | namespace MediaWiki\Specials; |
| 8 | |
| 9 | use MediaWiki\Html\Html; |
| 10 | use MediaWiki\MainConfigNames; |
| 11 | use MediaWiki\Permissions\GrantsLocalization; |
| 12 | use MediaWiki\SpecialPage\SpecialPage; |
| 13 | use MediaWiki\User\User; |
| 14 | |
| 15 | /** |
| 16 | * List all defined rights grants and the associated rights. |
| 17 | * |
| 18 | * See also @ref $wgGrantPermissions and @ref $wgGrantPermissionGroups. |
| 19 | * |
| 20 | * @see SpecialListGroupRights |
| 21 | * @ingroup SpecialPage |
| 22 | */ |
| 23 | class SpecialListGrants extends SpecialPage { |
| 24 | public function __construct( |
| 25 | private readonly GrantsLocalization $grantsLocalization, |
| 26 | ) { |
| 27 | parent::__construct( 'Listgrants' ); |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Show the special page |
| 32 | * @param string|null $par |
| 33 | */ |
| 34 | public function execute( $par ) { |
| 35 | $this->setHeaders(); |
| 36 | $this->outputHeader(); |
| 37 | |
| 38 | $out = $this->getOutput(); |
| 39 | $out->addModuleStyles( 'mediawiki.special' ); |
| 40 | |
| 41 | $out->addHTML( |
| 42 | Html::openElement( 'table', [ 'class' => [ 'wikitable', 'mw-listgrouprights-table' ] ] ) . |
| 43 | '<tr>' . |
| 44 | Html::element( 'th', [], $this->msg( 'listgrants-grant' )->text() ) . |
| 45 | Html::element( 'th', [], $this->msg( 'listgrants-rights' )->text() ) . |
| 46 | '</tr>' |
| 47 | ); |
| 48 | |
| 49 | $lang = $this->getLanguage(); |
| 50 | |
| 51 | foreach ( |
| 52 | $this->getConfig()->get( MainConfigNames::GrantPermissions ) as $grant => $rights |
| 53 | ) { |
| 54 | $descs = []; |
| 55 | $rights = array_filter( $rights ); // remove ones with 'false' |
| 56 | foreach ( $rights as $permission => $granted ) { |
| 57 | $descs[] = $this->msg( 'listgrouprights-right-display' ) |
| 58 | ->params( User::getRightDescription( $permission ) ) |
| 59 | ->rawParams( Html::element( |
| 60 | 'span', |
| 61 | [ 'class' => 'mw-listgrants-right-name' ], |
| 62 | $permission |
| 63 | ) ) |
| 64 | ->parse(); |
| 65 | } |
| 66 | if ( $descs === [] ) { |
| 67 | $grantCellHtml = ''; |
| 68 | } else { |
| 69 | sort( $descs ); |
| 70 | $grantCellHtml = '<ul><li>' . implode( "</li>\n<li>", $descs ) . '</li></ul>'; |
| 71 | } |
| 72 | |
| 73 | $out->addHTML( Html::rawElement( 'tr', [ 'id' => $grant ], |
| 74 | "<td>" . |
| 75 | $this->msg( 'listgrants-grant-display' ) |
| 76 | ->params( $this->grantsLocalization->getGrantDescription( $grant, $lang ) ) |
| 77 | ->rawParams( Html::element( |
| 78 | 'span', |
| 79 | [ 'class' => 'mw-listgrants-grant-name' ], |
| 80 | $grant |
| 81 | ) ) |
| 82 | ->parse() . |
| 83 | "</td>" . |
| 84 | "<td>" . $grantCellHtml . "</td>" |
| 85 | ) ); |
| 86 | } |
| 87 | |
| 88 | $out->addHTML( Html::closeElement( 'table' ) ); |
| 89 | } |
| 90 | |
| 91 | /** @inheritDoc */ |
| 92 | protected function getGroupName() { |
| 93 | return 'users'; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | // @codeCoverageIgnoreStart |
| 98 | /** @deprecated class alias since 1.41 */ |
| 99 | class_alias( SpecialListGrants::class, 'SpecialListGrants' ); |
| 100 | // @codeCoverageIgnoreEnd |