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 | * This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation; either version 2 of the License, or |
6 | * (at your option) any later version. |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License along |
14 | * with this program; if not, write to the Free Software Foundation, Inc., |
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
16 | * http://www.gnu.org/copyleft/gpl.html |
17 | * |
18 | * @file |
19 | */ |
20 | |
21 | namespace MediaWiki\Specials; |
22 | |
23 | use MediaWiki\Html\Html; |
24 | use MediaWiki\MainConfigNames; |
25 | use MediaWiki\Permissions\GrantsLocalization; |
26 | use MediaWiki\SpecialPage\SpecialPage; |
27 | use MediaWiki\User\User; |
28 | |
29 | /** |
30 | * List all defined rights grants and the associated rights. |
31 | * |
32 | * See also @ref $wgGrantPermissions and @ref $wgGrantPermissionGroups. |
33 | * |
34 | * @see SpecialListGroupRights |
35 | * @ingroup SpecialPage |
36 | */ |
37 | class SpecialListGrants extends SpecialPage { |
38 | private GrantsLocalization $grantsLocalization; |
39 | |
40 | public function __construct( GrantsLocalization $grantsLocalization ) { |
41 | parent::__construct( 'Listgrants' ); |
42 | $this->grantsLocalization = $grantsLocalization; |
43 | } |
44 | |
45 | /** |
46 | * Show the special page |
47 | * @param string|null $par |
48 | */ |
49 | public function execute( $par ) { |
50 | $this->setHeaders(); |
51 | $this->outputHeader(); |
52 | |
53 | $out = $this->getOutput(); |
54 | $out->addModuleStyles( 'mediawiki.special' ); |
55 | |
56 | $out->addHTML( |
57 | Html::openElement( 'table', [ 'class' => 'wikitable mw-listgrouprights-table' ] ) . |
58 | '<tr>' . |
59 | Html::element( 'th', [], $this->msg( 'listgrants-grant' )->text() ) . |
60 | Html::element( 'th', [], $this->msg( 'listgrants-rights' )->text() ) . |
61 | '</tr>' |
62 | ); |
63 | |
64 | $lang = $this->getLanguage(); |
65 | |
66 | foreach ( |
67 | $this->getConfig()->get( MainConfigNames::GrantPermissions ) as $grant => $rights |
68 | ) { |
69 | $descs = []; |
70 | $rights = array_filter( $rights ); // remove ones with 'false' |
71 | foreach ( $rights as $permission => $granted ) { |
72 | $descs[] = $this->msg( 'listgrouprights-right-display' ) |
73 | ->params( User::getRightDescription( $permission ) ) |
74 | ->rawParams( Html::element( |
75 | 'span', |
76 | [ 'class' => 'mw-listgrants-right-name' ], |
77 | $permission |
78 | ) ) |
79 | ->parse(); |
80 | } |
81 | if ( $descs === [] ) { |
82 | $grantCellHtml = ''; |
83 | } else { |
84 | sort( $descs ); |
85 | $grantCellHtml = '<ul><li>' . implode( "</li>\n<li>", $descs ) . '</li></ul>'; |
86 | } |
87 | |
88 | $out->addHTML( Html::rawElement( 'tr', [ 'id' => $grant ], |
89 | "<td>" . |
90 | $this->msg( 'listgrants-grant-display' ) |
91 | ->params( $this->grantsLocalization->getGrantDescription( $grant, $lang ) ) |
92 | ->rawParams( Html::element( |
93 | 'span', |
94 | [ 'class' => 'mw-listgrants-grant-name' ], |
95 | $grant |
96 | ) ) |
97 | ->parse() . |
98 | "</td>" . |
99 | "<td>" . $grantCellHtml . "</td>" |
100 | ) ); |
101 | } |
102 | |
103 | $out->addHTML( Html::closeElement( 'table' ) ); |
104 | } |
105 | |
106 | protected function getGroupName() { |
107 | return 'users'; |
108 | } |
109 | } |
110 | |
111 | /** @deprecated class alias since 1.41 */ |
112 | class_alias( SpecialListGrants::class, 'SpecialListGrants' ); |