I added the code as you suggested below. What I have is a custom settings file that I call at the end of the LocalSettings.php file called "xoran_custom.php". I have added your code to the end of this file. But now I receive the following error when accessing the wiki:
Parse error: syntax error, unexpected '}' in C:...\wiki\includes\xoran_custom.php on line 118
Here is the code pasted from the xoran_custom.php:
<---- Begin Code ---->
# # Restrict access to custom namespaces # $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; Line 118 --> } $wgPrivateNamespaces[100] = 'edit_CSE'; $wgPrivateNamespaces[101] = 'edit_CSE'; $wgPrivateNamespaces[102] = 'edit_IT'; $wgPrivateNamespaces[103] = 'edit_IT'; // create new user groups to allow namespace editing $wgGroupPermissions['CSE']['edit_CSE'] = true; $wgGroupPermissions['IT']['edit_IT'] = true; // give sysop permission to edit all namespaces $wgGroupPermissions['sysop']['edit_CSE'] = true; $wgGroupPermissions['sysop']['edit_IT'] = true; //Restrict reading of CSE & IT (and talk) namespaces $wgPrivateNamespacesRead[100] = 'read_CSE'; $wgPrivateNamespacesRead[101] = 'read_CSE'; $wgPrivateNamespacesRead[102] = 'read_IT'; $wgPrivateNamespacesRead[103] = 'read_IT'; // give employees permission to read all namespaces $wgGroupPermissions['xoran']['read_CSE'] = true; $wgGroupPermissions['xoran']['read_IT'] = true; // give distributor access to CSE namespace only // <---- End Code ---->
I apologize for the lengthy code paste, but I am just a beginner when it comes to PHP so please bear with me.
I really appreciate your help, I'm excitied to get this working...it will make things so much easier to administer.
Thanks.
----------------------------- Jason Spirko Systems Administrator Xoran Technologies Inc.
-----Original Message----- From: mediawiki-l-bounces@lists.wikimedia.org [mailto:mediawiki-l-bounces@lists.wikimedia.org] On Behalf Of Platonides Sent: Wednesday, July 25, 2007 12:30 PM To: mediawiki-l@lists.wikimedia.org Subject: Re: [Mediawiki-l] v1.10.1 - Namespace Protection
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.
_______________________________________________ MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
.................................................................................... This message (including any attachments) contains confidential and proprietary information intended only for the addressee. If you are not the intended recipient, please notify the sender immediately by responding to this e-mail, and delete this message and attachments from your system. If you have any questions about this e-mail please notify the sender immediately. Any unauthorized disclosure, copying, distribution or reliance on the contents of this information is strictly prohibited and may constitute a violation of law.