Special:ListGroupRights: Add per-namespace restrictions and rights
authorAlex Monk <krenair@gmail.com>
Sun, 23 Dec 2012 16:39:21 +0000 (16:39 +0000)
committerAlex Monk <krenair@gmail.com>
Wed, 9 Apr 2014 19:27:54 +0000 (20:27 +0100)
Bug: 43282
Change-Id: Ibe9deeedb8fef24627b2cda73823d70c4d8a768d

includes/specials/SpecialListgrouprights.php
languages/i18n/en.json
languages/i18n/qqq.json

index 82a4f70..31034f9 100644 (file)
@@ -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' ) );
        }
 
        /**
index 45a64df..34b6998 100644 (file)
     "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",
index 939d011..878a18a 100644 (file)
     "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}}",