* (bug 13604) Add Special:ListGroupRights to show a list of defined usergroups and...
authorRaimond Spekking <raymond@users.mediawiki.org>
Thu, 10 Apr 2008 10:10:07 +0000 (10:10 +0000)
committerRaimond Spekking <raymond@users.mediawiki.org>
Thu, 10 Apr 2008 10:10:07 +0000 (10:10 +0000)
See bug 13603 for the same function added to the API last week
Patch by Mormegil

RELEASE-NOTES
includes/AutoLoader.php
includes/DefaultSettings.php
includes/SpecialListgrouprights.php [new file with mode: 0644]
includes/SpecialPage.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc
skins/common/shared.css

index 0882f98..808adf4 100644 (file)
@@ -64,7 +64,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Redesign of Special:Userrights
 * Make rev_deleted log entries more intelligible.
 * (bug 6943) Added PAGESINCATEGORY: magic word
-
+* (bug 13604) Added Special:ListGroupRights
 
 === Bug fixes in 1.13 ===
 
index 0aa929a..8eecb77 100644 (file)
@@ -234,6 +234,7 @@ function __autoload($className) {
                'SkinTemplate' => 'includes/SkinTemplate.php',
                'SpecialAllpages' => 'includes/SpecialAllpages.php',
                'SpecialBookSources' => 'includes/SpecialBooksources.php',
+               'SpecialListGroupRights' => 'includes/SpecialListgrouprights.php',
                'SpecialMostlinkedtemplates' => 'includes/SpecialMostlinkedtemplates.php',
                'SpecialPage' => 'includes/SpecialPage.php',
                'SpecialPrefixindex' => 'includes/SpecialPrefixindex.php',
index 5cd275f..9e94135 100644 (file)
@@ -1342,7 +1342,7 @@ $wgCacheEpoch = '20030516000000';
  * to ensure that client-side caches don't keep obsolete copies of global
  * styles.
  */
-$wgStyleVersion = '132';
+$wgStyleVersion = '133';
 
 
 # Server-side caching:
diff --git a/includes/SpecialListgrouprights.php b/includes/SpecialListgrouprights.php
new file mode 100644 (file)
index 0000000..bf3ae92
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+
+/**
+ * This special page lists all defined user groups and the associated rights.
+ * See also @ref $wgGroupPermissions.
+ *
+ * @addtogroup SpecialPage
+ * @author Petr Kadlec <mormegil@centrum.cz>
+ */
+class SpecialListGroupRights extends SpecialPage {
+
+       var $skin;
+
+       /**
+        * Constructor
+        */
+       function __construct() {
+               global $wgUser;
+               parent::__construct( 'Listgrouprights' );
+               $this->skin = $wgUser->getSkin();
+       }
+
+       /**
+        * Show the special page
+        */
+       public function execute( $par ) {
+               global $wgOut, $wgGroupPermissions, $wgImplicitGroups;
+
+               $this->setHeaders();
+               $this->outputHeader();
+
+               $wgOut->addHTML(
+                       Xml::openElement( 'table', array( 'class' => 'mw-listgrouprights-table' ) ) .
+                               '<tr>' .
+                                       Xml::element( 'th', null, wfMsg( 'listgrouprights-group' ) ) .
+                                       Xml::element( 'th', null, wfMsg( 'listgrouprights-rights' ) ) .
+                               '</tr>'
+               );
+
+               foreach( $wgGroupPermissions as $group => $permissions ) {
+                       $groupname = htmlspecialchars( $group );
+                       if ( in_array( $group, $wgImplicitGroups ) )
+                               $grouplink = $groupname;
+                       else
+                               $grouplink = $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Listusers' ), $groupname, 'group=' . $group );
+
+                       $wgOut->addHTML(
+                               '<tr>
+                                       <td>' .
+                                               $grouplink .
+                                       '</td>
+                                       <td>' .
+                                               SpecialListGroupRights::formatPermissions( $permissions ) .
+                                       '</td>
+                               </tr>'
+                       );
+               }
+               $wgOut->addHTML( 
+                       Xml::closeElement( 'table' ) . "\n"
+               );
+       }
+
+       /**
+        * Create a user-readable list of permissions from the given array.
+        *
+        * @param $permissions Array of permission => bool (from $wgGroupPermissions items)
+        * @return string List of all granted permissions, separated by comma separator
+        */
+        private static function formatPermissions( $permissions ) {
+               global $wgUser;
+               $r = array();
+               foreach( $permissions as $permission => $granted ) {
+                       if ( $granted ) {
+                               $permission = htmlspecialchars( $permission );
+                               $r[] = wfMsgExt( 'listgrouprights-link', array( 'parseinline' ), $permission );
+                       }
+               }
+               sort( $r );
+               $r = implode( wfMsg( 'comma-separator' ), $r );
+
+               return $r;
+       }
+}
index 8a157eb..ea891c8 100644 (file)
@@ -85,6 +85,7 @@ class SpecialPage
                'Imagelist'                 => array( 'SpecialPage', 'Imagelist' ),
                'Newimages'                 => array( 'IncludableSpecialPage', 'Newimages' ),
                'Listusers'                 => array( 'SpecialPage', 'Listusers' ),
+               'Listgrouprights'           => 'SpecialListGroupRights',
                'Statistics'                => array( 'SpecialPage', 'Statistics' ),
                'Randompage'                => 'Randompage',
                'Lonelypages'               => array( 'SpecialPage', 'Lonelypages' ),
index 11a7a07..f5253c9 100644 (file)
@@ -363,6 +363,7 @@ $specialPageAliases = array(
        'Imagelist'                 => array( 'ImageList' ),
        'Newimages'                 => array( 'NewImages' ),
        'Listusers'                 => array( 'ListUsers', 'UserList' ),
+       'Listgrouprights'           => array( 'ListGroupRights' ),
        'Statistics'                => array( 'Statistics' ),
        'Randompage'                => array( 'Random', 'RandomPage' ),
        'Lonelypages'               => array( 'LonelyPages', 'OrphanedPages' ),
@@ -1876,6 +1877,13 @@ It may contain one or more characters which cannot be used in titles.',
 'listusers-submit'   => 'Show',
 'listusers-noresult' => 'No user found.',
 
+# Special:Listgrouprights
+'listgrouprights'         => 'User group rights',
+'listgrouprights-summary' => 'The following is a list of user groups defined on this wiki, with their associated access rights.',
+'listgrouprights-group'   => 'Group',
+'listgrouprights-rights'  => 'Rights',
+'listgrouprights-link'    => "[[{{ns:help}}:Group rights#$1|$1]]",
+
 # E-mail user
 'mailnologin'     => 'No send address',
 'mailnologintext' => 'You must be [[Special:Userlogin|logged in]] and have a valid e-mail address in your [[Special:Preferences|preferences]] to send e-mail to other users.',
index 1f9e364..03516f9 100644 (file)
@@ -1208,6 +1208,13 @@ $wgMessageStructure = array(
                'listusers-submit',
                'listusers-noresult',
        ),
+       'listgrouprights' => array(
+               'listgrouprights',
+               'listgrouprights-summary',
+               'listgrouprights-group',
+               'listgrouprights-rights',
+               'listgrouprights-link',
+       ),
        'emailuser' => array(
                'mailnologin',
                'mailnologintext',
@@ -2513,6 +2520,7 @@ XHTML id names.",
        'logpages'            => 'Special:Log',
        'allpages'            => 'Special:Allpages',
        'listusers'           => 'Special:Listusers',
+       'listgrouprights'     => 'Special:Listgrouprights',
        'emailuser'           => 'E-mail user',
        'watchlist'           => 'Watchlist',
        'watching'            => 'Displayed when you click the "watch" button and it is in the process of watching',
index dba01a9..66bc561 100644 (file)
@@ -122,3 +122,17 @@ table.mw-userrights-groups * td,table.mw-userrights-groups * th {
     background-color: #f9f9f9;
     border: 1px dashed #aaa;
 }
+
+table.mw-listgrouprights-table  {
+       border: 1px solid #ccc;
+       border-collapse: collapse;
+}
+
+table.mw-listgrouprights-table tr  {
+       vertical-align: top;
+}
+
+table.mw-listgrouprights-table td, table.mw-listgrouprights-table th {
+       padding: 0.5em 0.2em 0.5em 0.2em;
+       border: 1px solid #ccc;
+}