Expose $wgMaxArticleSize in siteinfo query api
[mediawiki.git] / includes / specials / SpecialListgrants.php
blob39c8ae8a93d01713429682c5f89c3344391671f2
1 <?php
2 /**
3 * Implements Special:Listgrants
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @ingroup SpecialPage
24 /**
25 * This special page lists all defined rights grants and the associated rights.
26 * See also @ref $wgGrantPermissions and @ref $wgGrantPermissionGroups.
28 * @ingroup SpecialPage
30 class SpecialListGrants extends SpecialPage {
31 function __construct() {
32 parent::__construct( 'Listgrants' );
35 /**
36 * Show the special page
37 * @param string|null $par
39 public function execute( $par ) {
40 $this->setHeaders();
41 $this->outputHeader();
43 $out = $this->getOutput();
44 $out->addModuleStyles( 'mediawiki.special' );
46 $out->addHTML(
47 \Html::openElement( 'table',
48 [ 'class' => 'wikitable mw-listgrouprights-table' ] ) .
49 '<tr>' .
50 \Html::element( 'th', null, $this->msg( 'listgrants-grant' )->text() ) .
51 \Html::element( 'th', null, $this->msg( 'listgrants-rights' )->text() ) .
52 '</tr>'
55 foreach ( $this->getConfig()->get( 'GrantPermissions' ) as $grant => $rights ) {
56 $descs = [];
57 $rights = array_filter( $rights ); // remove ones with 'false'
58 foreach ( $rights as $permission => $granted ) {
59 $descs[] = $this->msg(
60 'listgrouprights-right-display',
61 \User::getRightDescription( $permission ),
62 '<span class="mw-listgrants-right-name">' . $permission . '</span>'
63 )->parse();
65 if ( !count( $descs ) ) {
66 $grantCellHtml = '';
67 } else {
68 sort( $descs );
69 $grantCellHtml = '<ul><li>' . implode( "</li>\n<li>", $descs ) . '</li></ul>';
72 $id = \Sanitizer::escapeId( $grant );
73 $out->addHTML( \Html::rawElement( 'tr', [ 'id' => $id ],
74 "<td>" . $this->msg( "grant-$grant" )->escaped() . "</td>" .
75 "<td>" . $grantCellHtml . '</td>'
76 ) );
79 $out->addHTML( \Html::closeElement( 'table' ) );
82 protected function getGroupName() {
83 return 'users';