From 31c3012d45278805bddc8493e6f4dfec9564743f Mon Sep 17 00:00:00 2001 From: Rotem Liss Date: Sun, 23 Jul 2006 12:36:37 +0000 Subject: [PATCH] Deprecating ; reordering the special pages array (whose the special page list is created from) by restricted and not restricted (like Special:Specialpages), not by rights which are not used to divide the list anymore to levels, and required us to use . --- includes/Defines.php | 6 ++---- includes/Skin.php | 14 ++++---------- includes/SpecialPage.php | 3 ++- includes/SpecialSpecialpages.php | 12 ++++-------- includes/User.php | 2 +- 5 files changed, 13 insertions(+), 24 deletions(-) diff --git a/includes/Defines.php b/includes/Defines.php index 9ff8303bea..287551b4d6 100644 --- a/includes/Defines.php +++ b/includes/Defines.php @@ -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', diff --git a/includes/Skin.php b/includes/Skin.php index b56ec96ac6..00b2f44121 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -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(); } } diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 3a52f850d3..b5ba9d78eb 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -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; diff --git a/includes/SpecialSpecialpages.php b/includes/SpecialSpecialpages.php index 0b53db73c1..ea7cedae2e 100644 --- a/includes/SpecialSpecialpages.php +++ b/includes/SpecialSpecialpages.php @@ -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 ); diff --git a/includes/User.php b/includes/User.php index 7bc52aba25..a0f34be722 100644 --- a/includes/User.php +++ b/includes/User.php @@ -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='') { -- 2.20.1