From 4c8133adbad85bdd637021bb307b84c370d9c908 Mon Sep 17 00:00:00 2001 From: Alex Monk Date: Sun, 23 Dec 2012 16:39:21 +0000 Subject: [PATCH] Special:ListGroupRights: Add per-namespace restrictions and rights Bug: 43282 Change-Id: Ibe9deeedb8fef24627b2cda73823d70c4d8a768d --- includes/specials/SpecialListgrouprights.php | 82 ++++++++++++++++++++ languages/i18n/en.json | 3 + languages/i18n/qqq.json | 3 + 3 files changed, 88 insertions(+) diff --git a/includes/specials/SpecialListgrouprights.php b/includes/specials/SpecialListgrouprights.php index 82a4f70f1d..31034f9cb2 100644 --- a/includes/specials/SpecialListgrouprights.php +++ b/includes/specials/SpecialListgrouprights.php @@ -132,6 +132,88 @@ class SpecialListGroupRights extends SpecialPage { ) ); } $out->addHTML( Xml::closeElement( 'table' ) ); + $this->outputNamespaceProtectionInfo(); + } + + private function outputNamespaceProtectionInfo() { + global $wgNamespaceProtection, $wgParser, $wgContLang; + $out = $this->getOutput(); + + if ( count( $wgNamespaceProtection ) == 0 ) { + return; + } + + $header = $this->msg( 'listgrouprights-namespaceprotection-header' )->parse(); + $out->addHTML( + Html::rawElement( 'h2', array(), Html::element( 'span', array( + 'class' => 'mw-headline', + 'id' => $wgParser->guessSectionNameFromWikiText( $header ) + ), $header ) ) . + Xml::openElement( 'table', array( 'class' => 'wikitable' ) ) . + Html::element( + 'th', + array(), + $this->msg( 'listgrouprights-namespaceprotection-namespace' )->text() + ) . + Html::element( + 'th', + array(), + $this->msg( 'listgrouprights-namespaceprotection-restrictedto' )->text() + ) + ); + + ksort( $wgNamespaceProtection ); + foreach ( $wgNamespaceProtection as $namespace => $rights ) { + if ( !in_array( $namespace, MWNamespace::getValidNamespaces() ) ) { + continue; + } + + if ( $namespace == NS_MAIN ) { + $namespaceText = $this->msg( 'blanknamespace' )->text(); + } else { + $namespaceText = $wgContLang->convertNamespace( $namespace ); + } + + $out->addHTML( + Xml::openElement( 'tr' ) . + Html::rawElement( + 'td', + array(), + Linker::link( + SpecialPage::getTitleFor( 'Allpages' ), + $namespaceText, + array(), + array( 'namespace' => $namespace ) + ) + ) . + Xml::openElement( 'td' ) . Xml::openElement( 'ul' ) + ); + + if ( !is_array( $rights ) ) { + $rights = array( $rights ); + } + + foreach ( $rights as $right ) { + $out->addHTML( + Html::rawElement( 'li', array(), $this->msg( + 'listgrouprights-right-display', + User::getRightDescription( $right ), + Html::element( + 'span', + array( 'class' => 'mw-listgrouprights-right-name' ), + $right + ) + )->parse() ) + ); + } + + $out->addHTML( + Xml::closeElement( 'ul' ) . + Xml::closeElement( 'td' ) . + Xml::closeElement( 'tr' ) + ); + } + $out->addHTML( Xml::closeElement( 'table' ) ); } /** diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 45a64df468..34b6998777 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -1772,6 +1772,9 @@ "listgrouprights-removegroup-self": "Remove {{PLURAL:$2|group|groups}} from own account: $1", "listgrouprights-addgroup-self-all": "Add all groups to own account", "listgrouprights-removegroup-self-all": "Remove all groups from own account", + "listgrouprights-namespaceprotection-header": "Namespace restrictions", + "listgrouprights-namespaceprotection-namespace": "Namespace", + "listgrouprights-namespaceprotection-restrictedto": "Right(s) allowing user to edit", "trackingcategories": "Tracking categories", "trackingcategories-summary": "This page lists tracking categories which are automatically populated by the MediaWiki software. Their names can be changed by altering the relevant system messages in the {{ns:8}} namespace.", "trackingcategories-msg": "Tracking category", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 939d01181d..878a18aca6 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -1881,6 +1881,9 @@ "listgrouprights-removegroup-self": "This is an individual right for groups, used on [[Special:ListGroupRights]].\n* $1 - the group names\n* $2 - the number of group names in $1", "listgrouprights-addgroup-self-all": "Used on [[Special:ListGroupRights]].\n{{Related|Listgrouprights}}", "listgrouprights-removegroup-self-all": "Used on [[Special:ListGroupRights]].\n{{Related|Listgrouprights}}", + "listgrouprights-namespaceprotection-header": "Shown on [[Special:ListGroupRights]] as the header for the namespace restrictions table.", + "listgrouprights-namespaceprotection-namespace": "Shown on [[Special:ListGroupRights]] as the 'namespace' column header for the namespace restrictions table.", + "listgrouprights-namespaceprotection-restrictedto": "Shown on [[Special:ListGroupRights]] as the 'right(s) allowing user to edit' column header for the namespace restrictions table.", "trackingcategories": "[[Special:TrackingCategories]] page implementing list of Tracking categories [[mw:Special:MyLanguage/Help:Tracking categories|tracking category]].\n{{Identical|Tracking category}}", "trackingcategories-summary": "Description for [[Special:TrackingCategories]] page [[mw:Help:Tracking categories|tracking category]]", "trackingcategories-msg": "Header for the message column of the table on [[Special:TrackingCategories]]. This column lists the mediawiki message that controls the tracking category in question.\n{{Identical|Tracking category}}", -- 2.20.1