Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 46 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| SpecialListGrants | |
0.00% |
0 / 45 |
|
0.00% |
0 / 3 |
42 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
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 | private GrantsLocalization $grantsLocalization; |
| 25 | |
| 26 | public function __construct( GrantsLocalization $grantsLocalization ) { |
| 27 | parent::__construct( 'Listgrants' ); |
| 28 | $this->grantsLocalization = $grantsLocalization; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Show the special page |
| 33 | * @param string|null $par |
| 34 | */ |
| 35 | public function execute( $par ) { |
| 36 | $this->setHeaders(); |
| 37 | $this->outputHeader(); |
| 38 | |
| 39 | $out = $this->getOutput(); |
| 40 | $out->addModuleStyles( 'mediawiki.special' ); |
| 41 | |
| 42 | $out->addHTML( |
| 43 | Html::openElement( 'table', [ 'class' => [ 'wikitable', 'mw-listgrouprights-table' ] ] ) . |
| 44 | '<tr>' . |
| 45 | Html::element( 'th', [], $this->msg( 'listgrants-grant' )->text() ) . |
| 46 | Html::element( 'th', [], $this->msg( 'listgrants-rights' )->text() ) . |
| 47 | '</tr>' |
| 48 | ); |
| 49 | |
| 50 | $lang = $this->getLanguage(); |
| 51 | |
| 52 | foreach ( |
| 53 | $this->getConfig()->get( MainConfigNames::GrantPermissions ) as $grant => $rights |
| 54 | ) { |
| 55 | $descs = []; |
| 56 | $rights = array_filter( $rights ); // remove ones with 'false' |
| 57 | foreach ( $rights as $permission => $granted ) { |
| 58 | $descs[] = $this->msg( 'listgrouprights-right-display' ) |
| 59 | ->params( User::getRightDescription( $permission ) ) |
| 60 | ->rawParams( Html::element( |
| 61 | 'span', |
| 62 | [ 'class' => 'mw-listgrants-right-name' ], |
| 63 | $permission |
| 64 | ) ) |
| 65 | ->parse(); |
| 66 | } |
| 67 | if ( $descs === [] ) { |
| 68 | $grantCellHtml = ''; |
| 69 | } else { |
| 70 | sort( $descs ); |
| 71 | $grantCellHtml = '<ul><li>' . implode( "</li>\n<li>", $descs ) . '</li></ul>'; |
| 72 | } |
| 73 | |
| 74 | $out->addHTML( Html::rawElement( 'tr', [ 'id' => $grant ], |
| 75 | "<td>" . |
| 76 | $this->msg( 'listgrants-grant-display' ) |
| 77 | ->params( $this->grantsLocalization->getGrantDescription( $grant, $lang ) ) |
| 78 | ->rawParams( Html::element( |
| 79 | 'span', |
| 80 | [ 'class' => 'mw-listgrants-grant-name' ], |
| 81 | $grant |
| 82 | ) ) |
| 83 | ->parse() . |
| 84 | "</td>" . |
| 85 | "<td>" . $grantCellHtml . "</td>" |
| 86 | ) ); |
| 87 | } |
| 88 | |
| 89 | $out->addHTML( Html::closeElement( 'table' ) ); |
| 90 | } |
| 91 | |
| 92 | /** @inheritDoc */ |
| 93 | protected function getGroupName() { |
| 94 | return 'users'; |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | /** @deprecated class alias since 1.41 */ |
| 99 | class_alias( SpecialListGrants::class, 'SpecialListGrants' ); |