Hi,
I found out how to require specific users for certain page categories. This
should be more flexible and somewhat safer than my previous quickhack, since
the template security hole doesn't occur any more (pages aquire the
categories of a template).
In the meantime I upgraded to Mediawiki 1.4beta5, so this is only tested with
this version.
Here are the changes:
-----------------------------------------
LocalSettings.php at the end:
#
# inserted by m:o
#
# set access rights
#
# usage:
# - "category" => "required_user"
# - 'required_user' can also be a list of users, separeted with blanks
# - the first expression witch matches the sitename will be used. If there are
other
# expressions that match, they will be ignored.
#
$wgRequireUser = array (
"Privat" => "Mo",
"Grid" => "Mo Max Christoph",
"H1MC" => "Mo Max Christoph"
);
-----------------------------------------
includes/Title.php line 843:
# inserted by m:o
global $wgRequireUser;
// get categories as array
$parentCategories = $this->getParentCategories();
if( !empty($parentCategories) ) //prevents php warning for uncategorized pages
{
// go through all categories wich have restrictions
foreach( $wgRequireUser as $category => $requiredUser )
{
// go through all categories to which a page belongs to
foreach( $parentCategories as $siteCategory => $wikiSite )
{
// is the page in a category that is restricted?
if( preg_match("/:".$category."$/", $siteCategory)==1 )
//if( $siteCategory == "Kategorie:".$category )
{
// ...then check, whether the user is the right one!
$user = $wgUser->getName();
$isUsrAllowed = preg_match("/\b$user\b/", "$requiredUser");
// not the right one? -> go away!
if( $isUsrAllowed!=1 )
{
return false;
}
}
}
}
}
# /inserted by m:o
Cheers,
- Moritz