Help:Regexp wgWhitelistRead

From MMVLWiki
Revision as of 14:58, 4 October 2005 by Engjw (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This hack makes entries in the array '$wgWiteListRead' be interpreted as regular expressions. The file include/Title.php has been changed as follows:

/**
  * Can $wgUser read this page?
  * @return boolean
  * @access public
  */
  function userCanRead() {
           global $wgUser;
           if( $wgUser->isAllowed('read') ) {
                return true;
           } else {
                global $wgWhitelistRead;
                /** If anon users can create an account,
                    they need to reach the login page first! */
                if( $wgUser->isAllowed( 'createaccount' )
                      && $this->getNamespace() == NS_SPECIAL
                      && $this->getText() == 'Userlogin' ) {
                          return true;
                }
                /** some pages are explicitly allowed */
                $name = $this->getPrefixedText();
                # Jan Wedekind: Changed this.
                # if( in_array( $name, $wgWhitelistRead ) ) {
                #       return true;
                #}
                if ( is_array($wgWhitelistRead) ) {
                      for ($i=0; $i<count($wgWhitelistRead); $i++) {
                            if (preg_match($wgWhitelistRead[$i],$name)) {
                                 return true;
                            }
                      }
                }
                # Compatibility with old settings
                if( $this->getNamespace() == NS_MAIN ) {
                      if( in_array( ':' . $name, $wgWhitelistRead ) )
                      {
                             return true;
                      }
                }
       }
       return false;
 }
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox