Deprecating ; reordering the special pages array (whose the special page list is...
authorRotem Liss <rotem@users.mediawiki.org>
Sun, 23 Jul 2006 12:36:37 +0000 (12:36 +0000)
committerRotem Liss <rotem@users.mediawiki.org>
Sun, 23 Jul 2006 12:36:37 +0000 (12:36 +0000)
includes/Defines.php
includes/Skin.php
includes/SpecialPage.php
includes/SpecialSpecialpages.php
includes/User.php

index 9ff8303..287551b 100644 (file)
@@ -75,10 +75,8 @@ define( 'MW_MATH_MATHML', 5 );
 /**#@-*/
 
 /**
- * User rights management
- * a big array of string defining a right, that's how they are saved in the
- * database.
- * @todo Is this necessary?
+ * User rights list
+ * @deprecated
  */
 $wgAvailableRights = array(
        'block',
index b56ec96..00b2f44 100644 (file)
@@ -1016,7 +1016,7 @@ END;
         * @TODO crash bug913. Need to be rewrote completly.
         */
        function specialPagesList() {
-               global $wgUser, $wgContLang, $wgServer, $wgRedirectScript, $wgAvailableRights;
+               global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
                require_once('SpecialPage.php');
                $a = array();
                $pages = SpecialPage::getPages();
@@ -1027,15 +1027,9 @@ END;
                }
 
                // Other special pages that are restricted.
-               // Copied from SpecialSpecialpages.php
-               foreach($wgAvailableRights as $right) {
-                       if( $wgUser->isAllowed($right) ) {
-                               /** Add all pages for this right */
-                               if(isset($pages[$right])) {
-                                       foreach($pages[$right] as $name => $page) {
-                                       $a[$name] = $page->getDescription();
-                                       }
-                               }
+               foreach ( $pages['restricted'] as $name => $page ) {
+                       if( $wgUser->isAllowed( $page->getRestriction() ) ) {
+                               $a[$name] = $page->getDescription();
                        }
                }
 
index 3a52f85..b5ba9d7 100644 (file)
@@ -292,7 +292,8 @@ class SpecialPage
                foreach ( self::$mList as $name => $rec ) {
                        $page = self::getPage( $name );
                        if ( $page->isListed() ) {
-                               $pages[$page->getRestriction()][$page->getName()] = $page;
+                               $restricted = $page->getRestriction() == '' ? '' : 'restricted';
+                               $pages[$restricted][$page->getName()] = $page;
                        }
                }
                return $pages;
index 0b53db7..ea7ceda 100644 (file)
@@ -9,7 +9,7 @@
  *
  */
 function wfSpecialSpecialpages() {
-       global $wgOut, $wgUser, $wgAvailableRights;
+       global $wgOut, $wgUser;
 
        $wgOut->setRobotpolicy( 'index,nofollow' );
        $sk = $wgUser->getSkin();
@@ -22,13 +22,9 @@ function wfSpecialSpecialpages() {
 
        /** Restricted special pages */
        $rpages = array();
-       foreach($wgAvailableRights as $right) {
-               /** only show pages a user can access */
-               if( $wgUser->isAllowed($right) ) {
-                       /** some rights might not have any special page associated */
-                       if(isset($pages[$right])) {
-                               $rpages = array_merge( $rpages, $pages[$right] );
-                       }
+       foreach ( $pages['restricted'] as $name => $page ) {
+               if( $wgUser->isAllowed( $page->getRestriction() ) ) {
+                       $rpages[$name] = $page;
                }
        }
        wfSpecialSpecialpages_gen( $rpages, 'restrictedpheading', $sk );
index 7bc52ab..a0f34be 100644 (file)
@@ -1234,7 +1234,7 @@ class User {
 
        /**
         * Check if user is allowed to access a feature / make an action
-        * @param string $action Action to be checked (see $wgAvailableRights in Defines.php for possible actions).
+        * @param string $action Action to be checked
         * @return boolean True: action is allowed, False: action should not be allowed
         */
        function isAllowed($action='') {