In a semi-private wiki I maintain, we are using whitelisting to make some pages visible to the public but not others. Authentication is done off of an IMAP server, and only registered users have full access tothe wiki. We still run in to the occasional page where most info should be public, but only certain bits should not appear to the public. Things like server passwords, or phone numbers should be hidden except to registered users. I created this plugin so that we can hide bits and pieces of pages from non-registered users, while making the rest of the page public. Just add a <private> tag around the text you want hidden, and you're good to go.
Copy this code to a "extensions/PrivateBlocks.php", and add the following line to LocalSettings.php:
require_once( 'extensions/PrivateBlocks.php' );
PrivateBlocks.php
<?php
$wgExtensionFunctions[] = "wfPrivateBlocks";
$wgExtensionCredits['parserhook'][] = array(
'name' => 'PrivateBlocks',
'author' => 'Aaron Parecki',
'description' => 'Adds <nowiki><private></nowiki> tag for hiding text to non-registered users',
'url' => 'http://blog.neverusethisfont.com/2008/09/hiding-text-from-non-registered-users-in-mediawiki/'
);
function wfPrivateBlocks() {
global $wgParser;
$wgParser->setHook( "private", "privateBlock" );
}
# The callback function for converting the input text to HTML output
function privateBlock($input, $args)
{
if( $_SESSION['wsUserID'] == 0 )
{
return "";
}
else
{
return $input;
}
}
?>