Jason Spirko wrote:
Hi All:
Can somebody please explain how the namespace protection works in v1.10 and
how to implement it?
You need an extension to protect per namespace, thus the
method used
will greatly vary with the extension chosen.
I have several namespaces defined in my
LocalSettings.php (see code below).
I want to be able to create user groups for each namespace and allow only
that group associated with the namespace (and sysops of course) permission
to edit pages (still allow others to read).
#
# Custom Namespaces
#
$wgExtraNamespaces =
array(100 => "CSE",101 => "CSE_talk",
102 => "IT",103 => "IT_talk",
104 => "MarCom",105 => "MarCom_talk",
106 => "OPS",107 => "OPS_talk",
108 => "Sales",109 => "Sales_talk",
);
#
# End Custom Namespaces
#
Also, is there a way to allow a specific user group read permission
to only
the main namespace and an additional namespace (ex.
only Main & Sales)?
Grant everybody else a permission to read the other namespaces.
I just need to be pointed in the right direction.
I've read the meta pages
and I guess I just don't understand...
Your could use a code like this:
$wgPrivateNamespaces = array();
$wgHooks['userCan'][] = 'wfCheckNamespace';
function wfCheckNamespace( $title, $user, $action, &$result) {
global $wgPrivateNamespaces;
if ( $action == 'read' ) {
if ( in_array( $title->getNamespace(), $wgPrivateNamespacesRead ) ) {
if ( !$user->isAllowed( $wgPrivateNamespacesRead[
$title->getNamespace() ] ) ) {
$result = false;
return false;
}
}
} else
if ( in_array( $title->getNamespace(), $wgPrivateNamespaces ) ) {
if ( !$user->isAllowed( $wgPrivateNamespaces[
$title->getNamespace() ] ) ) {
$result = false;
return false;
}
}
}
return true;
}
$wgPrivateNamespaces[100] = 'editCSE';
$wgPrivateNamespaces[101] = 'editCSE';
$wgPrivateNamespaces[102] = 'editIT';
$wgPrivateNamespaces[103] = 'editIT';
$wgPrivateNamespaces[104] = 'editMarCom';
...
$wgGroupPermissions['CSE']['editCSE'] = true;
$wgGroupPermissions['IT']['editIT'] = true;
$wgGroupPermissions['MarCom']['editMarCom'] = true;
...
$wgGroupPermissions['sysop']['editCSE'] = true;
$wgGroupPermissions['sysop']['editIT'] = true;
$wgGroupPermissions['sysop']['editMarCom'] = true;
...
//Restrict reading of CSE, IT, MarCom and OPS (and talk) namespaces
$wgPrivateNamespacesRead[100] = 'readMoreNamespaces';
$wgPrivateNamespacesRead[101] = 'readMoreNamespaces';
$wgPrivateNamespacesRead[102] = 'readMoreNamespaces';
$wgPrivateNamespacesRead[103] = 'readMoreNamespaces';
$wgPrivateNamespacesRead[104] = 'readMoreNamespaces';
$wgPrivateNamespacesRead[105] = 'readMoreNamespaces';
$wgPrivateNamespacesRead[106] = 'readMoreNamespaces';
$wgPrivateNamespacesRead[107] = 'readMoreNamespaces';
//to read them you need to be registered
$wgGroupPermissions['user' ]['readMoreNamespaces'] = true;
I practically copied PrivateNamespaces extension by amidaniel. Use at
your own risk. If you know a bit of PHP, you should be able to customize
it to do whatever you want.