Moritz,
I also have a similar requirement and have thought of the following
scheme: if a page is in the [[Category:Private]] category, it'll only be
viewable/editable by registered users (and, of course, the
[[Special:Userlogin]] page is protected). This is more flexible than
regex matching.
However, I'm not fluent in PHP and didn't have the time to work out the
implementation... :-(
--
John
Moritz Karbach wrote:
Hi,
as my very private Wiki grew larger, a few people liked to use it as well. So
I needed to protect the sites, that are really private. Since some kind of
user rights is scheduled for version 1.5, here comes a quickhack:
Wiki Version: 1.3.5 (maybe it works on later versions as well)
Insert the following into Title.php, function userCanRead(), right after the
globals have been defined (for me it's line 550):
# inserted by m:o
global $wgRequireUser;
$siteName = $this->getPrefixedText(); # pagename
$requiredUser = $wgRequireUser[$name];
$allowed = true;
foreach( $wgRequireUser as $siteRegExp => $requiredUser )
{
$check= preg_match("/$siteRegExp/",
"$siteName");
if( $check==1 && $wgUser->getName()!=$requiredUser )
{
$allowed = false;
}
}
if( ! $allowed ) return false;
# /inserted by m:o
Then insert the following in your LocalSettings.php at the end, just before
the '?>':
#
# inserted by m:o
#
# set access rights
#
# usage:
# "regular expression that matches the site you want to protect" =>
"required
user"
#
# examples:
# "^Linux" matches all sites beginning with "Linux"
# "Linux" matches all sites containing "Linux"
# "Linux$" % ending with "Linux"
#
$wgRequireUser = array (
"^Hauptseite:private$" => "Mo",
"^Tbd$" => "Mo",
"^Desy" => "Mo",
"^Grid" => "Mo",
"^Logbook$" => "Mo"
);
Maybe someone can comment on possible disadvantages or security holes?
Cheers,
- Moritz
_______________________________________________
MediaWiki-l mailing list
MediaWiki-l(a)Wikimedia.org
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
--
John Yu
ObjectMastery Pty. Ltd.
Level 4, 854 Glenferrie Road, Hawthorn 3122, Australia.
Tel: (+613) 8862 3222 Fax: (+613) 9818 7867