Site/Management*/Frameworks/PrivatePages

From A-State Computer Science Wiki
< Site‎ | Management*‎ | Frameworks(Redirected from *private pages)
Jump to: navigation, search

The following changes allow regular expressions to be used to build a list of private pages to prevent anonymous reads for public wikis.

Alter the file includes/Title.php to include the following lines in the function userCanRead:

 1520c1520,1529
 <        if ( !empty( $wgGroupPermissions['*']['read'] ) )
 ---
 >        if ( !empty( $wgGroupPermissions['*']['read'] ) ) {
 >                global $wgPrivatePageList;
 >                if ($wgUser->isAnon() && is_array($wgPrivatePageList)) {
 >                        $name = $this->getPrefixedText();
 >                        for ($i=0; $i<count($wgPrivatePageList); ++$i) {
 >                                if (preg_match($wgPrivatePageList[$i], $name)) {
 >                                        return false;
 >                                }
 >                        }
 >                }
 1521a1531
 >        }


Add the following lines to the file LocalSettings.php:

 #Create list of private pages (use regular expressions)
 #all pages with title starting or ending with '*' are private
 $wgPrivatePageList = array ( "/.*\*$/", "/^\*.*/" );