Reverting r16861; incompatible change to message texts, breaks a lot of toggle displa...
[lhc/web/wiklou.git] / includes / SpecialPage.php
index bd98203..294c05e 100644 (file)
@@ -279,24 +279,43 @@ class SpecialPage
        }       
 
        /**
-        * Return categorised listable special pages
-        * Returns a 2d array where the first index is the restriction name
+        * Return categorised listable special pages for all users
         * @static
         */
-       static function getPages() {
+       static function getRegularPages() {
                if ( !self::$mListInitialised ) {
                        self::initList();
                }
-               $pages = array(
-                 '' => array(),
-                 'sysop' => array(),
-                 'developer' => array()
-               );
+               $pages = array();
+
+               foreach ( self::$mList as $name => $rec ) {
+                       $page = self::getPage( $name );
+                       if ( $page->isListed() && $page->getRestriction() == '' ) {
+                               $pages[$name] = $page;
+                       }
+               }
+               return $pages;
+       }
+
+       /**
+        * Return categorised listable special pages which are available
+        * for the current user, but not for everyone
+        * @static
+        */
+       static function getRestrictedPages() {
+               global $wgUser;
+               if ( !self::$mListInitialised ) {
+                       self::initList();
+               }
+               $pages = array();
 
                foreach ( self::$mList as $name => $rec ) {
                        $page = self::getPage( $name );
                        if ( $page->isListed() ) {
-                               $pages[$page->getRestriction()][$page->getName()] = $page;
+                               $restriction = $page->getRestriction();
+                               if ( $restriction != '' && $wgUser->isAllowed( $restriction ) ) {
+                                       $pages[$name] = $page;
+                               }
                        }
                }
                return $pages;
@@ -410,7 +429,7 @@ class SpecialPage
         *     and displayRestrictionError()
         *
         * @param string $name Name of the special page, as seen in links and URLs
-        * @param string $restriction Minimum user level required, e.g. "sysop" or "developer".
+        * @param string $restriction User right required, e.g. "block" or "delete"
         * @param boolean $listed Whether the page is listed in Special:Specialpages
         * @param string $function Function called by execute(). By default it is constructed from $name
         * @param string $file File which is included by execute(). It is also constructed from $name by default
@@ -460,15 +479,7 @@ class SpecialPage
         * special page (as defined by $mRestriction)
         */
        function userCanExecute( &$user ) {
-               if ( $this->mRestriction == "" ) {
-                       return true;
-               } else {
-                       if ( in_array( $this->mRestriction, $user->getRights() ) ) {
-                               return true;
-                       } else {
-                               return false;
-                       }
-               }
+               return $user->isAllowed( $this->mRestriction );
        }
 
        /**